单项选择题
public class Test {
public static void main(String[] args) {
int x = 0;
assert (x > 0) ? “assertion failed” : “assertion passed”;
System.out.println(“Finished”);
}
}
What is the result?()
A. finished
B. Compilation fails.
C. An AssertionError is thrown and finished is output.
D. An AssertionError is thrown with the message “assertion failed”.
E. An AssertionError is thrown with the message “assertion passed”.
点击查看答案&解析
相关考题
-
单项选择题
public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (RuntimeException ex) { System.out.print(“B”); } catch (Exception ex1) { System.out.print(“C”); } finally { System.out.print(“D”); } System.out.print(“E”); } public static void badMethod() { throw new RuntimeException(); } } What is the result?()
A. BD
B. BCD
C. BDE
D. BCDE
E. ABCDE
F. Compilation fails. -
多项选择题
switch(x) { default: System.out.println(“Hello”); } Which two are acceptable types for x?()
A. byte
B. long
C. char
D. float
E. Short
F. Long -
单项选择题
Youwanttolimitaccesstoamethodofapublicclasstomembersofthesameclass.Whichaccessaccomplishesthisobjective?()
A. public
B. private
C. protected
D. transient
E. default access
