单选题1. class Exc0 extends Exception { }  2. class Exc1 extends Exc0 { }  3. public class Test {  4. public static void main(String args[]) {  5. try {  6. throw new Exc1();  7. } catch (Exc0 e0) {  8. System.out.println(“Ex0 caught”);  9. } catch (Exception e) {  10. System.out.println(“exception caught”);  11. }  12. }  13. }  What is the result?()A Ex0 caughtB exception caughtC Compilation fails because of an error at line 2.D Compilation fails because of an error at line 6.

单选题
1. class Exc0 extends Exception { }  2. class Exc1 extends Exc0 { }  3. public class Test {  4. public static void main(String args[]) {  5. try {  6. throw new Exc1();  7. } catch (Exc0 e0) {  8. System.out.println(“Ex0 caught”);  9. } catch (Exception e) {  10. System.out.println(“exception caught”);  11. }  12. }  13. }  What is the result?()
A

 Ex0 caught

B

 exception caught

C

 Compilation fails because of an error at line 2.

D

 Compilation fails because of an error at line 6.


参考解析

解析: 暂无解析

相关考题:

下列类头定义中,错误的是( )。 A.class x { .... }B.public x extends y { .... }C.public class x extends y { .... }D.class x extends y implements y1 { .... }

Given:Which two, inserted at line 11, will allow the code to compile?() A.public class MinMax? {B.public class MinMax? extends Number {C.public class MinMaxN extends Object {D.public class MinMaxN extends Number {E.public class MinMax? extends Object {F.public class MinMaxN extends Integer {

如果有-个类MyFrame是Frame的子类,但它不能被实例化,请写出该类的声明头为( )。A.abstract class Frame. extends MyFrameB.abstract class MyFrame. extends FrameC.class MyFrame. abstract extends FrameD.class Frame. abstract extends MyFrame.

如果有一个类MyFrame是Frame的子类,但它不能被实例化,请写出该类的声明头为( )。A.abstract class Frame. extends MyFrameB.abstract class MyFrame. extends FrameC.class MyFrame. abstract extends FrameD.class Frame. abstract extends MyFrame.

定义一个类名为MyClass的类,并且该类可被所有类访问,那么该类的正确声明应为()A、private class MyClass extends ObjectB、class MyClass extends ObjectC、public class MyClassD、protected class MyClass extends Object

Class TestException  1. public class TestException extends Exception {  2. } Class a:  1. public class a {  2.  3. public String sayHello(String name) throws TestException {  4.  5. if(name == null) {  6. throw new TestException();  7. }  8.  9. return “Hello “+ name;  10. }  11.  12. }  A programmer wants to use this code in an application: 45. A a=new A();  46. System.out.println(a.sayHello(”John”));  Which two are true?()A、 Class a will not compile.B、 Line 46 can throw the unchecked exception TestException.C、 Line 45 can throw the unchecked exception TestException.D、 Line 46 will compile if the enclosing method throws a TestException.E、 Line 46 will compile if enclosed in a try block, where TestException is caught.

public class TestA{    public void methodA() throws IOException{        //……    } }  public class TestB extends TestA{    public void methodA() throws EOFException{        //……   } }  public class TestC extends TestA{    public void methodA() throws Exception{        //……   } }  当编译类TestC的时候,结果是哪项?() A、 正常B、 编译错误C、 运行错误D、 以上都不对

1. class SuperClass {  2. public a geta() {  3. return new a();  4. }  5. }  6. class SubClass extends SuperClass {  7. public b geta() {  8. return new b();  9. }  10. }  Which is true?() A、 Compilation will succeed if a extends b.B、 Compilation will succeed if b extends a.C、 Compilation will always fail because of an error in line 7.D、 Compilation will always fail because of an error in line 8.

Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program?()   class A {}   class B extends A {}   class C extends A {}   public class Q3ae4 {   public static void main(String args[]) {   A x = new A();   B y = new B();   C z = new C();   // insert statement here   }   } A、x = y;B、z = x;C、y = (B) x;D、z = (C) y;E、y = (A) y;

现在有两个类A、B,以下描述中表示B继承自A的是()A、class A extends BB、class B implements AC、class A implementsD、class B extends A

定义一个类名为"MyClass.java"的类,并且该类可被一个工程中的所有类访问,那么该类的正确声明应为()。A、private class My Class extends ObjectB、class My Class extends ObjectC、public class My ClassD、public class My Class extends Object

1. public class Exception Test {  2. class TestException extends Exception {}  3. public void runTest() throws TestException {}  4. public void test() /* Point X */ {  5. runTest();  6. }  7. }  At Point X on line 4, which code is necessary to make the code compile?()  A、 No code is necessary.B、 throws ExceptionC、 catch ( Exception e )D、 throws RuntimeExceptionE、 catch ( TestException e)

现自:  1.  interface Color {  }      2. interface Weight  {  }      3.  //insert code here    和以下足六个声明:  class Boat extends Color, extends Weight  {  }     class Boat extends Color and Weight  {  }      class Boat extends Color, Weight  {  }  class Boat implements Color,  implements Weight  {  }     class Boat implements Color and Weight  {  }      class Boat implements Color, Weight  {  }    分别插入到第3行,有多少行可以编译? () A、  0B、  1C、  2D、  3

下列类的定义中,错误的是()。A、class x{....}B、public x extends y{....}C、public class x extends y{....}D、class x extends y implements y1{....}

Which two demonstrate an “is a” relationship?()   A、 public interface Person { }  public class Employee extends Person { }B、 public interface Shape { }  public class Employee extends Shape { }C、 public interface Color { }  public class Employee extends Color { }D、 public class Species { }  public class Animal (private Species species;)E、 interface Component { }  Class Container implements Component ( Private Component[ ]children;  )

What produces a compiler error?()  A、 class A { public A(int x) {} }B、 class A {} class B extends A { B() {} }C、 class A { A() {} } class B { public B() {} }D、 class Z { public Z(int) {} } class A extends Z {}

1. class Exc0 extends Exception { }  2. class Exc1 extends Exc0 { }  3. public class Test {  4. public static void main(String args[]) {  5. try {  6. throw new Exc1();  7. } catch (Exc0 e0) {  8. System.out.println(“Ex0 caught”);  9. } catch (Exception e) {  10. System.out.println(“exception caught”);  11. }  12. }  13. }  What is the result?()  A、 Ex0 caughtB、 exception caughtC、 Compilation fails because of an error at line 2.D、 Compilation fails because of an error at line 6.

多选题定义一个类名为"MyClass.java"的类,并且该类可被一个工程中的所有类访问,那么该类的正确声明应为()。Aprivate class My Class extends ObjectBclass My Class extends ObjectCpublic class My ClassDpublic class My Class extends Object

多选题Class TestException  1. public class TestException extends Exception {  2. } Class a:  1. public class a {  2.  3. public String sayHello(String name) throws TestException {  4.  5. if(name == null) {  6. throw new TestException();  7. }  8.  9. return “Hello “+ name;  10. }  11.  12. }  A programmer wants to use this code in an application: 45. A a=new A();  46. System.out.println(a.sayHello(”John”));  Which two are true?()AClass a will not compile.BLine 46 can throw the unchecked exception TestException.CLine 45 can throw the unchecked exception TestException.DLine 46 will compile if the enclosing method throws a TestException.ELine 46 will compile if enclosed in a try block, where TestException is caught.

单选题1. class Exc0 extends Exception { }  2. class Exc1 extends Exc0 { }  3. public class Test {  4. public static void main(String args[]) {  5. try {  6. throw new Exc1();  7. } catch (Exc0 e0) {  8. System.out.println(“Ex0 caught”);  9. } catch (Exception e) {  10. System.out.println(“exception caught”);  11. }  12. }  13. }  What is the result?()A Ex0 caughtB exception caughtC Compilation fails because of an error at line 2.D Compilation fails because of an error at line 6.

单选题Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program?()   class A {}   class B extends A {}   class C extends A {}   public class Q3ae4 {   public static void main(String args[]) {   A x = new A();   B y = new B();   C z = new C();   // insert statement here   }   }Ax = y;Bz = x;Cy = (B) x;Dz = (C) y;Ey = (A) y;

单选题1. import java.util.*;  2. class SubGen {  3. public static void main(String [] args) {  4. //insert code here  5. }  6. }  class Alpha { }  class Beta extends Alpha { }  class Gamma extends Beta { }  和四段代码片段:  s1. ArrayList〈? extends Alpha〉 list1 = new ArrayList〈Gamma〉();  s2. ArrayList〈Alpha〉 list2 = new ArrayList〈? extends Alpha〉();  s3. ArrayList〈? extends Alpha〉 list3 = new ArrayList〈? extends Beta〉();  s4. ArrayList〈? extends Beta〉 list4 = new ArrayList〈Gamma〉(); ArrayList〈? extends Alpha〉 list5 = list4;  哪些片段分别插入到第4行,可允许代码编译?()A只有s1B只有s3C只有s1和s3D只有s1和s4

多选题Which two demonstrate an “is a” relationship?()Apublic interface Person { }  public class Employee extends Person { }Bpublic interface Shape { }  public class Employee extends Shape { }Cpublic interface Color { }  public class Employee extends Color { }Dpublic class Species { }  public class Animal (private Species species;)Einterface Component { }  Class Container implements Component ( Private Component[ ]children;  )

单选题public class TestA{   public void methodA()  throws IOException{   //……   }   }   public class TestB extends TestA{   public void methodA()  throws EOFException{   //……   }   }   public class TestC extends TestA{   public void methodA()  throws Exception{   //……   }   }   当编译类TestC的时候,结果是哪项?()A 正常B 编译错误C 运行错误D 以上都不对

单选题1.class TestSuper { 22.TestSuper(int i) { } 3. } 4.class TestSub extends TestSuper{ } 5.class TestAll { 6.public static void main (String [] args) { 7.new TestSub(); 8.} 9.} Which is true?()A Compilation fails.B The code runs without exception.C An exception is thrown at line 7.D An exception is thrown at line 2.

单选题现自:  1.  interface Color {  }      2. interface Weight  {  }      3.  //insert code here    和以下足六个声明:  class Boat extends Color, extends Weight  {  }     class Boat extends Color and Weight  {  }      class Boat extends Color, Weight  {  }  class Boat implements Color,  implements Weight  {  }     class Boat implements Color and Weight  {  }      class Boat implements Color, Weight  {  }    分别插入到第3行,有多少行可以编译? ()A  0B  1C  2D  3

单选题What produces a compiler error?()A class A { public A(int x) {} }B class A {} class B extends A { B() {} }C class A { A() {} } class B { public B() {} }D class Z { public Z(int) {} } class A extends Z {}

单选题1. public class Exception Test {  2. class TestException extends Exception {}  3. public void runTest() throws TestException {}  4. public void test() /* Point X */ {  5. runTest();  6. }  7. }  At Point X on line 4, which code is necessary to make the code compile?()A No code is necessary.B throws ExceptionC catch ( Exception e )D throws RuntimeExceptionE catch ( TestException e)