单项选择题
class Number {
public static void main(String [] args) {
try {
System.out.print(Integer.parseInt("forty "));
} catch (RuntimeException r) {
System.out.print("runtime ");
} catch (NumberFormatException e) {
System.out.print("number ");
}
}
}
结果是什么?()
A.forty
B.number
C.runtime
D.编译失败
点击查看答案&解析
相关考题
-
单项选择题
final class Tree { private static String tree = "tree "; String getTree() { return tree; } } class Elm extends Tree { private static String tree = "elm "; public static void main(String [] args) { new Elm().go(new Tree()); } void go(Tree t) { String s = t.getTree()+Elm.tree+tree+(new Elm().getTree()); System.out.println(s); } } 结果为:()
A.elm elm elm elm
B.tree elm elm elm
C.tree elm tree elm
D.编译失败 -
单项选择题
1. class Animal { Animal getOne() { return new Animal(); } } 2. class Dog extends Animal { 3. // insert code here 4. } 5. 6. class AnimalTest { 7. public static void main(String [] args) { 8. Animal [] animal = { new Animal(), new Dog() } ; 9. for( Animal a : animal) { 10. Animal x = a.getOne(); 11. } 12. } 13. } 和代码: 3a. Dog getOne() { return new Dog(); } 3b. Animal getOne() { return new Dog(); } 第 3 行中插入的哪项将编译且运行无异常?()
A.3a行
B.3b行
C.3a行或3b行
D.既非3a,也非3b -
单项选择题
class Guy { String greet() { return "hi "; } } class Cowboy extends Guy { String greet() { return "howdy "; } } class Wrangler extends Cowboy { String greet() { return "ouch! "; } } class Greetings2 { public static void main(String [] args) { Guy g = new Wrangler(); Guy g2 = new Cowboy(); Wrangler w2 = new Wrangler(); System.out.print(g.greet()+g2.greet()+w2.greet()); } } 结果是什么?()
A.hi hi ouch!
B.hi howdy ouch!
C.ouch! howdy ouch!
D.编译失败
