网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

下面的方法,当参数值为2的时候返回值是多少 public int getValue(int i) { int result = 0; switch (i) { case 1: result = result + i; case 2: result = result + i * 2; case 3: result = result + i * 3; } return result; }

A.10

B.8

C.6

D.4

E.2

F.0


参考答案和解析
错误
更多 “下面的方法,当参数值为2的时候返回值是多少 public int getValue(int i) { int result = 0; switch (i) { case 1: result = result + i; case 2: result = result + i * 2; case 3: result = result + i * 3; } return result; }A.10B.8C.6D.4E.2F.0” 相关考题
考题 关于JAVA初级的代码计算问题 下面的方法,当输入为2的时候返回值是多少?()publicintgetValue(inti){intresult=0;switch(i){case1:result=result+i;case2:result=result+i*2;case3:result=result+i*3;}returnresult;}

考题 下面程序的运行结果是#includeint fun(int a[]. int n){int result=l:for(int i=1;iresult=result*a[i];return result;}void main(){int a[3]={3,4,5};cout}A.12;B.15;C.20;D.60

考题 下面程序的运行结果是 include int fun(int a[ ] ,int n) { int result=1; for(in 下面程序的运行结果是#include<iostream.h>int fun(int a[ ] ,int n){int result=1;for(int i=1;i<n;i++)result=result * a[i] ;retum result;}void main( ){int a[3] ={3,4,5};coutA.12B.15C.20D.60

考题 下面程序段的输出结果是( )。 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

考题 下面程序的运行结果是( )。 #includeiostream.h int fun(int a[],int n) { int resuh=1; for(inl i=1;i11;1‘++) result=result * a[i]; retum result; } void main int a[3]={3,4,5}: coutfun(a,3)endl: }A.12B.15C.20D.60

考题 下面程序的运行结果是()。includeintfun(inta[],int n){int result=1;for(int i=“i 下面程序的运行结果是( )。 #include<iostream.h> intfun(inta[],int n) { int result=1; for(int i=“i<n;i++) result’resultxa[i]; return result; } void main() { inta[3]={3,4,5}; cout<<fun(a,3)<<endl; }A.12B.15C.20D.60

考题 假定a=3,下列程序的运行结果是()。ineludeint fun(int n);void main(){cout 假定a=3,下列程序的运行结果是( )。 #inelude<iostream.h> int fun(int n); void main() { cout<<"Please input a number:"; int a,result=0; cin>>a; result=fun(a); tout<<result<<end1; } intfun(int n) { int p=1,result=0; for(int i=1;i<=n;i++) { p*=i; result+=p; } return result; )A.4B.8C.9D.20

考题 下面程序的输出结果是 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<sizeresult==-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.以下都不对

考题 阅读以下说明及C++程序代码,将应填入(n)处的语句写在对应栏内。【说明】本程序的功能是实现任意两个大整数的乘法运算,例如:输入整数1:8934793850094505800243958034985058输入整数2:234584950989689084095803583095820923二者之积:209596817742739508050978890737675662366433464256830959194834854876 8534【C++代码】include<iostream.h>const int MAXINPUTBIT=100;const int MAXRESULTBIT=500;class LargeNumber{int i,j;int temp;int one[MAXINPUTBIT+1];int onebit; //one的位数int two[MAXINPUTBIT+1];int twobit; //two的位数int result[MAXRESULTBIT+1];public:LargeNumber();~LargeNumber();int inputone(); //出错返叫0,否则返回1int inputtwo(); //同上void multiplication(); //乘void clearresult(); //清零void showresult(); //显示};LargeNumber∷LargeNumber(){for(i=0;i<=MAXINPUTBIT;i++){one[i]=0;two[i]=0;}nebit=0;twobit=0;inputone();inputtwo();}LargeNumber∷~LargeNumber(){}int LargeNumber∷inputone(){char Number[MAXINPUTBIT+1];cout<<"Please enter one:";cin>>Number;i=0;j=MAXINPUTBIT;while(Number[i]!='\0')i++;nebit=i;for(i--;i>=0;i--,j--){if(int(Number[i])>=48int(Number[i])<=57)(1); //由字符转换为数字elsereturn 0;}return 1;}int LargeNumber∷inputtwo(){char Number[MAXINPUTBIT+1];cout<<"Please enter two:";cin>>Number;i=0;j=MAXINPUTBIT;while(Number[i]!='\0')i++;twobit=i;for(i--;i>=0;i--,j--){if(int(Number[i])>=48int(Number[i])<=57)two[j]=int(Number[i]-48); //由字符转换为数字elsereturn 0;}return 1;}void LargeNumber∷multiplication() //乘法{clearresult();int m;for(i=MAXINPUTBIT;i>=0;i--){temp=two[i];for(j=(2),m=MAXINPUTBIT;m>=0;m--,j--){result[j]+=temp*one[m];if(result[j]>9){result[j-1]+=result[j]/10;(3);}}&n

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

考题 下面程序的运行结果是includeint fun(inta[],int n){ int result=1; for(int i=1:i 下面程序的运行结果是 #include<iostream.h> int fun(inta[],int n) { int result=1; for(int i=1:i<n;i++) result=result*a[i]; remm result; } void main() { int a[3]={3,4,5}; cout <<fun(a,3) <<end1; }A.12B.15C.20D.60

考题 下面的语句片段中,变量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 Test{ Public static void main(String[]args){ int[]array=(2,4,6,8,10); int size=6; int result=-l: try{ for(int i=0;isizeresult= =-1:) if(array[i]= =20)result=i: } catch(ArithmeticException e){ System.out.println("Catch---1"); } catch(ArraylndexOutOfBoundsException e){ System.out.println("Catch---2"): } catch(Exception e){ System.out.println("Catch---3"): } }A.Catch---1B.Catch---2C.Catch---3D.以上都不对

考题 下列程序的输出结果是( )。 public class Test{ public static void main(String[]args){ int[]array=(2,4,6,8,lO); int size=6; int result =-1: try{ for(int i=0;i(size 8Lresult= = -1;) if(array[i]= =20)result=i: } catch(ArithmeticException e){ System.out.println("Catch- - -l"); } catch(ArraylndexOutOfBoundsException e){ System.out.println("Catch- - -2"); } catch(Exception e){ System.out.println("Catch- - -3");) } }A.Catch- - -1B.Catch- - -2C.Catch- - -3D.以上都不对

考题 下面程序的运行结果是include int fun ( int a[ ],int n){int result=1;for(int 下面程序的运行结果是 #include < iostream.h > int fun ( int a[ ],int n) { int result=1; for(int i=1;i<n;i++) result=result*a[i]; return result; } void main( ) { int a[3]={3,4,5}; cout << fun(a,A.12B.15C.20D.60

考题 假定a=3,下列程序的运行结果是()。includeint fun(int n);void main(){cout 假定a=3,下列程序的运行结果是( )。 #include<iostream.h> int fun(int n); void main() { cout<<"Please input a number:"; int a,result=0; cin>>a; result=fun(a); cout<<result<<end1; } int fun(int n) { int p=1,result=0; for(int i=1;i<=n;i++) { p*=i; result +=p; } return result; }A.4B.8C.9D.20

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

考题 public class Test {  public static void main(String Args[]) {  int i =1, j = 0;  switch(i) {  case 2: j +=6;  case 4: j +=1;  default: j +=2;  case 0: j +=4;  }  System.out.println(“j =” +j);  }  }  What is the result? () A、 0B、 2C、 4D、 6E、 9F、 13

考题 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.

考题 int i = 1,j = -1;  switch (i) {  case 0, 1:j = 1;  case 2: j = 2;  default; j = 0;  }  System.out.println(“j=”+j);  What is the result?()  A、 j = -1B、 j = 0C、 j = 1D、 j = 2E、 Compilation fails.

考题 单选题int i = 1,j = -1;  switch (i) {  case 0, 1:j = 1;  case 2: j = 2;  default; j = 0;  }  System.out.println(“j=”+j);  What is the result?()A  j = -1B  j = 0C  j = 1D  j = 2E  Compilation fails.

考题 单选题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;  //result =result*x;   return result;  }  }   2、6、24、120   程序运行后的输出是哪项?()A  14B  编译错误C  120D  24

考题 单选题class Computation extends Thread {  private int num;  private boolean isComplete;  private int result;  public Computation(int num) { this.num = num; }  public synchronized void run() {  result = num * 2;  isComplete = true;  notify();  }  public synchronized int getResult() {  while (!isComplete) {  try {  wait();  } catch (InterruptedException e) { }  }  return result;  }  public static void main(String[] args) {  Computation[] computations = new Computation [4];  for (int i = 0; i  computations.length; i++) {  computations[i] = new Computation(i);  computations[i] .start();  }  for (Computation c : computations)  System.out.print(c.getResult() +“ “);  }  }  What is the result?()A  The code will deadlock.B  The code may run with no output.C  An exception is thrown at runtime.D  The code may run with output “0 6”.E  The code may run with output “2 0 6 4‟.F  The code may ruin with output “0 2 4 6”.

考题 单选题public class Test {  public static void main(String Args[]) {  int i =1, j = 0;  switch(i) {  case 2: j +=6;  case 4: j +=1;  default: j +=2;  case 0: j +=4;  }  System.out.println(“j =” +j);  }  }  What is the result? ()A  0B  2C  4D  6E  9F  13