Given:11.staticclassA{12.voidprocess()throwsException{thrownewException();}13.}14.staticclassBextendsA{15.voidprocess(){System.out.println("B");}16.}17.publicstaticvoidmain(String[]args){18.Aa=newB();19.a.process();20.}Whatistheresult?()A.Compilationfails

题目

Given:11.staticclassA{12.voidprocess()throwsException{thrownewException();}13.}14.staticclassBextendsA{15.voidprocess(){System.out.println("B");}16.}17.publicstaticvoidmain(String[]args){18.Aa=newB();19.a.process();20.}Whatistheresult?()

A.Compilationfailsbecauseofanerrorinline19.

B.Anexceptionisthrownatruntime.

C.B

D.Compilationfailsbecauseofanerrorinline18.

E.Compilationfailsbecauseofanerrorinline15.

F.Thecoderunswithnooutput.


相似考题
更多“Given:11.staticclassA{12.voidprocess()throwsException{thrownewException();}13.}14.staticcl ”相关问题
  • 第1题:

    publicclassTest{publicstaticvoidaMethod()throwsException{try{thrownewException();}finally{System.out.println(finally”);}}publicstaticvoidmain(Stringargs[]){try{aMethod();}catch(Exceptione){System.out.println(exception”);}System.out.println(finished”);}}Whatistheresult?()

    A.finally

    B.exceptionfinished

    C.finallyexceptionfinished

    D.Compilationfails.


    参考答案:C

  • 第2题:

    给定以下JAVA代码,这段代码编译运行后输出的结果是( )

    publicclassTest{

    publicstaticintaMethod(inti)throwsException{

    try{

    returni/10;

    }catch(Exceptionex){

    thrownewException("exceptioninaaMothod");

    }finally{

    System.out.print("finally");

    }

    }

    publicstaticvoidmain(String[]args){

    try{

    aMethod(0);

    }catch(Exceptionex){

    System.out.print("exceptioninmain");

    }

    System.out.print("finished");

    }

    }

    A、finallyexceptioninmainfinished

    B、exceptioninmainfinally

    C、finallyfinished

    D、finallyexceptioninmainfinished


    正确答案:C

  • 第3题:

    给定如下Java代码片段,则下列调用方法正确的是()。 Public int count (int i) throws Exception { if (i==0) throw new Exception(“参数不正确!”); return 20/i; }

    A.public void useCount(){ count(0); }

    B.public void useCount() throws Exception{ count(0); }

    C.public void useCount(){ try { count(10); }catch(ArithmeticException e){} }

    D.public void useCount(){ try{ count(10); } }


    public void useCount() throws Exception{ count(0); }

  • 第4题:

    使用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;

    }


    正确答案:
     

  • 第5题:

    Given11.publicinterfaceStatus{12./*insertcodehere*/intMY_VALUE=10;13.}Whichthreearevalidonline12?()

    A.final

    B.static

    C.native

    D.public

    E.private


    参考答案:A, B, D