Tuesday 2 April 2013

Constructor Calling in java


// ----------- Constructor Calling in java --------------//


class Acun{
Acun(){
System.out.println("Super Class Constructor is print...");
}
}
class Bcun extends Acun{
Bcun(){
System.out.println("B sub class constructor is print...");
}
}
class Ccun extends Bcun{
Ccun(){
System.out.println("C sub class constructor is print...");
}
}

class Constructor_Call {
public static void main(String args[]){
  Ccun c = new Ccun();
  // new Ccun();
}
}

//---------------------------------------
Answer is:

Super Class Constructor is print...
B sub class constructor is print...
C sub class constructor is print...

No comments:

Post a Comment