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

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

执行下列Java语句:int x = 1; switch (x+1 ) { case 1: System.out.print("One" ); case 2: System.out.print("Two" ); case 3: System.out.print("Three" ); default: System.out.print("Error" ); } 显示器上将显示()。

A.One

B.Two

C.TwoThree

D.TwoThreeError


参考答案和解析
case 后面的常量可以相同。
更多 “执行下列Java语句:int x = 1; switch (x+1 ) { case 1: System.out.print("One" ); case 2: System.out.print("Two" ); case 3: System.out.print("Three" ); default: System.out.print("Error" ); } 显示器上将显示()。A.OneB.TwoC.TwoThreeD.TwoThreeError” 相关考题
考题 若有定义 : float x=1.5; int a=1,b=3,c=2; 则正确的 switch 语句是A)switch(x){ case 1.0: printf("*\n");case 2.0: printf("**\n");}B)switch((int)x);{ case 1: printf("*\n");case 2: printf("**\n");}C)switch(a+b){ case 1: printf("*\n");case 2+1: printf("**\n");}D)switch(a+b){ case 1: printf("*\n");case c: printf("**\n");}

考题 若有定义:float x=1.5;int a=1,b=3,c=2;,则正确的switch语句是A.switch(x) {case 1.0:printf("*\n"); case 2.0:printf("**\n");}B.switch((int)x); {case 1:printf("*\n"); case 2:printf("**\n");}C.switch(a+B) {case 1:printf("*\n"); case 2+1:printf("**\n");}D.switch(a+B) {case 1:printf("*\n"); case c:printf("**\n");}

考题 阅读下列代码 public class Test 2005{ public static void main(String args[]){ Strings="Test"; switch(s){ case "Java":System.out.print("Java"); break; case "Language":System.out.print("Language"); break; case "Test":System.out.ptint("Test"); break; } } } 其运行结果是A.JavaB.LanguageC.TestD.编译出错

考题 ( 19 )阅读下列代码public class Test2005{public static void main(String args[]){String s= ″ Test ″ ;Switch(s){case ″ Java ″ : System.out.print( ″ Java ″ ) ;break ;case ″ Language ″ : System.out.print( ″ Language ″ ) ;break ;case ″ Test ″ : System.out.print( ″ Test ″ ) ;break ;}}}其运行结果是A ) JavaB ) LanguageC ) TestD )编译出错

考题 以下程序段的输出结果为 ( )int j=2;switch(j){case 2:System.out.print("two.");case 2+1:System.out.println("three.");breakdefault:System.out.println("value is"+j);break;}A.two.three.B.two.C.three.D.value is 2

考题 下列Aplication程序实现:从1到100的整数分别对35求余数,并根据不同余数(0,1,2,3时分别输出“余0”,“余1,”“余2”,“余3”,其他输出“其他”)输出相应信息。请将程序补充完整。public class test18_2{Public static Void main(String[]args) {for(int i=1;i=100;i++){______(i______35) {Case 0:System.out.print(“余0”);break;Case 1:System.out.print(“余1”);break;Case 2:System.out.print(“余2”);break;——:System.out.print(“其他”);break;}}System.out.println();}}

考题 编译和执行以下代码,输出结果是( )。 int i=1; switch (i) { case 0: System.out.print("zero,"); break; case 1: System.out.print("one,"); case 2: System.out.print("two,"); default: System.out.println("default"); }A.one,B.one,two,C.one,two,defaultD.default

考题 阅读下面代码 public class Test2005 { public static void main(String args[]) { String s="Test"; switch(s) { case"Java":System.out.print("Java"); break; case"Language":System.out.print("Language"): break; case"Test":System.out.print("Test"); break; } } } 其运行结果是A.JavaB.LanguageC.TestD.编译出错

考题 执行语句序列 int n: cin>>n: switch (n) { case 1: case 2:cout<<'1'; case 3: case 4: cout<<'2': break; default: cout<<'3': }时,若键盘输入1,则屏幕显示A.1B.2C.3D.12

考题 给出下列代码段: public class ex38 { public static void main (String args [ ] ) { int m; switch(m) { case 0: System.out.println ( "case 0" ); case 1:System.out.println("case 1");break; case 2: default: System.out.print in ("default") } } 下列m的______值将引起"default"的输出。A.0B.1C.2D.以上答案都不正确

考题 已知:int a,b;下列switch语句中,( )是正确的。A.switdh (a) { case a: a + +;break; case b: b + +;break; }B.switch(a+b) { case 1:a+b;break; case 1:a-b }C.switch(a*a) { case 1,2:+ +a; case 3, 4:+ +b: }D.switch(a/10+b) { cases 5:a/5:break: default:a+b; }

考题 下列程序执行的结果是______。 public class ex6 { public static void main(String[] args) { char ch='8'; int r=10; switch(ch+l) { case '7': r=r+3; case '8': r=r+5; case '9': r=r+6; break; default: ; } System.out.print(r); } }A.14B.13C.16D.10

考题 阅读下列代码 public class Test { public static void main(String args[]) { String s = "Test"; switch (s) { case "Java": System.out.print("Java"); break; case "Language": System.out.print("Language"); break; case "Test": System.out.print("Test"); break; } } } 其运行结果是( )。A.JavaB.LanguageC.TestD.编译出错

考题 下列程序执行之后,将输出 public class exl9 { public static void main(string[] args) { int x=3; int y=7; switch(y/x){ case 1: y*=2; break; case 2: y*=3; break; case 3: y*=4; break; default: y=0; } System.out.print(y); } }A.28B.21C.14D.0

考题 阅读下列代码 public class Test2005{ public static void main(String args[]){ String s="Test"; switch(s){ case"Java":System.out.print("Java"); break; case"Language":System.out.print("Lan- guage"); break; case"Test":System.out.print("Test"); break; } } } 其运行结果是( )。A.JavaB.LanguageC.TestD.编译时出错

考题 若有定义float x=1.5;int a=1,b=3,c=2;,则正确的switch语句是A.swimh(x) {case 1.0:printf("*\n"); case 2.0:printf("**\n");}B.switch((int)x); {case 1:printf("*\n"); case 2:printf("**\n");}C.switch(a+D. {case 1:pfintf("*\n"); case 2+1:pfintf("**\n");}switch(a-I-{case 1:pfintf("*\n"); case c:printf("**\n");}

考题 以下程序段的输出结果为( )。 int j=2 switch (j){ Case 2: system.out.print("two."): Case 2+1: System.out.println("three."); break: default: System.out.println (“value is”+j): Break }A.B.twoA.two.three.B.twoC.threeD.value is 2

考题 若有定义语句int a,b;double x;则下列选项中没有错误的是( )。A.switch(x%2) {case O:a++;break; case 1:b++;break; default:a++;b++; }B.switch((int)x/2.0) {case O:a++;break; case 1:b++;break; default:a++;b++; }C.switch((int)x%2) {case O:a++;break; case 1:b++;break; default:a++;b++; }D.switch((int)(x)%2) {case 0.O:a++;break; case 1.0:b++;break; default:a++;b++; }

考题 若有定义语句“int a,b;double X;”,则下列选项中没有错误的是( )。A.switch(X%2) { case 0:a++;break; case l:b++;break; default:a++;b++; }B.switch((int)x/2.O) { case 0:a++;break; case l:b++;break; default:a++;b++; }C.switch((int)X%2) { case 0:a++;break; case l:b++;break; default:a++;b++; }D.switch((int)(x)%2) { case 0.0:a++;break; case l.0:b++;break; default:a++;b++; }

考题 阅读下面代码段:public class Test{ public static void main(String args[]){ char ch; switch(ch) { case'a':System.out.print("abc");break; case'b':System.out.print("ab"); case'c':System.out.print("c");break; default:System.out.print("abc"); } }}不输出"abc"的ch值是 ( )A.'a'B.'b'C.'c'D.'d'

考题 下列输出结果是( )inta=0;while(a 下列输出结果是( )inta=0;while(aswitch( ){case0:case3:a=a+2;case1:case2:a=a+3;default:a=a+5;}}System.out.print( );A、0B、5C、10D、其他

考题 若有定义:float x=1.5;int a=1,b=3,c=2; 则正确的switch语句是( )。A.switch(x) { case 1.0: printf("*\n"); case 2.0: printf(" * * \n" );B.switch((iht)x); { case 1: printf(" * \n" ); case 2: printf(" * * \n" ); }C.switch(a +b) { case 1: printf(" * \n" ); case 2 + 1: printf(" * * \n" ); }D.switch(a + b) { case 1: pfintf(" * \n" ); case c: pfintf(" * * \n"); }

考题 class One {  public One() { System.out.print(1); }  }  class Two extends One {  public Two() { System.out.print(2); }  }  class Three extends Two {  public Three() { System.out.print(3); }  }  public class Numbers{  public static void main( String[] argv) { new Three(); }  }  What is the result when this code is executed?() A、 1B、 3C、 123D、 321E、 The code rims with no output.

考题 public class Test {  public enum Dogs {collie, harrier, shepherd};  public static void main(String [] args) {  Dogs myDog = Dogs.shepherd;  switch (myDog) {  case collie:  System.out.print(”collie “);  case default:  System.out.print(”retriever “); case harrier:  System.out.print(”harrier “);  }  }  }  What is the result?() A、 harrierB、 shepherdC、 retrieverD、 Compilation fails.E、 retriever harrierF、 An exception is thrown at runtime.

考题 public class Test {  public enum Dogs {collie, harrier};  public static void main(String [] args) {  Dogs myDog = Dogs.collie;  switch (myDog) {  case collie:  System.out.print(”collie “); case harrier:  System.out.print(”harrier “);  }  }  }  What is the result?() A、 collieB、 harrierC、 Compilation fails.D、 collie harrierE、 An exception is thrown at runtime.

考题 单选题public class Test {  public enum Dogs {collie, harrier};  public static void main(String [] args) {  Dogs myDog = Dogs.collie;  switch (myDog) {  case collie:  System.out.print(”collie “); case harrier:  System.out.print(”harrier “);  }  }  }  What is the result?()A  collieB  harrierC  Compilation fails.D  collie harrierE  An exception is thrown at runtime.

考题 单选题public class Test {  public enum Dogs {collie, harrier, shepherd};  public static void main(String [] args) {  Dogs myDog = Dogs.shepherd;  switch (myDog) {  case collie:  System.out.print(”collie “);  case default:  System.out.print(”retriever “); case harrier:  System.out.print(”harrier “);  }  }  }  What is the result?()A  harrierB  shepherdC  retrieverD  Compilation fails.E  retriever harrierF  An exception is thrown at runtime.

考题 单选题class One {  public One() { System.out.print(1); }  }  class Two extends One {  public Two() { System.out.print(2); }  }  class Three extends Two {  public Three() { System.out.print(3); }  }  public class Numbers{  public static void main( String[] argv) { new Three(); }  }  What is the result when this code is executed?()A  1B  3C  123D  321E  The code rims with no output.