- ALL METHOD IMPLEMENTS FROM INTERFACE MUST BE DECLARED AS PUBLIC
2. ClassName(){ super(){}} is added automatically if there is no programmer-defined constructor.
QUESTION NO: 88
Given:
1. public class Plant {
2. private String name;
3. public Plant(String name) { this.name = name; } //if (Plant has no Constructor) JVM add Plant(){ super(){} } automatically;
4. public String getName() { return name; }
5. }
The code will compile if public Plant() { this("fern"); } is added to the Plant class.
QUESTION NO: 88
Given:
1. public class Plant {
2. private String name;
3. public Plant(String name) { this.name = name; } //if (Plant has no Constructor) JVM add Plant(){ super(){} } automatically;
4. public String getName() { return name; }
5. }
1. public class Tree extends Plant {
//Tree(){ super(){} } was added automatically.
2. public void growFruit() { }
3. public void dropLeaves() {}
4. }
//Tree(){ super(){} } was added automatically.
2. public void growFruit() { }
3. public void dropLeaves() {}
4. }
No comments:
Post a Comment