What is the result of running the code with the –ea option?

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?

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.



Leave a Reply 4

Your email address will not be published. Required fields are marked *


smh

smh

C
with -ea option an assertion error is thrown.

Berti John

Berti John

C is correct
Exception in thread “main” java.lang.AssertionError: Invalid Denominator
at examen2.Test2.main(Test2.java:255)

andrei

andrei

C.
If assertions are enabled and the boolean expression is false , then assertion is
invalid and a java.lang.AssertionError is thrown.