Multiple choice technology programming languages

What will happen when you attempt to compile and run the following code? (Assume that the code is compiled and run with assertions enabled.) public class AssertTest { public void methodA(int i) { assert i >= 0 : methodB(); System.out.println(i); } public void methodB() { System.out.println("The value must not be negative"); } public static void main(String args[]) { AssertTest test = new AssertTest(); test.methodA(-10); } }

  1. It will print -10

  2. It will result in Assertion Error showing the message -"The value must not be negative".

  3. The code will not compile.

  4. None of these.

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

The Java assertion statement syntax requires the second expression (after the colon) to return a value. Because methodB() has a void return type, it cannot be used as the detail message expression, causing a compilation error.