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、 42B、 An exception is thrown at runtime.

题目

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
更多“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、 42B、 An exception is thrown at runtime.C”相关问题
  • 第1题:

    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

  • 第2题:

    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

  • 第3题:

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


    正确答案:13423

  • 第4题:

    11.classA {  12. public void process() { System.out.print(”A “); } }  13. class B extends A {  14. public void process() throws RuntimeException {  15. super.process();  16. if (true) throw new RuntimeException();  17. System.out.print(“B”); }}  18. public static void main(String[] args) {  19. try { ((A)new B()).process(); }  20. catch (Exception e) { System.out.print(”Exception “); }  21. }  What is the result?() 

    • A、 Exception
    • B、 A Exception
    • C、 A Exception B
    • D、 A B Exception
    • E、 Compilation fails because of an error in line 14.
    • F、 Compilation fails because of an error in line 19.

    正确答案:B

  • 第5题:

    10. public class Hello {  11. String title;  12. int value;  13. public Hello() {  14. title += “ World”;  15. }  16. public Hello(int value) {  17. this.value = value;  18. title = “Hello”;  19. Hello();  20. }  21. }  and:  30. Hello c = new Hello(5);  31. System.out.println(c.title);  What is the result?() 

    • A、 Hello
    • B、 Hello World
    • C、 Compilation fails.
    • D、 Hello World 5
    • E、 The code runs with no output.
    • F、 An exception is thrown at runtime.

    正确答案:C

  • 第6题:

    11.classa {  12. public void process() { System.out.print(”a,”); } }  13. class b extends a {  14. public void process() throws IOException {  15. super.process();  16. System.out.print(”b,”);  17. throw new IOException();  18. } }  19. public static void main(String[] args) {  20. try { new b().process(); }  21. catch (IOException e) { System.out.println(”Exception”); } }  What is the result?() 

    • A、 Exception
    • B、 a,b,Exception
    • C、 Compilation fails because of an error in line 20.
    • D、 Compilation fails because of an error in line 14.
    • E、 A NullPointerException is thrown at runtime.

    正确答案:D

  • 第7题:

    11. public static void test(String str) {  12. if(str == null | str.lellgth() == 0) {  13. System.out.println(”String is empty”);  14. } else {  15. System.out.println(”String is not empty”);  16. }  17. }  And the invocation:  31. test(llull);  What is the result?() 

    • A、 Au exception is thrown at runtime.
    • B、 “String is empty” is printed to output.
    • C、 Compilation fails because of au error in line 12.
    • D、 “String is not empty” is printed to output.

    正确答案:A

  • 第8题:

    单选题
    11. static classA {  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

     B

    B

     The code runs with no output.

    C

     An exception is thrown at runtime.

    D

     Compilation fails because of an error in line 15.

    E

     Compilation fails because of an error in line 18.

    F

     Compilation fails because of an error in line 19.


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

  • 第9题:

    单选题
    11. public static void main(String[] args) {  12. Object obj =new int[] { 1,2,3 };  13. int[] someArray = (int[])obj;  14. for (int i: someArray) System.out.print(i +“ “)  15. }  What is the result? ()
    A

     1 2 3

    B

     Compilation fails because of an error in line 12.

    C

     Compilation fails because of an error in line 13.

    D

     Compilation fails because of an error in line 14.

    E

     A ClassCastException is thrown at runtime.


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

  • 第10题:

    单选题
    public class Test {  public static void main(String args[]) {  class Foo {  public int i = 3; }  Object o = (Object)new Foo();   Foo foo = (Foo)o;  System.out.println(“i = “ + foo.i); }  }  What is the result?()
    A

     i = 3

    B

     Compilation fails.

    C

     A ClassCastException is thrown at line 6.

    D

     A ClassCastException is thrown at line 7.


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

  • 第11题:

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


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

  • 第12题:

    单选题
    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
    解析: 暂无解析

  • 第13题:

    11. public void testIfA() {  12. if(testIfB(”True”)) {  13. System.out.println(”True”);  14. } else {  15. System.out.println(”Not true”);  16. }  17. }  18. public Boolean testIfB(String str) {  19. return Boolean.valueOf(str);  20. }  What is the result when method testIfA is invoked?() 

    • A、 True
    • B、 Not true
    • C、 An exception is thrown at runtime.
    • D、 Compilation fails because of an error at line 12.
    • E、 Compilation fails because of an error at line 19.

    正确答案:A

  • 第14题:

    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

  • 第15题:

    public class Test {  public static void main(String args[]) {  class Foo {  public int i = 3; }  Object o = (Object)new Foo();   Foo foo = (Foo)o;  System.out.println(“i = “ + foo.i); }  }  What is the result?()  

    • A、 i = 3
    • B、 Compilation fails.
    • C、 A ClassCastException is thrown at line 6.
    • D、 A ClassCastException is thrown at line 7.

    正确答案:A

  • 第16题:

    11. class Person {  12. String name = “No name‟;  13. public Person(String nm) { name = nm; }  14. }  15.  16. class Employee extends Person {  17. String emplD = “0000”;  18. public Employee(String id) { empID = id; }  19. }  20.  21. public class EmployeeTest {  22. public static void main(String[] args) {  23. Employee e = new Employee(”4321”);  24. System.out.println(e.empID);  25. }  26. }  What is the result?() 

    • A、 4321
    • B、 0000
    • C、 An exception is thrown at runtime.
    • D、 Compilation fails because of an error in line 18.

    正确答案:D

  • 第17题:

    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

  • 第18题:

    11. static classA {  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、 B
    • B、 The code runs with no output.
    • C、 An exception is thrown at runtime.
    • D、 Compilation fails because of an error in line 15.
    • E、 Compilation fails because of an error in line 18.
    • F、 Compilation fails because of an error in line 19.

    正确答案:F

  • 第19题:

    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

  • 第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. 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
    解析: 暂无解析

  • 第23题:

    单选题
    Given:   11. public static void main(String[] args) {   12. Object obj = new int[] { 1, 2, 3 };   13. int[] someArray = (int[])obj;   14. for (int i : someArray) System.out.print(i + " ");   15. }   What is the result? ()
    A

     Compilation fails because of an error in line 13.

    B

     A ClassCastException is thrown at runtime.

    C

     1 2 3

    D

     Compilation fails because of an error in line 14.

    E

     Compilation fails because of an error in line 12.


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