What is the output of the following code?
// Create a super class. class A {/*from w w w. j ava 2s . co m*/ A() { System.out.println("Inside A's constructor."); } } // Create a subclass by extending class A. class B extends A { B() { System.out.println("Inside B's constructor."); } } // Create another subclass by extending B. class C extends B { C() { System.out.println("Inside C's constructor."); } } public class Main { public static void main(String args[]) { C c = new C(); } }
Inside A's constructor. Inside B's constructor. Inside C's constructor.
The constructors are executed in order of derivation.