(多线程的两种实现方法)阅读下面程序:class Test implements Runnable{ public static void main(String[] args){ Test t=new Test(); t.start(); } public void run(){} }下列关于上述程序的叙述正确的是_______。
A: 程序不能通过编译,因为start()方法在Test类中没有定义
B: 程序编译通过,但运行时出错,提示start()方法没有定义
C: 程序不能通过编译,因为run()方法没有定义方法体
D: 程序编译通过,且运行正常
A: 程序不能通过编译,因为start()方法在Test类中没有定义
B: 程序编译通过,但运行时出错,提示start()方法没有定义
C: 程序不能通过编译,因为run()方法没有定义方法体
D: 程序编译通过,且运行正常
举一反三
- 中国大学MOOC: (多线程的两种实现方法)阅读下面程序:class Test implements Runnable{ public static void main(String[] args){ Test t=new Test(); t.start(); } public void run(){}}下列关于上述程序的叙述正确的是_______。
- 阅读下面的程序,分析代码是否能编译通过。如果能编译通过,请列出运行的结果;如果不能编译通过,请说明原因。class RunHandler {public void run() {System.out.println("run");}}public class Read01 {public static void main(String [] args) {Thread t = new Thread(new RunHandler( ));t.start( );}}
- 分析下列代码: public class Test { public static void main(String[ ] args) { double radius; final double PI= 3.15169; double area = radius * radius * PI; System.out.println("Area is " + area); } } A: 程序有编译错误,因为变量radius未初始化。 B: 程序有一个编译错误,因为在方法内部定义了一个常量PI。 C: 程序没有编译错误,但会得到一个运行时错误,因为radius没有初始化。 D: 程序编译和运行良好。
- 阅读下面的程序,分析代码是否能编译通过,如果能编译通过,选正确。如果不能编译通过,选错误。 public class A extends Thread{ protected void run() { System.out.println("thisisrun()"); } public static void main(String[] args) { A a = new A(); a.start(); } }
- 分析下述代码,下列描述正确的是()。public class Test { public static void main(String[] args) { double radius; final double PI= 3.15169; double area = radius * radius * PI; System.out.println("Area is " + area); }} A: 程序有编译错误,因为变量半径未初始化。 B: 程序编译并运行良好。 C: 程序没有编译错误,但会出现运行时错误,因为radius未初始化。 D: 程序有编译错误,因为在方法中定义了常量PI。