This is a question from the ePractice exams for 310-055 purchased directly from Sun Microsystems.
Given:
Which is true?
A - An assertion error will occur at runtime.
B - The command-line invocation
java -ea TestAssert will produce no error and the output "more info ".
C - The command-line invocation java -ea TestAssert will produce no error and the output "after assert ".
D - The command-line invocation java -ea TestAssert will produce no error and the output "more info after assert ".
E - The command-line invocation java -ea TestAssert will produce no error and the output "after assert more info ".
Sun's answer is:
Option A is correct. The command-line enables assertions, and more info is added to the stack trace before the program ends at line 3 with an AssertionError.
I disagree. Assertions are disabled by default at runtime. The question did not provide the command-line being used. I think the correct answer should be (which is not one of the options provided):
The command-line invocation java -ea TestAssert will produce an assertion error and the output "more info ".
Can someone please confirm?
Thank you!
Bonnie