Site hosted by Angelfire.com: Build your free website today!
 

Object Construction

When a constructor is called in a class, a call is immediately make to the constructor of its superclass.

class Parent {
   Parent() {
        System.out.println("Creating the Parent");
   }
}
class Child extends Parent {
   Child() {
        System.out.println("Creating the Child");
   }
   Child(boolean flag) {
        System.out.println("Creating the Child with parameter");
   }
}
class GrandChild extends Child {
   GrandChild() {
        System.out.println("Creating the GrandChild");
   }
   GrandChild(boolean flag) {
        System.out.println("Creating the GrandChild with parameter");
   }
   public static void main(String[] args) {
        GrandChild obj = new GrandChild();
   }
}

What is the output of the program?