单项选择题
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.
相关考题
-
多项选择题
Whichstatementsaretrueconcerningtheeffectofthe>>and>>>operators?()
A.For non-negative values of the left operand, the >> and >>> operators will have the same effect.
B.The result of (-1 >> 1) is 0.
C.The result of (-1 >>> 1) is -1.
D.The value returned by >>> will never be negative as long as the value of the right operand is equal to or greater than 1.
E.When using the >> operator, the leftmost bit of the bit representation of the resulting value will always be the same bit value as the leftmost bit of the bit representation of the left operand. -
多项选择题
Giventhefollowingclass,whichstatementscanbeinsertedatposition1withoutcausingthecodetofailcompilation?() publicclassQ6db8{ inta; intb=0; staticintc; publicvoidm(){ intd; inte=0; //Position1 } }
A.a++;
B.b++;
C.c++;
D.d++;
E.e++; -
单项选择题
If this source code is contained in a file called SmallProg.java, what command should be used to compile it using the JDK?() public class SmallProg { public static void main(String args[]) { System.out.println("Good luck!"); } }
A.java SmallProg
B.avac SmallProg
C.javac SmallProg.java
D.java SmallProg main
