The following is a question from my teacher along with the correct answer:
public class IfTest {
public static void main (String args[]) {
if (true)
if (false)
System.out.println("a");
else
System.out.println("b");
}
}
The code will compile correctly and display the letter b when run.
I have to explain why this is the correct answer. Is it because it skips both if statements since there is no condition and prints the else statement?