Multiple
child classes derived from one base(super class) class is called
Hierarchical inheritance.
class A{ A(){ System.out.println("I am class A's default constructor"); } A(int a){ System.out.println("I am class A's parameterized constructor"; } }
class B extends A{ B(){ System.out.println("I am class B's default constructor"); } B(int a){ System.out.println("I am class B's parameterized constructor"; } }
class C extends A{ C(){ System.out.println("I am class C's default constructor"); } C(int a){ System.out.println("I am class C's parameterized constructor"; } }
class D extends A{ D(){ System.out.println("I am class D's default constructor"); } D(int a){ System.out.println("I am class D's parameterized constructor"); } }
No comments:
Post a Comment