A.第3行出现编译错误
B.输出23, 5, 5 和23.
C.输出5, 5, 5 和23.
D.输出 23, 5, 23 和23.
第1题:
下面程序段的输出结果是( )。 public class Test{ public static void main(String args[]){ int X,y; x=(int)Math.sqrt(5)/2+(int)Math.random*5/2; y=(int)Math.sqrt(3)/2+(int)Math.random*3/2; if(x>v) System.OUt.println("x>y"); elseif(x= =y) System.out.println("x=Y"); else System.out.println("x<y"): } }
A.x>y
B.x=Y
C.x<y
D.编译错误
第2题:
下列程序段执行后的输出结果为( )。 int x=3; int y=10; System.out.println(y%x);
A.0
B.1
C.2
D.3
第3题:
阅读下面程序 public class Test1 { public static void main(String[] args){ System.out.println(34+56-6); System.out.println(26*2-3); System.out.println(3*4/2); System.out.println(5/2); } } 程序运行结果是
A.84 49 6 2
B.90 25 6 2.5
C.84 23 12 2
D.68 49 14 2.5
第4题:
如下的代码段中,如果方法unsafe()正常运行,那么结果是( )。 public void example() { try { unsafe(); System.out.println("Testl"); }catch(SafeException e) { System.out.println("Test 2"); }finally{ System.out.println("Test 3'); } System.out.println("Test 4"); }
A.Test 3 Test 4
B.Test1 Test3 Test4
C.Test1 Test3
D.Test1 Test4
第5题:
给出下列的程序代码片段,m为哪个值时将会输出default? switch(m) { case 0:System.out.println("case0"); case 1:System.out.println("case 1");break; case 2:System.out.println("case 2");break; default:System.out.println("default"); }
A.0
B.1
C.2
D.3
第6题:
在oneMethod()方法运行正常的情况下,程序段将输出______。 public void test() { try{ oneMethod(); System.out.println("ndition 1"; } catch (ArrayIndexOutOfVoundsException e){ System.out.println("ondition 2"; } catch (Exception e){ System.out.println("ondition 3"; } finally{ System.out.println ( "inally"; } }
A.condition1
B.condition2
C.condition3
D.condition1 finally
第7题:
A.2
B.3
C.5
D.7
第8题:
A. 小于 0
B. 小于 4
C. 4 和9之间
D. 大于9
E. 无任何可能
第9题:
研究下面的Java代码: switch (x) { case 1: System.out.println(1); case 2: case 3: System.out.println(3); case 4: System.out.println(4); } 当x=2时,运行结果是()。
第10题:
没有输出任何结果
输出结果为3
输出结果是3和4
输出结果是1、3和4
第11题:
condition 1 finally
condition 2 finally
condition 3 finally
finally
第12题:
if(2==3)System.out.println(Hi);
if(2=3)System.out.println(Hi);
if(true)System.out.println(Hi);
if(2!=3)System.out.println(Hi);
第13题:
在oneMethod( )方法运行正常的情况下,程序段将输出( )。 public void test( ){ try {oneMethod( ); System.out.println ("condition 1"); }catch (ArratlndexOutOfBoundException e){ System.out.println("condition2"): }catch (Exception e){ System.out.println("condition 3"); }finnally{ System.out.println("finally"): } }
A.condition 1
B.condition2
C.condition 3
D.condition 1 finally
第14题:
阅读下面程序 public class Test1 { public static void main(String[] args) { System.out.println(34+56-6); System.out.println(26*2-3); System.out.println(3*4/2); System.out.println(5/2); } } 程序运行的结果是
A.84 49 6 2
B.90 25 6 2.5
C.84 23 12 2
D.68 49 14 2.5
第15题:
给出下列的程序段,m为何值时将会输出default? ( ) switch(m) { case 0: System.out.println("case 0"); case 1:System.out.println("case 1");break; case 2:System.out.println("case 2");break; default:System.out.println("default"); }
A.0
B.1
C.2
D.3
第16题:
给出下列的程序片段,m为( )时将会输出default。 switch (m) case ():Systemt.out.println("case 0"); case 1: System.out.println("case 1");break; case 2:System.out.println("case2");break; default:System.out.println("default");
A.0
B.1
C.2 2
D.3
第17题:
下列代码的执行结果是( )。 public class Test { public static void main(String args[]) { System.out.println(5/2); System.OUt.println(100%3.O) } }
A.2和1
B.2和1.0
C.2.5和1
D.2.5和1.0
第18题:
以下代码段的输出结果为
1. int x = 0, y = 4, z = 5;
2. if (x >2、{
3. if (y<5、{
4. System. out .println ( "message one" );
5. }
6. else {
7. System.out.println( "message two");
8. }
9. }
10. else if (z >5、{
11. System.out.println("message three");
12. }
13. else {
14. System.out.println( "message four");
15. }
A. message one
B. message two
C. message three
D. message four
第19题:
编译和运行以下代码结果为:
1. public class EqualsTest{
2. public static void main(String args[]){
3. byte A=(byte)4096;
4. if(A== 4096、System.out.println("Equal");
5. else System.out.println("Not Equal");
6. }
7. }
A.在第3行出现转换丢失精度的编译错误.
B.输出 "Not Equal".
C.输出 "Equal".
第20题:
有如下代码段:
switch ( x ){
case 1:System.out.println("One");break;
case 2:
case 3:System.out.println("Two");break;
default:System.out.println("end");
}
变量x的取值下列哪些情形时,能使程序输出"Two" 。
A. 1
B. 2
C. 3
D. default
第21题:
以下会产生编译错误的Java语句是()。
第22题:
condition 1
condition 2
condition 3
finally
第23题:
0
1
2
3