14
编译错误
120
24
第1题:
A.120
B.24
C.14
D.编译错误
第2题:
A.14
B.编译错误
C.120
D.24
第3题:
下列语句中变量result的结果为( )。 public class test { public static void main(String args[ ]) { int sum=10; int r=3; int result=sum %( ++r); System.out.println(result); } }
A.3
B.10
C.2
D.4
第4题:
有如下程序: public class MethLoad { public static void main(String args[]) { MethLoad classObj=new MethLoad(); classObj.methtest(4); classObj.methtest(0); } void methtest(double d) { double sum=2*d; System.out.println("The result is:"+sum); } void methtest(int n) { int sum=4*n; System.out.println("The result is:" +sum); } }程序的运行结果为( )。
A.The result is:16 The result is:0
B.The result is:0 The result is:16
C.The result is:8 The result is:0
D.The result is:0 The result is:8
第5题:
程序: class TestApp{ public static void main(String[] args){ System.out.println(multiply(2,3,4,5)); } public int multiply(int[] nums){ int result = 1; for(int x :nums) result *= x; return result; } } 程序运行后的输出是哪项?()
第6题:
interface DeclareStuff{ public static final int EASY = 3; void doStuff(int t); } public class TestDeclare implements DeclareStuff { public static void main(String [] args) { int x=5; new TestDeclare().doStuff(++x); } void doStuff(int s) { s += EASY + ++s; System.out.println(”s “ + s); } } What is the result?()
第7题:
public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?()
第8题:
public class Test { private static int[] x; public static void main(String[] args) { System.out.println(x[0]); } } What is the result?()
第9题:
class TestApp{ public static void main(String[] args){ System.out.println(multiply(2,3,4,5)); } public int multiply(int... nums){ int result=1; for(int x:nums) result*=x; return result; } } 程序运行后的输出是哪项?()
第10题:
120
24
14
编译错误
第11题:
14
编译错误
120
24
第12题:
14
编译错误
120
24
第13题:
classTestApp{publicstaticvoidmain(String[]args){System.out.println(multiply(2,3,4,5));}publicintmultiply(int…nums){intresult=1;for(intx:nums)result*=x;//result=result*x;returnresult;}}2、6、24、120程序运行后的输出是哪项?()
A.14
B.编译错误
C.120
D.24
第14题:
阅读下面程序
public class OperatorsAndExpressions {
String conditionalExpression(int score) {
String result;
//如果score超过60分,则结果是passed,否则是doesn't pass
result=(score>=60)?"passed":"doesn't pass":
System.out.println(result);
return result;
}
public static void main(String args[]) {
OperatorsAndExpressions perAndExp=new OperatorsAndExpressions();
//条件表达式
OperAndExp.conditionalExpression(65);
}
}
程序的执行结果是______。
第15题:
下面的语句片段中,变量result结果为( )。 public class Test { public static void main (String args[ ]) { int sum=0; int r=2; iht result=(sum==1?sum:r); System. out. println (result); } }
A.1
B.2
C.10
D.0
第16题:
( 17 )下列程序的输出结果是
public class Test{
public static void main(String[] args){
int [] array={2,4,6,8,10};
int size=6;
int result=-1;
try{
for{int i=0;i<size && result==-1;i++}
if(array[i]==20) result=i;
}
catch(ArithmeticException e){
System.out.println( " Catch---1 " );
catch(ArrayIndexOutOfBoundsException e){
System.out.println( " Catch---2 " );
catch(Exception e){
System.out.println( " Catch---3 " );
}
}
A ) Catch---1
B ) Catch---2
C ) Catch---3
D )以上都不对
答案暂缺
第17题:
class TestApp{ public static void main(String[] args){ System.out.println(multiply(2,3,4,5)); } public int multiply(int… nums){ int result = 1; for(int x :nums) result *= x; //result =result*x; return result; } } 2、6、24、120 程序运行后的输出是哪项?()
第18题:
public class SwitchTest { public static void main(String[] args) { System.out.println(“value = “ + switchIt(4)); } public static int switchIt(int x) { int j = 1; switch (x) { case 1: j++; case 2: j++; case 3: j++; case 4: j++; case 5: j++; default: j++; } return j + x; } } What is the result?()
第19题:
public class Yikes { public static void go(Long n) {System.out.println(”Long “);} public static void go(Short n) {System.out.println(”Short “);} public static void go(int n) {System.out.println(”int “);} public static void main(String [] args) { short y= 6; long z= 7; go(y); go(z); } } What is the result?()
第20题:
public class Test { public static void main(String[] args) { int x = 0; assert (x > 0): “assertion failed”; System.out.println(“finished”); } } What is the result?()
第21题:
0
null
Compilation fails.
A NullPointerException is thrown at runtime.
An ArrayIndexOutOfBoundsException is thrown at runtime.
第22题:
0
1
2
Compilation fails.
第23题:
s 14
s 16
s 10
Compilation fails.
An exception is thrown at runtime.
第24题:
finished
Compilation fails.
An AssertionError is thrown.
An AssertionError is thrown and finished is output.