单选题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 程序运行后的输出是哪项?()A 14B 编译错误C 120D 24
单选题
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 程序运行后的输出是哪项?()
A
14
B
编译错误
C
120
D
24
参考解析
解析:
暂无解析
相关考题:
class A{public int getNumber(int a){return a+1;}}class B extends A{public int getNumber(int a, char c){return a+2;}public static void main(String[] args){B b=new B();System.out.println(b.getNumber(0));}}what is the result?()A.compilation succeeds and 1 is printedB.compilation succeeds and 2 is printedC.compilation succeeds and 3 is printedD.An error at this program cause compilation to fail
下面程序段的输出结果是( )。 public class Test { public static void main ( String[] args) { int result=0; for ( int i=1;i<=5;i++) { if ( i%2==0 ) continue; result + =i; } System. out. println ("result is " + result ); } }A.result is 7B.result is 8C.result is 9D.result is 10
下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new TeA.0B.1C.2D.3
有如下程序: public class MethLoad { public static void main(String args[]) { MethLoad classObj = new MethLoad(); classObj.methtest(4); classObj.methtest(4.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:8.0B.The result is:8.0 The resuR is:16C.The result is:8 The result is:16.0D.The resuR is:16.0 The result is:8
classTestApp{publicstaticvoidmain(String[]args){System.out.println(multiply(2,3,4,5));}publicintmultiply(int...nums){intresult=1;for(intx:nums)result*=x;returnresult;}}程序运行后的输出是哪项?() A.120B.24C.14D.编译错误
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.14B.编译错误C.120D.24
程序:classTestApp{publicstaticvoidmain(String[]args){System.out.println(multiply(2,3,4,5));}publicintmultiply(int[]nums){intresult=1;for(intx:nums)result*=x;returnresult;}}程序运行后的输出是哪项?() A.14B.编译错误C.120D.24
阅读下面程序public class OperatorsAndExpressions {String conditionalExpression(int score) {String result;//如果score超过60分,则结果是passed,否则是doesn't passresult=(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);}}程序的执行结果是______。
下列语句中变量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.3B.10C.2D.4
下面的语句片段中,变量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.1B.2C.10D.0
有如下程序: 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:0B.The result is:0 The result is:16C.The result is:8 The result is:0D.The result is:0 The result is:8
( 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;isize 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---1B ) Catch---2C ) Catch---3D )以上都不对
程序: 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; } } 程序运行后的输出是哪项?() A、 14B、 编译错误C、 120D、 24
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 程序运行后的输出是哪项?() A、 14B、 编译错误C、 120D、 24
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?() A、 s 14B、 s 16C、 s 10D、 Compilation fails.E、 An exception is thrown at runtime.
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?() A、 value = 3B、 value = 4C、 value = 5D、 value = 6E、 value = 7F、 value = 8
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?() A、 0B、 1C、 2D、 Compilation fails.
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?() A、 int LongB、 Short LongC、 Compilation fails.D、 An exception is thrown at runtime.
public class Test { private static int[] x; public static void main(String[] args) { System.out.println(x[0]); } } What is the result?() A、 0B、 nullC、 Compilation fails.D、 A NullPointerException is thrown at runtime.E、 An ArrayIndexOutOfBoundsException is thrown at runtime.
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?() A、 finishedB、 Compilation fails.C、 An AssertionError is thrown.D、 An AssertionError is thrown and finished is output.
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; } } 程序运行后的输出是哪项?() A、120B、24C、14D、编译错误
单选题public class Test { private static int[] x; public static void main(String[] args) { System.out.println(x[0]); } } What is the result?()A 0B nullC Compilation fails.D A NullPointerException is thrown at runtime.E An ArrayIndexOutOfBoundsException is thrown at runtime.
单选题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; } } 程序运行后的输出是哪项?()A120B24C14D编译错误
单选题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?()A 0B 1C 2D Compilation fails.
单选题程序: 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; } } 程序运行后的输出是哪项?()A 14B 编译错误C 120D 24
单选题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?()A s 14B s 16C s 10D Compilation fails.E An exception is thrown at runtime.
单选题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?()A finishedB Compilation fails.C An AssertionError is thrown.D An AssertionError is thrown and finished is output.