Given:
public class Counter {
public static void main (String[ ] args) {
int a = 10;
int b = -1;
assert (b >=1) : “Invalid Denominator”;
int с = a / b;
System.out.println (c);
}
}
What is the result of running the code with the –ea option?
A.
-10
B.
0
C.
An AssertionError is thrown.
D.
A compilation error occurs.
C
C
with -ea option an assertion error is thrown.
C is correct
Exception in thread “main” java.lang.AssertionError: Invalid Denominator
at examen2.Test2.main(Test2.java:255)
C.
If assertions are enabled and the boolean expression is false , then assertion is
invalid and a java.lang.AssertionError is thrown.