Java examples for Object Oriented Design:Constructor
Constructors for all Ancestors Are Called When an Object of a Class Is Created Starting at the Top of the Class Hierarchy and Going Down
class MyClass extends MyBase { public MyClass() { super(); // Injected by the compiler System.out.println("Inside CSub() constructor."); }/*w ww . j a v a2 s.c om*/ } class MyBase { public MyBase() { super(); // Injected by the compiler System.out.println("Inside CSuper() constructor."); } } public class Main { public static void main(String[] args) { MyClass cs = new MyClass(); } }