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.
第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.
第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
第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); } }
第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题:
A.final
B.static
C.native
D.public
E.private