“hello”
“good-bye”
“hello”“good-bye”
代码不能编译
第1题:
阅读下列代码段,选出该代码段的正确文件名( )。 class A { void methodl() { System.out.println("methodl in class A"); } } public class B { void method2() { System.out.println("method2 in class B"); } public static void main(String args[]) { System.out.println("main in class B"); } }
A.A.java
B.A.class
C.B.class
D.B.java
第2题:
阅读下列代码
Public class Person{
Static int arr[ ] = new int (10);
Public static void main (String args ) {
System.out.println(arr[9]);
}
}
该代码运行的结果是
A )编译时将产生错误
B )编译时正确,运行时将产生错误
C )输出 0
D )输出空
第3题:
有下列程序段 public class fun { public static void main(String args[]) { char b[]="Hello,you"; b[5] = 0; System.out.println(s); } 执行此程序后,得到的输出结果是( )。
A.Hello, you
B.Hello0you
C.Hello
D.0
第4题:
对于下面一段代码的描述中,正确的是______。 public class ex36 { public static void run main(String[] args) throws Excepion { method(); } static void method() throws Exception try { System.out.println("test"); } finally { System.out.println ("finally"); } } }
A.代码编译成功,输出“test”和“fmally”
B.代码编译成功,输出“test”
C.代码实现选项A中的功能,之后Java停止程序运行,抛出异常,但是不进行处理
D.代码不能编译
第5题:
A.编译错误;
B.运行输出 "Hello cruel world";
C.编译无错,但运行时指示没有定义构造方法。
D.编译无错,但运行时指示没有正确定义main方法。
第6题:
分析下列代码: Class A{ Public static void main(String[] args){ method(); } static void method(){ try{ System.out.println("Hello"); }finally{ System.out.println("good-bye"); } } } 编译运行后,输出结果是()。
第7题:
class A { public A() { System.out.println(“hello from a”); } } class B extends A { public B () { System.out.println(“hello from b”); super(); } } public class Test { public static void main(String args[]) { A a = new B(); } } What is the result when main is executed?()
第8题:
考虑下列Java代码: class A { public static void main(String[] args) { try { System.out.println("Hello, World!"); } } } 其中的错误是()。
第9题:
现有: class Pencil { public void write (String content){ System.out.println ("Write"+content); } } class RubberPencil extends Pencil{ public void erase (String content){ System.out.println ("Erase"+content); } } 执行下列代码的结果是哪项?() Pencil pen=new RubberPencil(); pen.write ("Hello"); pen.erase ("Hello");
第10题:
Hello
good-bye
Hello后面是good-bye
代码不能编译
第11题:
没有catch或finally块
没有抛出异常的代码不能出现在try代码块内
如果没有catch块而使用try,main()会总是抛出异常.
class A 没有throws IOException
第12题:
没有catch或finally块
没有抛出异常的代码不能出现在try代码块内
如果没有catch块而使用try,main()会总是抛出异常.
class A 没有throws IOException
第13题:
阅读下列代码段,选出该代码段的正确文件名( )。 class A { void method1() { System.out.println("method1 in class A"); } } public class B { void method2() { System.out.println("method2 in class B"); } public static void main(String args[]) { System.out.println("main in class B"); } }
A.A.java
B.A.class
C.B.class
D.B.java
第14题:
请在下划线处填入代码,是程序正常运行并且输出 “ Hello! ”
Class Test 【 15 】 {
Public static void main (String[] arge){
Test t = new Test();
t.start();
}
Public void run(){
System.out.println( “ Hello! ” );
}
第15题:
阅读下列代码段,选出该代码段的正确的文件名( )。 class A { void method () { System.out.println ("methodl in class A"); } } public class B { void method2 () { System.out.println("method2 in class B"); } public static void main (String args[]) { System.out.println ("main () in class B"); } }
A.A.java
B.A.class
C.B.class
D.B.java
第16题:
下列程序的输出结果是( )。 public class Test { public static void main (String[] args) { String s="hello"; s.replace ('r','m'); System.out.println(s); } }
A.hello
B.HELLO
C.hemmo
D.HEMMO
第17题:
A. hello
B. hello2
C. 编译报错
D. 运行报错,不能将串与整数相加
第18题:
考虑下列Java代码: Classc A{ Public static void main(String []args){ Try{ System.out.println(“hello,world”) } } } 其中错误的是()。
第19题:
分析下列Java代码: class A { public static void main(String[] args) { method(); } static void method() { try { System.out.println("Hello"); System.exit(0); } finally { System.out.println("good-bye"); } } } 编译运行后,输出结果是()。
第20题:
分析下列java代码 Class A{ Public static void main(String[] args){ Method(); } Static void method(){ try{ System.out.println(“hello”) }finally{ System.out.println(“good-bye”); } } } 编译运行后,输出结果是()
第21题:
程序不能通过编译,因为没有import语句将Thread类引入
程序不能通过编译,因为Test类没有实现Runnable接口
程序通过编译,且运行正常,没有任何输出
程序通过编译,且运行正常,打印出一个"Hello"
第22题:
Hello
good-bye
Hellogod-bye
代码不能编译
第23题:
Compilation fails.
hello from a
hello from b
hello from b hello from a
hello from a hello from b