A simple example of inheritance along explanation of constructor calling
class A {
A() {
System.out.println("Hey! I'm father of all.");
}
}
class B extends A {
B() {
System.out.println("Hey! I'm child of A.");
}
}
class C extends B {
C() {
System.out.println("Hey! I'm child of B and younger one.");
}
}
public class Inheri {
public static void main(String[] args) {
C youngerone = new C();
}
}
class A {
A() {
System.out.println("Hey! I'm father of all.");
}
}
class B extends A {
B() {
System.out.println("Hey! I'm child of A.");
}
}
class C extends B {
C() {
System.out.println("Hey! I'm child of B and younger one.");
}
}
public class Inheri {
public static void main(String[] args) {
C youngerone = new C();
}
}
Comments
Post a Comment
Post Your Valuable Comments