How to create Relations with different types of Objects

This is an overview of my Protected Keywords Program this will help you to understand the concept very easily. Here i have created the different types of Packages for different functions.

package p1;

public class  C1{

  public int x;

  protected int y;

  int z;

  protected void m();

  private int u;


package p1;

public class  C2{

  C1 o=new C1();







package p1;

public class  C3 extends C1{

  status of x,y,z,u,and m()


package p2;
public class  C4 extends C1{

  status of x, y, z, u, and m()


package p2;
public class  C5 {

  C1 o=new C1();

  status of x, y, z, u, and m()



In this i have used the Overriding concept by using methods Overriding. The main use of this concept is to override the one with other.

class Homer {

char doh(char c) {


return ‘d’;}

float doh(float f) {


return 1.0f; }}

class Milhouse {}

class Bart extends Homer {

void doh(Milhouse m) {


public class Hide {

public static void main(String[] args) {

Bart b = new Bart();




b.doh(new Milhouse());}}`

class Customer{

  private int cid;

  private static int counter =1000;

  public Customer(){cid=++counter; }

  public void displayCust(){

  System.out.println(“Custid :” +cid);}


class RegCustomer extends Customer{

  private float dis;

  public RegCustomer(float x){ dis=x; }

  public void displayCust(){

  System.out.println(“Discount :” +dis); }



class PriCustomer extends Customer{

  private String as;

  public PriCustomer(String x){ as=x; }

  public void displayCust(){

  System.out.println(“Meme :” +as);}


class Retail{

  public static void main(String [] args){

  RegCustomer rc=new RegCustomer(10.5f);

  PriCustomer pc=new PriCustomer(“Gold”);

  rc.displayCust(); pc.displayCust();



error: Content is protected !!