O'Reilly logo

Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition by Rolf W. Rasmussen, Khalid A. Mughal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Review Questions

5.1 What will be the result of attempting to compile and run the following class?
public class IfTest {
    public static void main(String[] args) {
        if (true)
        if (false)
        System.out.println("a");
        else
        System.out.println("b");
    }
}

Select the one correct answer.

  1. The code will fail to compile because the syntax of the if statement is incorrect.

  2. The code will fail to compile because the compiler will not be able to determine which if statement the else clause belongs to.

  3. The code will compile correctly and display the letter a when run.

  4. The code will compile correctly and display the letter b when run.

  5. The code will compile correctly, but ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required