单项选择题
现有:
class Parser extends Utils {
public static void main(String [] args) {
System.out.print(new Parser().getInt("42"));
}
int getInt(String arg) {
return Integer.parseInt(arg);
}
}
class Utils {
int getInt(String arg) throws Exception { return 42; }
}
结果为()
A. 42
B. 编译失败。
C. 无输出结果。
D. 运行时异常被抛出。
点击查看答案&解析
相关考题
-
单项选择题
类Student代码如下: class Student{ String name; int age; Student(String nm){ name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?()
A. 0
B. null
C. false
D. 编译错误 -
单项选择题
下列关于Java对象清除的叙述正确的是哪项?()
A. 对象被创建后,立刻变成垃圾对象
B. 任何不再被引用的对象都是垃圾收集的对象
C. 一旦对象失去引用,垃圾收集器立刻把它从内存中清除
D. Java对象的清除必须自己手动处理 -
单项选择题
下述代码执行后,有几个引用变量和几个对象?() Student stu = new Student(“Mike”); Student stua; Stua = stu;
A. 2个引用变量,1个对象
B. 1个引用变量,1个对象
C. 2个引用变量,2个对象
D. 1个引用变量,2个对象
