CMS专题

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

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

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?() 

  • A、 StackOverflowError
  • B、 NullPointerException
  • C、 NumberFormatException
  • D、 IllegalArgumentException
  • E、 ExceptionlnlnitializerError

正确答案: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题:

使用jdbc 编写class EnrollmentImpl 实现接口 Enrollment:

public interface Enrollment{

public void createStudent(Student student) throws Exception;

pubic void createCourse(Course course) throws Exception;

public void enroll(Student student, Course course) throws Exception;

public void exam(Student, Course course, float grade) throws Exception;

}


正确答案:
 

第4题:

public class TestOne {  public static void main (String[] args) throws Exception {  Thread.sleep(3000);  System.out.println(”sleep”);  }  }  What is the result?() 

  • A、 Compilation fails.
  • B、 An exception is thrown at runtime.
  • C、 The code executes normally and prints “sleep”.
  • D、 The code executes normally, but nothing is printed.

正确答案:C

第5题:

public class ExceptionTest {   class TestException extends Exception {}   public void runTest () throws TestException {}   public void test () /* Point X*/ {   runTest ();   }   }   At point X on line 4, which code can be added to make the code compile?()  

  • A、 Throws Exception.
  • B、 Catch (Exception e).
  • C、 Throws RuntimeException.
  • D、 Catch (TestException e).
  • E、 No code is necessary.

正确答案:B

第6题:

下面哪个方法不是HttpServlet类:()

  • A、protected void doGet(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception ,java.io.IOException
  • B、protected void doPost(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOException
  • C、protected void doHead(HttpServletRequest reg,HttpServletResponse res) throws Servlet Exception,java.io.IOException
  • D、protected void doReceive(HttpServletRequest reg,HttpServletResponse res) throws ServletException,java.io.IOException

正确答案:D

第7题:

public class Test {  public static void aMethod() throws Exception {  try {  throw new Exception(); } finally {  System.out.println(“finally”);  }  }  public static void main(String args[]) {  try {  aMethod();  } catch (Exception e) {  System.out.println(“exception”);  }  System.out.println(“finished”);  }  }  What is the result?()  

  • A、 finally
  • B、 exception finished
  • C、 finally exception finished
  • D、 Compilation fails.

正确答案:C

第8题:

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.

正确答案:D

第9题:

public class Starter extends Thread {  private int x= 2;  public static void main(String[] args) throws Exception {  new Starter().makeItSo();  }  public Starter() {  x=5;  start();  }  public void makeItSo() throws Exception {  join();  x=x- 1;  System.out.println(x);  }  public void run() { x *= 2; }  }  What is the output if the main() method is rum?() 

  • A、 4
  • B、 5
  • C、 8
  • D、 9
  • E、 Compilation fails.
  • F、 An exception is thrown at runtime.
  • G、 It is impossible to determine for certain.

正确答案:D

第10题:

现有:  void topGo()  {      try  {  middleGo();  }  catch  (Exception e)  {      System.out.print("catch");      }      }  void middleGo()  throws Exception  {     go();  system.out.print("late middle");     }  void go()  throws ExceptiOn  {     throw new Exception();     } 如果调用 topGo () ,则结果为:() 

  • A、 late middle
  • B、 catch
  • C、 late middle catch
  • D、 catch Iate middle

正确答案:B

更多相关问题