🎴 Flashcard Mode
C# and Java Programming Fundamentals
Card1 / 20
Mastered0
Review0
QuestionClick to flip
public class Test { public static void main(String... args) { for(int i = 2; i < 4; i++) for(int j = 2; j < 4; j++) if(i < j) assert i!=j : i; } }
AnswerClick to flip back
A
The class compiles and runs, but does not print anything
💡 Explanation:
The code compiles and runs without printing anything because assertions are disabled by default in Java. The nested loops iterate i=2,3 and j=2,3, checking if i<j is true. When i=2 and j=3, the condition i!=j is true (2!=3), so the assertion passes and nothing is printed. Without enabling assertions (-ea flag), assertions are ignored entirely.