单选题11. public static void main(String[] args) {  12. Integer i = uew Integer(1) + new Integer(2);  13. switch(i) {  14. case 3: System.out.println(”three”); break;  15. default: System.out.println(”other”); break;  16. }  17. }  What is the result?()Athre

题目
单选题
11. public static void main(String[] args) {  12. Integer i = uew Integer(1) + new Integer(2);  13. switch(i) {  14. case 3: System.out.println(”three”); break;  15. default: System.out.println(”other”); break;  16. }  17. }  What is the result?()
A

 three

B

 other

C

 An exception is thrown at runtime.

D

 Compilation fails because of an error on line 12.

E

 Compilation fails because of an error on line 13.

F

 Compilation fails because of an error on line 15.


相似考题
参考答案和解析
正确答案: C
解析: 暂无解析
更多“单选题11. public static void main(String[] args) {  12. Integer i = uew Integer(1) + new Integer(2);  13. switch(i) {  14. case 3: System.out.println(”three”); break;  15. default: System.out.println(”other”); break;  16. }  17. }  What is the result?()A  th”相关问题
  • 第1题:

    11.publicstaticvoidmain(String[]args){12.Integeri=uewInteger(1)+newInteger(2);13.switch(i){14.case3:System.out.println(”three”);break;15.default:System.out.println(”other”);break;16.}17.}Whatistheresult?()

    A.three

    B.other

    C.Anexceptionisthrownatruntime.

    D.Compilationfailsbecauseofanerroronline12.

    E.Compilationfailsbecauseofanerroronline13.

    F.Compilationfailsbecauseofanerroronline15.


    参考答案:A

  • 第2题:

    给出下面代码片段: public class Test{ 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.println("default"); } } } 下列m的( )值将引起"default"的输出。

    A.1

    B.2

    C.4

    D.0


    正确答案:B

  • 第3题:

    给出下面代码段: public class Test{ 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: break; default: System.out.println("default"); } } } 下列m的值能引起输出“default”的是( )。

    A.0

    B.1

    C.2

    D.4


    正确答案:D
    解析:本题考查条件语句switch的应用。此代码段最后输出default,则表示m的值不能为0、1和2三者其中之一,故m的值只能选择D。

  • 第4题:

    11. public static void main(String[] args) {  12. Integer i = uew Integer(1) + new Integer(2);  13. switch(i) {  14. case 3: System.out.println(”three”); break;  15. default: System.out.println(”other”); break;  16. }  17. }  What is the result?() 

    • A、 three
    • B、 other
    • C、 An exception is thrown at runtime.
    • D、 Compilation fails because of an error on line 12.
    • E、 Compilation fails because of an error on line 13.
    • F、 Compilation fails because of an error on line 15.

    正确答案:A

  • 第5题:

    11. static class A {  12. void process() throws Exception { throw new Exception(); }  13. }  14. static class B extends A {  15. void process() { System.out.println(”B”); }  16. }  17. public static void main(String[] args) {  18. new B().process();  19. }  What is the result?() 

    • A、 B
    • B、 The code runs with no output.
    • C、 Compilation fails because of an error in line 12.
    • D、 Compilation fails because of an error in line 15.
    • E、 Compilation fails because of an error in line 18.

    正确答案:A

  • 第6题:

    public static void main(String[]args){ Integer i=new Integer(1)+new Integer(2); switch(i){ case3:System.out.println("three");break; default:System.out.println("other");break; } } Whatistheresult?()

    • A、three
    • B、other
    • C、Anexceptionisthrownatruntime.
    • D、Compilationfailsbecauseofanerroronline12.
    • E、Compilationfailsbecauseofanerroronline13.
    • F、Compilationfailsbecauseofanerroronline15.

    正确答案:A

  • 第7题:

    10. public class MyClass {  11.  12. public Integer startingI;  13. public void methodA() {  14. Integer i = new Integer(25);  15. startingI = i;  16. methodB(i);  17. }  18. private void methodB(Integer i2) {  19. i2 = i2.intValue();  20.  21. }  22. }  If methodA is invoked, which two are true at line 20?()

    • A、 i2 == startingI returns true.
    • B、 i2 == startingI returns false.
    • C、 i2.equals(startingI) returns true.
    • D、 i2.equals(startingI) returns false.

    正确答案:B,C

  • 第8题:

    Given:   11. static class A {   12. void process() throws Exception { throw new Exception(); }   13. }   14. static class B extends A {   15. void process() { System.out.println("B "); }   16. }   17. public static void main(String[] args) {   18. A a = new B();   19. a.process();   20. }   What is the result? ()

    • A、 Compilation fails because of an error in line 19.
    • B、 An exception is thrown at runtime.
    • C、 B
    • D、 Compilation fails because of an error in line 18.
    • E、 Compilation fails because of an error in line 15. 
    • F、 The code runs with no output.

    正确答案:A

  • 第9题:

    单选题
    public static void main(String[]args){ Integer i=new Integer(1)+new Integer(2); switch(i){ case3:System.out.println("three");break; default:System.out.println("other");break; } } Whatistheresult?()
    A

    three

    B

    other

    C

    Anexceptionisthrownatruntime.

    D

    Compilationfailsbecauseofanerroronline12.

    E

    Compilationfailsbecauseofanerroronline13.

    F

    Compilationfailsbecauseofanerroronline15.


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

  • 第10题:

    单选题
    11. public static void main(String[] args) {  12. Integer i = uew Integer(1) + new Integer(2);  13. switch(i) {  14. case 3: System.out.println(”three”); break;  15. default: System.out.println(”other”); break;  16. }  17. }  What is the result?()
    A

     three

    B

     other

    C

     An exception is thrown at runtime.

    D

     Compilation fails because of an error on line 12.

    E

     Compilation fails because of an error on line 13.

    F

     Compilation fails because of an error on line 15.


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

  • 第11题:

    单选题
    11. class Converter {  12. public static void main(String[] args) {  13. Integer i = args[0];  14. int j = 12;  15. System.out.println(”It is “ + (j==i) + “that j==i.”);  16. }  17. }  What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?()
    A

     It is true that j==i.

    B

     It is false that j==i.

    C

     An exception is thrown at runtime.

    D

     Compilation fails because of an error in line 13.


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

  • 第12题:

    单选题
    public class test {  public static void add3 (Integer i)  int val = i.intValue ( );  val += 3;  i = new Integer (val);  } public static void main (String args [ ] )  {  Integer  i = new Integer (0);  add3 (i);  system.out.printIn (i.intValue ( )  );  } What is the result?()
    A

     Compilation will fail.

    B

     The program prints “0”.

    C

     The program prints “3”.

    D

     Compilation will succeed but an exception will be thrown at line 3.


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

  • 第13题:

    下面程序的输出结果是( )。 public class Sun { public static void main(String args[ ]) { int i = 1; switch (i) { case 0: System.but.println("zero"); break; case 1: System.out.println("one"); case 2: System.out.println("two"); default: System.out.println ("default"); } } }

    A.one

    B.one, default

    C.one, two, default

    D.default


    正确答案:C
    解析:该题考查对switch-case-break的理解。每个分支语句后面必须有break语句,否则程序向下执行,直到遇到break语句或程序结束。所以,该题i=1时执行casel分支语句,而casel分支语句后没有break语句,程序继续向下执行case2分支语句和 default分支语句。A只执行了case 1:B只执行了casel和default;C:只执行了default。故本题的正确答案是C。

  • 第14题:

    下面程序段的输出结果是( )。 public class Test{ public static void main(String args[]){ int i=1: switch(i){ case0: System.OUt.println("0"); break; casel: System.out.println("1"); case2: System.OUt.println("2"); break; default: System.out.println("default"); } } }

    A.01

    B.12

    C.10

    D.21


    正确答案:B
    B。【解析】本题考查switch-case-break的用法。每个分支语句后面必须有break语句,否则程序向下执行,直到遇到break语句或程序结束。所以该题i=1时执行easel分支语句,而casel分支语句后没有break语句,程序继续向下执行case2分支语句,case2语句后有break语句,故程序不执行default分支语句。

  • 第15题:

    public class Test {  public static void add3 (Integer i) {  int val = i.intValue();  val += 3;  i = new Integer(val); }  public static void main(String args[]) {  Integer i = new Integer(0);  add3(i);  System.out.println(i.intValue());  }  }   What is the result? () 

    • A、 0
    • B、 3
    • C、 Compilation fails.
    • D、 An exception is thrown at runtime.

    正确答案:A

  • 第16题:

    11. public static void main(String[] args) {  12. Object obj = new Object() {  13. public int hashCode() {  14. returns 42; 15. }  16. };  17. System.out.println(obj.hashCode());  18. }    What is the result? () 

    • A、 42
    • B、 An exception is thrown at runtime.
    • C、 Compilation fails because of an error on line 12.
    • D、 Compilation fails because of an error on line 16.
    • E、 Compilation fails because of an error on line 17.

    正确答案:A

  • 第17题:

    11. class Converter {  12. public static void main(String[] args) {  13. Integer i = args[0];  14. int j = 12;  15. System.out.println(”It is “ + (j==i) + “that j==i.”);  16. }  17. }  What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?() 

    • A、 It is true that j==i.
    • B、 It is false that j==i.
    • C、 An exception is thrown at runtime.
    • D、 Compilation fails because of an error in line 13.

    正确答案:D

  • 第18题:

    public class test {   public static void add3 (Integer i){  int val = i.intValue ( );   val += 3;   i = new Integer (val);    }     public static void main (String args [ ] )  { Integer i = new Integer (0);    add3 (i);   system.out.printIn (i.intValue ( ) );   }    }   What is the result?()

    • A、 Compilation will fail.
    • B、 The program prints “0”.
    • C、 The program prints “3”.
    • D、 Compilation will succeed but an exception will be thrown at line 3.

    正确答案:B

  • 第19题:

    11. public static void append(List list) { list.add(”0042”); }  12. public static void main(String[] args) {  13. List intList = new ArrayList();  14. append(intList);  15. System.out.println(intList.get(0));  16. }  What is the result?() 

    • A、 42
    • B、 0042
    • C、 An exception is thrown at runtime.
    • D、 Compilation fails because of an error in line 13.
    • E、 Compilation fails because of an error in line 14.

    正确答案:B

  • 第20题:

    单选题
    11. public static void append(List list) { list.add(”0042”); }  12. public static void main(String[] args) {  13. List intList = new ArrayList();  14. append(intList);  15. System.out.println(intList.get(0));  16. }  What is the result?()
    A

     42

    B

     0042

    C

     An exception is thrown at runtime.

    D

     Compilation fails because of an error in line 13.

    E

     Compilation fails because of an error in line 14.


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

  • 第21题:

    单选题
    11. public static void main(String[] args) {  12. Object obj = new Object() {  13. public int hashCode() {  14. returns 42; 15. }  16. };  17. System.out.println(obj.hashCode());  18. }    What is the result? ()
    A

     42

    B

     An exception is thrown at runtime.

    C

     Compilation fails because of an error on line 12.

    D

     Compilation fails because of an error on line 16.

    E

     Compilation fails because of an error on line 17.


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

  • 第22题:

    单选题
    11. static class A {  12. void process() throws Exception { throw new Exception(); }  13. }  14. static class B extends A {  15. void process() { System.out.println(”B”); }  16. }  17. public static void main(String[] args) {  18. new B().process();  19. }  What is the result?()
    A

     B

    B

     The code runs with no output.

    C

     Compilation fails because of an error in line 12.

    D

     Compilation fails because of an error in line 15.

    E

     Compilation fails because of an error in line 18.


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

  • 第23题:

    单选题
    public class Test {  public static void add3 (Integer i) {  int val = i.intValue();  val += 3;  i = new Integer(val); }  public static void main(String args[]) {  Integer i = new Integer(0);  add3(i);  System.out.println(i.intValue());  }  }   What is the result? ()
    A

     0

    B

     3

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


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

  • 第24题:

    多选题
    10. public class MyClass {  11.  12. public Integer startingI;  13. public void methodA() {  14. Integer i = new Integer(25);  15. startingI = i;  16. methodB(i);  17. }  18. private void methodB(Integer i2) {  19. i2 = i2.intValue();  20.  21. }  22. }  If methodA is invoked, which two are true at line 20?()
    A

    i2 == startingI returns true.

    B

    i2 == startingI returns false.

    C

    i2.equals(startingI) returns true.

    D

    i2.equals(startingI) returns false.


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