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();

  o.x;//?

  o.y;//?

  o.z;//?

  o.u;//?

  o.m()//?

}

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) {

System.out.print(“doh(char)”);

return ‘d’;}

float doh(float f) {

System.out.print(“doh(float)”);

return 1.0f; }}

class Milhouse {}

class Bart extends Homer {

void doh(Milhouse m) {

System.out.print(“doh(Milhouse)”);}}

public class Hide {

public static void main(String[] args) {

Bart b = new Bart();

b.doh(1);

b.doh(‘x’);

b.doh(1.0f);

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: