请看下列代码: public class Plant { private String name; public Plant(String name) { this.name = name; } public String getName() { return name; } } class Tree extends Plant { public void growFruit() { } public void dropLeaves() { } } 下列说法正确的是
选项:
A:在Tree类中添加代码:public Tree() { Plant(); },编译将通过
B:在Plant类中添加代码:public Plant() { Plant(”fern”); },编译将通过
C:在Plant类中添加代码:public Plant() { Tree(); },编译将通过
D:在Plant类中添加代码:public Plant() { this(”fern”); },编译将通过
发布时间:2024-06-12 01:18:15