Java Constructor 2 !?

What is the expected output?


class Plant {
      Plant() {
      System.out.println("Plant created");
}
}
class Tree extends Plant {
       Tree() {
       System.out.println("Tree created");
       super();
}
}
public class Test {
public static void main(String args[]) {
       Tree tree = new Tree();
}
}

Please choose only one answer:
1)    Plant created
       Tree created
2)    Tree created
       Plant created
3)    RuntimeException
4)    Compilation error


Comments

Popular posts from this blog

String Concept

String and StringBuffer!