A: 程序编译正确,命令行输入参数123,抛出异常
B: 程序语法错误
C: 程序编译错误,
D: 程序编译正确,没有输出结果
举一反三
- 读下面代码,哪个选项是正确的( )import java.io.*;public class Test2{public static void main(String []args)throws IOException{if(args[0]==”hello”)throw new IOException();}} A: 没有错误,程序编译正确 B: 编译错误,不能够在main方法中抛出异常 C: 编译错误,IOException是一个系统异常,不能够由application程序产生 D: 没有输出结果
- 对于如下代码,下列哪个叙述是正确的?public class E { public static void main (String args[]) { String s0 = args[0]; String s1 = args[1]; String s2 = args[2]; System.out.println(s2); }} A: 程序出现编译错误 B: 无编译错误,在命令行执行程序:“java E I love this game”,程序输出game C: 无编译错误,在命令行执行程序:“java E go on”,运行异常:ArraylndexOutOfBoundsException:2. D: 无编译错误,在命令行执行程序:“java E you are ok”程序输出you
- 35 下面程序运行的结果是() public class X { private static int a; public static void main(String [] args) { modify(a); System.out.println(a); } public static void modify(int a) { a++; } } A: 0 B: 1 C: 程序编译失败 D: 程序抛出异常
- 代码如下: public class Foo{ public static void main(String args[]){ String s; System.out.println("s="+s); } } 下列关于程序编译运行的说法正确的是: A: 程序编译正确,并输出: “s=” 。 B: 程序编译正确,并输出: “s=null”。 C: 程序编译错误,因为变量s未被初始化。 D: 程序编译正确,但运行时抛出空指针异常。
- 对于如下代码,叙述正确的是()public class E {public static void main (String args[]) {String s1 = args[1];String s2 = args[2];String s3 = args[3];System.out.println(s3);}} A: 程序出现编译错误 B: 无编译错误,在命令行执行程序:“java E I love this game”,程序输出this C: 无编译错误,在命令行执行程序:“java E let us go”,程序无运行异常 D: 无编译错误,在命令行执行程序:“java E 0 1 2 3 4 5 6 7 8 9”,程序输出3
内容
- 0
下列叙述正确的是( ) public class E { public static void main(String args[]) { String s1=args[1]; String s2=args[2]; String s3=args[3]; System.out.println(s3); } } A: 程序编译出现错误 B: 无编译错误,在命令行执行程序“java E I love this game”,程序输出this C: 无编译错误,在命令行执行程序“java E let us go”,程序无运行异常 D: 无编译错误,在命令行执行程序“java E 0 1 2 3 4 5 6 7 8 9”,程序输出3
- 1
阅读下面的程序,分析代码是否能编译通过。如果能编译通过,请列出运行的结果;如果不能编译通过,请说明原因。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( );}}
- 2
阅读下面的程序,分析代码是否能编译通过,如果能编译通过,选正确。如果不能编译通过,选错误。 public class A extends Thread{ protected void run() { System.out.println("thisisrun()"); } public static void main(String[] args) { A a = new A(); a.start(); } }
- 3
interface A{ void x(); } class B implements A{ public void x(){} public void y(){} } class C extends B{ public void x(){System.out.println("C");} } public class Test{ public static void main(String args[]){ B b=new B(); B c=new C(); b.x(); c.y(); } } A: 程序运行错误 B: 程序没有输出结果 C: 程序输出C。 D: class B implements A 编译错误 E: c.y();编译错误
- 4
阅读下面代码段:public class Demo{public static void main (String[] args){int[] arr = new int [10];System.out.println(arr[1]);}}执行结果正确的说法是( ) A: 编译时将产生错误 B: 编译时正确,运行时将产生错误 C: 输出0 D: 输出空
