「Java」「Singleton」 Chapter4 Question11
Given:
Answer:
Bird b2 = new Bird(); 導致無法通過編譯,是必須移除
而 在 Test2 類別中 String fly()方法是可以移除的。
abstract class Bird{
String fly() {
return "fly";
}
abstract void dock();
}
public class Test2 extends Bird{
public static void main(String[] args) {
Bird b = new Test2();
Bird b2 = new Bird();
}
String fly() {
return "flyfly";
}
void dock() {}
}
Answer:
Bird b2 = new Bird(); 導致無法通過編譯,是必須移除
而 在 Test2 類別中 String fly()方法是可以移除的。
留言
張貼留言