niusouti.com

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

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


相似考题
参考答案和解析
正确答案: E
解析: 暂无解析
更多“单选题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. pu”相关问题
  • 第1题:

    11. public class Test {  12. public void foo() {  13. assert false;  14. assert false;  15. }  16. public void bar(){  17. while(true){  18. assert false;  19. }  20. assert false;  21. }  22. }  What causes compilation to fail?()  

    • A、 Line 13
    • B、 Line 14
    • C、 Line 18
    • D、 Line 20

    正确答案:D

  • 第2题:

    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

  • 第3题:

    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (RuntimeException ex) {  System.out.print(“B”);  }  catch (Exception ex1) {  System.out.print(“C”);  }   finally {  System.out.print(“D”);  }  System.out.print(“E”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result?()  

    • A、 BD
    • B、 BCD
    • C、 BDE
    • D、 BCDE
    • E、 ABCDE
    • F、 Compilation fails.

    正确答案:C

  • 第4题:

    10. interface Foo {}  11. class Alpha implements Foo {}  12. class Beta extends Alpha {}  13. class Delta extends Beta {  14. public static void main( String[] args) {  15. Beta x = new Beta();  16. // insert code here  17. }  18. }  Which code, inserted at line 16, will cause a java.lang.ClassCastException?() 

    • A、 Alpha a = x;
    • B、 Foo f= (Delta)x;
    • C、 Foo f= (Alpha)x;
    • D、 Beta b = (Beta)(Alpha)x;

    正确答案:B

  • 第5题:

    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

  • 第6题:

    单选题
    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (RuntimeException ex) {  System.out.print(“B”);  }  catch (Exception ex1) {  System.out.print(“C”);  }   finally {  System.out.print(“D”);  }  System.out.print(“E”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result?()
    A

     BD

    B

     BCD

    C

     BDE

    D

     BCDE

    E

     ABCDE

    F

     Compilation fails.


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

  • 第7题:

    单选题
    static void test() throws RuntimeException {  try {  System.out.print(”test “);  throw new RuntimeException();  }  catch (Exception ex) { System.out.print(”exception “); }  }  public static void main(String[] args) {  try { test(); }  catch (RuntimeException ex) { System.out.print(”runtime “); }  System.out.print(”end “);  }  What is the result?()
    A

     test end

    B

     Compilation fails.

    C

     test runtime end

    D

     test exception end

    E

     A Throwable is thrown by main at runtime.


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

  • 第8题:

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


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

  • 第9题:

    单选题
    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result? ()
    A

     AB

    B

     BC

    C

     ABC

    D

     BCD

    E

     Compilation fails.


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

  • 第10题:

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


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

  • 第11题:

    单选题
    11. public class Test {  12. public void foo() {  13. assert false;  14. assert false;  15. }  16. public void bar(){  17. while(true){  18. assert false;  19. }  20. assert false;  21. }  22. }  What causes compilation to fail?()
    A

     Line 13

    B

     Line 14

    C

     Line 18

    D

     Line 20


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

  • 第12题:

    单选题
    public class Pet{  public void speak(){   System.out.print(“ Pet ”);  }  }   public class Cat extends Pet{  public void speak(){   System.out.print(“ Cat ”);  }  }   public class Dog extends Pet{  public void speak(){   System.out.print(“ Dog ”);  }  }   执行代码   Pet[] p = {new Cat(),new Dog(),new Pet()};   for(int i=0;i〈p.length;i++)   p[i].speak();   后输出的内容是哪项?()
    A

    Pet Pet Pet

    B

    Cat Cat Cat

    C

    Cat Dog Pet

    D

    Cat Dog Dog


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

  • 第13题:

    What is wrong with the following code?()   class MyException extends Exception {}   public class Qb4ab {   public void foo() {  try {  bar();  } finally {  baz();   } catch (MyException e) {}  }   public void bar() throws MyException {   throw new MyException();  }   public void baz() throws RuntimeException {   throw new RuntimeException();   }   }  

    • A、Since the method foo() does not catch the exception generated by the method baz(), it must      declare the RuntimeException in its throws clause.
    • B、A try block cannot be followed by both a catch and a finally block.
    • C、An empty catch block is not allowed.
    • D、A catch block cannot follow a finally block.
    • E、A finally block must always follow one or more catch blocks.

    正确答案:D

  • 第14题:

    public class Pet{  public void speak(){   System.out.print(“ Pet ”);  }  }   public class Cat extends Pet{  public void speak(){   System.out.print(“ Cat ”);  }  }   public class Dog extends Pet{  public void speak(){   System.out.print(“ Dog ”);  }  }   执行代码   Pet[] p = {new Cat(),new Dog(),new Pet()};   for(int i=0;i〈p.length;i++)   p[i].speak();   后输出的内容是哪项?()  

    • A、Pet Pet Pet
    • B、Cat Cat Cat
    • C、Cat Dog Pet
    • D、Cat Dog Dog

    正确答案:C

  • 第15题:

    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result? () 

    • A、 AB
    • B、 BC
    • C、 ABC
    • D、 BCD
    • E、 Compilation fails.

    正确答案:D

  • 第16题:

    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

  • 第17题:

    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

  • 第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.


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

  • 第19题:

    单选题
    What is wrong with the following code?()   class MyException extends Exception {}   public class Qb4ab {   public void foo() {  try {  bar();  } finally {  baz();   } catch (MyException e) {}  }   public void bar() throws MyException {   throw new MyException();  }   public void baz() throws RuntimeException {   throw new RuntimeException();   }   }
    A

    Since the method foo() does not catch the exception generated by the method baz(), it must      declare the RuntimeException in its throws clause.

    B

    A try block cannot be followed by both a catch and a finally block.

    C

    An empty catch block is not allowed.

    D

    A catch block cannot follow a finally block.

    E

    A finally block must always follow one or more catch blocks.


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

  • 第20题:

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

  • 第21题:

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

  • 第22题:

    单选题
    10. interface Foo { int bar(); }  11. public class Sprite {  12. public int fubar( Foo foo) { return foo.bar(); }  13. public void testFoo() {  14. fubar(  15. // insert code here  16.);  17. }  18. }  Which code, inserted at line 15, allows the class Sprite to compile?()
    A

     Foo { public int bar() { return 1; } }

    B

     new Foo { public int bar() { return 1; } }

    C

     newFoo() { public int bar(){return 1; } }

    D

     new class Foo { public int bar() { return 1; } }


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

  • 第23题:

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

  • 第24题:

    单选题
    1. public class GoTest {  2. public static void main(String[] args) {  3. Sente a = new Sente(); a.go();  4. Goban b = new Goban(); b.go();  5. Stone c = new Stone(); c.go();  6. }  7. } 8.  9. class Sente implements Go {  10. public void go() { System.out.println(”go in Sente.”); }  11. }  12.  13. class Goban extends Sente {  14. public void go() { System.out.println(”go in Goban”); }  15. }  16.  17. class Stone extends Goban implements Go { }  18.  19. interface Go { public void go(); }  What is the result?()
    A

     go in Goban     go in Sente go in Sente

    B

     go in Sente      go in Sente go in Goban

    C

     go in Sente     go in Goban go in Goban

    D

     go in Goban    go in Goban go in Sente

    E

     Compilation fails because of an error in line 17.


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