网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
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、120
- B、24
- C、14
- D、编译错误
参考答案
更多 “ 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、编译错误” 相关考题
考题
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
考题
下列程序的功能是为变量赋值,程序运行后,输出i=51。请改动main方法中的错误,使程序能够正确编译、运行并输出正确的结果。注意:不改动程序结构。class A{private int a;public void setA (int x){a=x;}public int getA(){return a;}}public class MethodTest{public static void main(String args[]){A a=A();a.getA(51);int i=a.getA();System.out.println ("i="+i);}}
考题
下面程序的输出结果是什么? 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
考题
interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}
考题
下列语句中变量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
考题
以下程序调试结果为:public class Test {int m=5;public void some(int x) {m=x;}public static void main(String args []) {new Demo().some(7);}}class Demo extends Test {int m=8;public void some(int x) {super.some(x);System.out.println(m);}}A.5B.8C.7D.无任何输出E.编译错误
考题
程序: 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
考题
程序: class TestReference{ public static void main(String[] args){ int x=2; TestReference tr = new TestReference(); System.out.print(x); tr.change(x); System.out.print(x); } public void change(int num){ num = num + 1; } } 程序运行后的输出是哪项?() A、 23B、 21C、 22D、 编译错误
考题
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 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.
考题
单选题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; } } 程序运行后的输出是哪项?()A
120B
24C
14D
编译错误
考题
单选题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
考题
单选题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
考题
单选题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.
热门标签
最新试卷