Java SE 8 Programmer II — Question 4

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);
}
}
ea option?
What is the result of running the code with the

Answer options

Correct answer: B

Explanation

The code includes an assertion that checks if 'b' is greater than or equal to 1. Since 'b' is -1, the assertion fails, resulting in an AssertionError being thrown. Options A, C, and D are incorrect as they do not reflect the actual outcome of the assertion failure.