The program is run with java Sample01 - what will be the output?
public class Sample01
{
public static void main(String[] args)
{
int x = 5;
assert x > 10;
System.out.println("done");
}
}
Answer: A
Assertions are disabled by default, and a disabled assertion is semantically equivalent to an empty statement. The expression x > 10 is never evaluated, so no AssertionError can be thrown and the program falls through to the print. Only java -ea Sample01 would make this fail.
Please log in or register to report this question.