Assessment Test

  1. The following code appears in a file named Book.java. What is the result of compiling this source file? (Select one answer.)
    1.  public class Book {
    2.      private int pageNumber;
    3.
    4.      private class BookReader {
    5.          public int getPage() {
    6.              return pageNumber;
    7.          }
    8.      }
    9.  }
    1. The code compiles successfully and one bytecode file is generated: Book.class.
    2. The code compiles successfully and two bytecode files are generated: Book.class and BookReader.class.
    3. The code compiles successfully and two bytecode files are generated: Book.class and Book$BookReader.class.
    4. A compiler error occurs on line 4.
    5. A compiler error occurs on line 6.
  2. Given the following TV class:
    1. public class TV { 2. private String make; 3. private String model; ...

Get SCJP: Sun Certified Programmer for Java® Platform, SE6, Study Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.