Thursday, 8 October 2015

Java Program Example to demonstrtae First parent constructor is called followed by chiled class constructor

/**
 *
 */

/**
 *
 *
 */
public class Second {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
First obj = new First();
}

}


public class Demo {
Demo(){
System.out.println("Test one");
}
}

class First extends Demo{
First(){
System.out.println("Test Two");
}
}

Output:-
Test one
Test Two

No comments:

Post a Comment