hai
here bydefaultly the assertions are disabled
so it should print finished
but why this code is giveing compile time error
Given:
1. public class
Test {
2. public static void main(
String[] args) {
3. int x = 0;
4. assert (x > 0) ? "assertion failed" : "assertion passed";
5. System.out.println("Finished");
6. }
7. }
What is the result?
A. finished
B. Compilation fails.
C. An AssertionError is thrown and finished is output.
D. An AssertionError is thrown with the message "assertion failed".
E. An AssertionError is thrown with the message "assertion passed".
Answer: B
by
velan vel