网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
1. public class SwitchTest { 2. public static void main (String []args) { 3. System.out.PrintIn(“value =” +switchIt(4)); 4. } 5. public static int switchIt(int x) { 6. int j = 1; 7. switch (x) { 8. case 1: j++; 9. case 2: j++; 10. case 3: j++; 11. case 4: j++; 12. case 5: j++; 13. default:j++; 14. } 15. return j + x; 16. } 17. } What is the output from line 3?()
- A、 Value = 3
- B、 Value = 4
- C、 Value = 5
- D、 Value = 6
- E、 Value = 7
- F、 Value = 8
参考答案
更多 “ 1. public class SwitchTest { 2. public static void main (String []args) { 3. System.out.PrintIn(“value =” +switchIt(4)); 4. } 5. public static int switchIt(int x) { 6. int j = 1; 7. switch (x) { 8. case 1: j++; 9. case 2: j++; 10. case 3: j++; 11. case 4: j++; 12. case 5: j++; 13. default:j++; 14. } 15. return j + x; 16. } 17. } What is the output from line 3?() A、 Value = 3B、 Value = 4C、 Value = 5D、 Value = 6E、 Value = 7F、 Value = 8” 相关考题
考题
下面程序的输出结果是( )。 public class Sun { public static void main(String args[ ]) { int x=0; for(int i=1;i<=4;i++) { x=4; for(int j=1;j<=3;j++) { x=3; for(int k=1;k<=2;k++) { x-x+6; } } } System.out.println(x); } }A.7B.15C.157D.538
考题
下面程序的输出结果是什么? 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
考题
以下代码的输出结果是什么? class Foo{ public static void main(String args[]){ int x=4,j=0; switch(x){ case 1:j++; case 2:j++; case 3:j++; case 4:j++; case 5:j++; break; default:j++; } System.out.println(j); } }()A.1B.2C.3D.编译错误
考题
1.publicclassSwitchTest{2.publicstaticvoidmain(String[]args){3.System.out.PrintIn(value=”+switchIt(4));4.}5.publicstaticintswitchIt(intx){6.intj=1;7.switch(x){8.case1:j++;9.case2:j++;10.case3:j++;11.case4:j++;12.case5:j++;13.default:j++;14.}15.returnj+x;16.}17.}Whatistheoutputfromline3?()A.Value=3B.Value=4C.Value=5D.Value=6E.Value=7F.Value=8
考题
publicclassSwitchTest{publicstaticvoidmain(String[]args){System.out.println(value=+switchIt(4));}publicstaticintswitchIt(intx){intj=1;switch(x){case1:j++;case2:j++;case3:j++;case4:j++;case5:j++;default:j++;}returnj+x;}}Whatistheresult?()A.value=3B.value=4C.value=5D.value=6E.value=7F.value=8
考题
publicclassSwitchTest{publicstaticvoidmain(Stringargs){System.out.PrintIn(value=”+switchIt(4));}publicstaticintswitchIt(intx){intj=1;switch(x){case1:j++;case2:j++;case3:j++;case4:j++;case5:j++;default:j++;}returnj+x;}}Whatistheoutputfromline3?()A.Value=3B.Value=4C.Value=5D.Value=6E.Value=7F.Value=8
考题
下面程序段的输出结果是( )。 public class Test t public static void main(String[] args) { int x=0; for (int i=1;i<=4;i++) { x=4; for(int j=1;j<=3; j++) { x=3; for(int k=1; k<=2; k++) x=x+6; } } System. out. println (x); } }A.36B.48C.144D.15
考题
下面程序段的输出结果是( )。 public class Test { public static void main (String[] args) { int j=2,i=5; while (j<i--) j++; System.out.println(j);} }A.2B.3C.4D.5
考题
下列程序的输出的结果是______。 public class exl6 { public static void main(String[] args) { int j=10; for(int i=0;i<3;i++) { j-=i+1; switch (j){ case 3: break; case 5: break; case 8: break; default: j=0;break; } } System,out.println(j); } }A.5B.3C.8D.0
考题
下列程序执行之后,将输出 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 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);
考题
下列程序输出结果为( )。public class test { public static void main(String args[]) { int a=0; outer: for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { if(j>i) { continue outer; } a++; } } System.out.println(a); }}A.0B.2C.3D.4
考题
以下程序的运行结果为:1. public class Conditional {2. public static void main(String args [] ) {3. int x = 4;4. System.out.println( "value is " +((x >4、? 99.99 : 9));5. }6. }
A. 输出:value is 99.99B. 输出: value is 9C. 输出: value is 9.0D. 在第4行出现编译错误
考题
1. class A { 2. public int getNumber(int a) { 3. return a + 1; 4. } 5. } 6. 7. class B extends A { 8. public int getNumber (int a) { 9. return a + 2 10. } 11. 12. public static void main (String args[]) { 13. A a = new B(); 14. System.out.printIn(a.getNumber(0)); 15. } 16. } What is the result?() A、 Compilation succeeds and 1 is printed.B、 Compilation succeeds and 2 is printed.C、 An error at line 8 causes compilation to fail.D、 An error at line 13 causes compilation to fail.E、 An error at line 14 causes compilation to fail.
考题
1. public class SimpleCalc { 2. public int value; 3. public void calculate() { value += 7; } 4. } And: 1. public class MultiCalc extends SimpleCalc { 2. public void calculate() { value -= 3; } 3. public void calculate(int multiplier) { 4. calculate(); 5. super.calculate(); 6. value *=multiplier; 7. } 8. public static void main(String[] args) { 9. MultiCalc calculator = new MultiCalc(); 10. calculator.calculate(2); 11. System.out.println(”Value is: “+ calculator.value); 12. } 13. } What is the result?() A、 Value is: 8B、 Compilation fails.C、 Value is: 12D、 Value is: -12E、 The code runs with no output.F、 An exception is thrown at runtime.
考题
1. public class Target { 2. private int i = 0; 3. public int addOne() { 4. return ++i; 5. } 6. } And: 1. public class Client { 2. public static void main(String[] args) { 3. System.out.println(new Target().addOne()); 4. } 5. } Which change can you make to Target without affecting Client?() A、 Line 4 of class Target can be changed to return i++;B、 Line 2 of class Target can be changed to private int i = 1;C、 Line 3 of class Target can be changed to private int addOne() {D、 Line 2 of class Target can be changed to private Integer i = 0;
考题
1. public class X { 2. public static void main (String[]args) { 3. int [] a = new int [1] 4. modify(a); 5. System.out.printIn(a[0]); 6. } 7. 8. public static void modify (int[] a) { 9. a[0] ++; 10. } 11. } What is the result?()A、 The program runs and prints “0”B、 The program runs and prints “1”C、 The program runs but aborts with an exception.D、 An error “possible undefined variable” at line 4 causes compilation to fail.E、 An error “possible undefined variable” at line 9 causes compilation to fail.
考题
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 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
考题
1. public class Test { 2. public static String output =””; 3. 4. public static void foo(int i) { 5. try { 6. if(i==1) { 7. throw new Exception(); 8. } 9. output += “1”; 10. } 11. catch(Exception e) { 12. output += “2”; 13. return; 14. } 15. finally { 16. output += “3”;17. } 18. output += “4”; 19. } 20. 21. public static void main(String args[]) { 22. foo(0); 23. foo(1); 24. 25. }26. } What is the value of the variable output at line 23?()
考题
1. public class Boxer1 { 2. Integer i; 3. int x; 4. public Boxer1(int y) { 5. x=i+y; 6. System.out.println(x); 7. } 8. public static void main(String[] args) { 9. new Boxer1(new Integer(4)); 10. } 11. } What is the result?() A、 The value “4” is printed at the command line.B、 Compilation fails because of an error in line 5.C、 Compilation fails because of an error in line 9.D、 A NullPointerException occurs at runtime.E、 A NumberFormatException occurs at runtime.F、 An IllegalStateException occurs at runtime.
考题
public class SwitchTest { public static void main (String args) { System.out.PrintIn(“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 output from line 3? ()A、 Value = 3B、 Value = 4C、 Value = 5D、 Value = 6E、 Value = 7F、 Value = 8
考题
1. public class test ( 2. public static void main(string args[]) { 3. int 1= 0; 4. while (i) { 5. if (i==4) { 6. break; 7. } 8. ++i; 9. } 10. 11. } 12. ) What is the value of i at line 10?()A、 0B、 3C、 4D、 5E、 The code will not compile.
考题
单选题1. public class X { 2. public static void main (String[]args) { 3. int [] a = new int [1] 4. modify(a); 5. System.out.printIn(a[0]); 6. } 7. 8. public static void modify (int[] a) { 9. a[0] ++; 10. } 11. } What is the result?()A
The program runs and prints “0”B
The program runs and prints “1”C
The program runs but aborts with an exception.D
An error “possible undefined variable” at line 4 causes compilation to fail.E
An error “possible undefined variable” at line 9 causes compilation to fail.
考题
单选题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 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
考题
单选题1. public class test ( 2. public static void main(string args[]) { 3. int 1= 0; 4. while (i) { 5. if (i==4) { 6. break; 7. } 8. ++i; 9. } 10. 11. } 12. ) What is the value of i at line 10?()A
0B
3C
4D
5E
The code will not compile.
热门标签
最新试卷