单选题程序:  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;   } }  程序运行后的输出是哪项?()A14

题目
单选题
程序:  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

 14

B

 编译错误

C

 120

D

 24


相似考题
参考答案和解析
正确答案: 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  ”相关问题
  • 第1题:

    有如下程序: 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.0

    B.The result is:8.0 The resuR is:16

    C.The result is:8 The result is:16.0

    D.The resuR is:16.0 The result is:8


    正确答案:A
    解析:本题考查对方法重载的掌握程度。在上面的程序中,类MethLoad中定义了两个具有相同名称methtest的方法,但这两个方法的参数不相同,编译器会根据参数的个数和参数类型宋决定应该调用哪个方法。在类MethLoad中先声明了一个classObj对象,接着调用classObj的methest方法,只不过是两次调用中参数的类型不同,第1次调用的参数是血类型的4,第2次调用的参数是double类型的4.0,因此要调用相对应的方法。int类型的方法返回参数值的4倍,而double类型的方法返回参数值的2倍。

  • 第2题:

    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


    参考答案:C

  • 第3题:

    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();

    }

    }


    正确答案:

     

    错误。在编译时会发生错误(错误描述不同的JVM 有不同的信息,意思就是未明确的

    x 调用,两个x 都匹配(就象在同时import java.util 和java.sql 两个包时直接声明Date 一样)。

    对于父类的变量,可以用super.x 来明确,而接口的属性默认隐含为 public static final.所以可

    以通过A.x 来明确。

  • 第4题:

    下列语句中变量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


    正确答案:C

  • 第5题:

    有如下程序: 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


    正确答案:A
    解析:本题考查对方法重载的掌握程度。在上面的程序中,类MethLoad中定义了两个具有相同名称methtest的方法,但这两个方法的参数不相同,编译器会根据参数的个数和参数类型来决定应该调用哪个方法。在类MethLoad中先声明了一个classObi对象,接着调用classObj的methest方法,只不过是两次调用中参数的类型不同,第1次调用的参数是int类型的4,第2次调用的参数是 double类型的0,因此要调用相对应的方法。int类型的方法返回参数值的4倍,而 double类型的方法返回参数值的2倍。

  • 第6题:

    程序:  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、 14
    • B、 编译错误
    • C、 120
    • D、 24

    正确答案:C

  • 第7题:

    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 14
    • B、 s 16
    • C、 s 10
    • D、 Compilation fails.
    • E、 An exception is thrown at runtime.

    正确答案:D

  • 第8题:

    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 Long
    • B、 Short Long
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:A

  • 第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;  }  }   程序运行后的输出是哪项?()  

    • A、120
    • B、24
    • C、14
    • D、编译错误

    正确答案:D

  • 第10题:

    单选题
    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

    编译错误


    正确答案: C
    解析: 暂无解析

  • 第11题:

    单选题
    程序:  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

     14

    B

     编译错误

    C

     120

    D

     24


    正确答案: C
    解析: 暂无解析

  • 第12题:

    单选题
    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 14

    B

     s 16

    C

     s 10

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


    正确答案: E
    解析: 暂无解析

  • 第13题:

    classTestApp{publicstaticvoidmain(String[]args){System.out.println(multiply(2,3,4,5));}publicintmultiply(int...nums){intresult=1;for(intx:nums)result*=x;returnresult;}}程序运行后的输出是哪项?()

    A.120

    B.24

    C.14

    D.编译错误


    参考答案:D

  • 第14题:

    程序:classTestApp{publicstaticvoidmain(String[]args){System.out.println(multiply(2,3,4,5));}publicintmultiply(int[]nums){intresult=1;for(intx:nums)result*=x;returnresult;}}程序运行后的输出是哪项?()

    A.14

    B.编译错误

    C.120

    D.24


    参考答案:C

  • 第15题:

    以下程序运行后输出的结果是______。

    public class exl7

    {

    public static void main(String args [])

    {

    int a = 0;

    for(int j = 1; j <= 20; j++)

    if(j%5 != 0)

    a = a + j;

    System.out.println (a);


    正确答案:160
    160

  • 第16题:

    下面的语句片段中,变量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


    正确答案:B
    解析:条件运算符?:为三元运算符,它的一般形式为:expression ? statement1:statement2。其中表达式expression的值应为一个布尔值,若该值为true,则执行语句statement1,否则执行语句statement2,而且语句statement1和statement2需要返回相同的数据类型,且该类型不能是 void。在本题中sum等于0,而不等于1,所以返回r的值为2。

  • 第17题:

    ( 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 )以上都不对


    正确答案:U

    答案暂缺

  • 第18题:

    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

    正确答案:C

  • 第19题:

    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、 0
    • B、 1
    • C、 2
    • D、 Compilation fails.

    正确答案:D

  • 第20题:

    public class Test {  private static int[] x;  public static void main(String[] args) {  System.out.println(x[0]);  }  }   What is the result?()   

    • A、 0
    • B、 null
    • C、 Compilation fails.
    • D、 A NullPointerException is thrown at runtime.
    • E、 An ArrayIndexOutOfBoundsException is thrown at runtime.

    正确答案:D

  • 第21题:

    单选题
    public class Test {  private static int[] x;  public static void main(String[] args) {  System.out.println(x[0]);  }  }   What is the result?()
    A

     0

    B

     null

    C

     Compilation fails.

    D

     A NullPointerException is thrown at runtime.

    E

     An ArrayIndexOutOfBoundsException is thrown at runtime.


    正确答案: B
    解析: 暂无解析

  • 第22题:

    单选题
    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

     0

    B

     1

    C

     2

    D

     Compilation fails.


    正确答案: D
    解析: 暂无解析

  • 第23题:

    单选题
    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 Long

    B

     Short Long

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: D
    解析: 暂无解析

  • 第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


    正确答案: C
    解析: 暂无解析