Multiple choice

What will be the output of the program? public class Test {
public static void main(String[] args) { int x = 0;
assert (x > 0) ? "assertion failed" : "assertion passed" ; System.out.println("finished");
} }

  1. finished

  2. Compiliation fails.

  3. An AssertionError is thrown and finished is output.

  4. An AssertionError is thrown with the message "assertion failed."

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Compilation Fails. You can't use the Assert statement in a similar way to the ternary operator. Don't confuse.