System.out.println("5" + 2);的输出结果应该是()
第1题:
classTestApp{publicstaticvoidmain(String[]args){intx=5;switch(x){case1:case2:case3:System.out.println(一季度”);break;case4:case5:case6:System.out.println(二季度”);case7:case8:case9:System.out.println(三季度”);break;ase10:case11:ase12:System.out.println(四季度”);break;default:System.out.println(不是有效的月份”);}}}上述程序运行后的结果是哪项?()
A.一季度
B.二季度
C.三季度
D.四季度
第2题:
Giventhefollowingcodefragment:1)Stringstr=null;2)if((str!=null)&&(str.length()>10)){3)System.out.println("morethan10");4)}5)elseif((str!=null)&(str.length()<5)){6)System.out.println("lessthan5");7)}8)else{System.out.println("end");}Whichlinewillcauseerror?()
A.line1
B.line2
C.line5
D.line8
此题需要将代码仔细看清楚,查询没有逻辑错误,if…else的使用没有问题,也没有拼写错误,错误在于第5行的“与”操作符的使用,逻辑操作符(logicaloperator)的“与”应该是&&,而&是位逻辑操作符(bitwiselogicaloperator)的“与”,使用的对象不一样,逻辑操作符的“与”的左右操作数都应该是布尔型(logicalboolan)的值,而位逻辑操作符的左右操作数都是整型(integral)值。
第3题:
A.a
B.b
C.c
D.d
E.Compilationfails.
第4题:
阅读下面程序 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
第5题:
阅读下面程序 publicclasslncrement{ publicstaticvoidmain(Stringargs[]){ intc; C=5; System.out.println?System.out.println(C++); System.out.println(C); } } 程序运行结果是( )。
A.5 6 6
B.5 5 6
C.6 7 7
D.6 6 6
第6题:
阅读下面程序 public class Increment{ public static void main(stringargs[]){ int C; c=5: System.out.println(c); System.out.println(c++): System.out.println(c); } } 程序运行结果是( )。
A.5 6 6
B.5 5 6
C.6 7 7
D.6 6 6
第7题:
下列代码的执行结果是( )。 PublicclassTest { Publicstaticvoidmain(Stringargs[]) { System.out.println(5/2); System.out.println(100%3.0) } }
A.2和1
B.2和1.0
C.2.5和1
D.2.5和1.0
第8题:
boolean bool = true; if(bool = false) { System.out.println(“a”); } else if (bool) { System.out.println(“c”); } else if (!bool) { System.out.println(“c”); } else { System.out.println(“d”); } What is the result?()
第9题:
try { int x = 0; int y = 5 / x; } catch (Exception e) { System.out.println(“Exception”); } catch (ArithmeticException ae) { System.out.println(“Arithmetic Exception”); } System.out.println(“finished”); What is the result?()
第10题:
class TestApp{ public static void main(String[] args){ int x = 5; switch(x){ case 1: case 2: case 3: System.out.println(“一季度”); break; case 4: case 5: case 6: System.out.println(“二季度”); case 7: case 8: case 9: System.out.println(“三季度”); break; ase 10: case 11: ase 12: System.out.println(“四季度”); break; default: System.out.println(“不是有效的月份”); } } } 上述程序运行后的结果是哪项?()
第11题:
a
b
c
d
Compilation fails.
第12题:
52
7
2
5
第13题:
程序:classTestApp{publicstaticvoidmain(String[]args){intx=6;if(x>l)System.out.println("x>l");elseif(x>5)System.out.println("x>5");elseif(x<10)System.out.println("xSystem.out.println("x<29");elseSystem.out.println(以上都不是”);}}上述程序运行后的结果是哪项?()
A.x>5
B.x>l
C.x<10
D.x<29
第14题:
A.finished
B.Exception
C.Compilationfails.
D.ArithmeticException
第15题:
阅读下面程序 public class Increment { public static void main( String args[] ){ int c; c=5; System.out.println(C) ; System.out.println(c++); System.out.println(C) ; } }
A.5 6 6
B.5 5 6
C.6 7 7
D.6 6 6
第16题:
阅读下面程序 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
第17题:
下面程序的运行结果是( )。 public class Increment { public static void main(String args[ ] ){ int c; c=5; System.out.println(c) ; System.out.println(c++); System .out.println(c) ; } }
A.5 6 6
B.5 5 6
C.6 7 7
D.6 6 6
第18题:
下列代码的执行结果是( )。 int length="Hell0".length; System.OUt.println(length);
A.5
B.2
C.10
D.6
第19题:
A.第3行出现编译错误
B.输出23, 5, 5 和23.
C.输出5, 5, 5 和23.
D.输出 23, 5, 23 和23.
第20题:
System.out.println("5" + 2);的输出结果应该是()
第21题:
Given the following code fragment: 1) String str = null; 2) if ((str != null) && (str.length() > 10)) { 3) System.out.println("more than 10"); 4) } 5) else if ((str != null) & (str.length() < 5)) { 6) System.out.println("less than 5"); 7) } 8) else { System.out.println("end"); } Which line will cause error?()
第22题:
一季度
二季度
三季度
四季度
第23题:
line 1
line 2
line 5
line 8
第24题:
finished
Exception
Compilation fails.
Arithmetic Exception