0
Using inheritance,class ,functions writing java code for hobbys like cricket,reading all should display
2 Answers
0
class GrandParent {
  int a;
Â
 GrandParent(int a) {
   this.a = a;
  }
}
Â
class Parent extends GrandParent {
  int b;
Â
 Parent(int a, int b) {
   super(a);
   this.b = b;
  }
Â
  void show() {
   System.out.println("GrandParent's a = "+ a);
   System.out.println("Parent's b    = "+ b);
  }
}
Â
class Child {
  public static void main(String[] args) {
  Parent object = new Parent(8, 9);
  object.show();
  }
0
By this example i want to create two class one super and sub class and then display my hobbies such as cricket,reading ,writing etc