单项选择题
现有:
class ThreadExcept implements Runnable {
public void run() { throw new RuntimeException("exception "); }
public static void main(Stri_ng [] args) {
new Thread (new ThreadExcept()).start();
try {
int x=Integer.parselnt (args [0]);
Thread. sleep (x);
System.out.print("main");
} catch (Exception e) { }
}
}
和命令行: java ThreadExcept l000
哪一个是结果?()
A.main
B.编译失败
C.main java.lang.RuntimeException: exception
D.代码运行,但没有输出
点击查看答案&解析
相关考题
-
单项选择题
现有:t是一个合法的Thread对象的引用,并且t的合法run()方法如下: public void run() { System.out.print ("go"); } 及: t.start(); t.start(); t.run(); 哪一个是结果?()
A.go go
B.go go go
C.go之后跟着一个异常
D.go go之后跟着一个异常 -
单项选择题
现有: class ThreadBoth extends Threaa implements Runnable { public void run() (System.out.print("hi"); } public static voicl main (String [] args) { Thread tl=new ThreadBoth(): Thread t2 = new Thread (tl): tl.run(): t2.run(): } 结果为:()
A. hi hi
B. hi
C.编译失败
D.运行时异常被抛出 -
单项选择题
程序员想要创建一个名为MyThread的类以便在main方法中用Thread实例化。对于下面三行: MyThread必须继承Thread。 MyThread必须实现Thread。 MyThread必须覆盖public void run()。 有几行是正确的()
A. 0
B. 1
C. 2
D. 3
