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