试题详情
- 单项选择题 1. class Pizza { 2. java.util.ArrayList toppings; 3. public final void addTopping(String topping) { 4. toppings.add(topping); 5. } 6. } 7. public class PepperoniPizza extends Pizza { 8. public void addTopping(String topping) { 9. System.out.println(”Cannot add Toppings”); 10. } 11. public static void main(String[] args) { 12. Pizza pizza = new PepperoniPizza(); 13. pizza.addTopping(”Mushrooms”); 14. } 15. } What is the result?()
A、 Compilation fails.
B、 Cannot add Toppings
C、 The code runs with no output.
D、 A NullPointerException is thrown in Line 4.
- A
关注下方微信公众号,在线模考后查看
热门试题
- 有关for和while循环,以下说法错误
- 在java中,下列标识符不合法的有()。
- 使GUI事件处理器生效的方法是:()
- 编写Applet程序,包含三个标签,其背
- 4位反序数,设N是一个四位数,它的9倍恰
- You have
- 菲波那契(Fibonacci)数列的第一
- “哥德巴赫猜想”指出,每个大于6的偶数,
- public interfa
- Java语言中表达式“11”+22的结果
- 现有: interface
- You need
- Which statement
- Which two̳
- 25.intx=12; 2
- public class&e
- 下述代码执行后,有几个引用变量和几个对
- Assume that&en
- Which is e
- 程序员已经创建了一个类,该类的实例可以用