Exam Prep Practice Questions

Question 1 You are writing a utility class and your company's policy is to keep utility classes in a package named conglomo.util. Select the correct code fragment to start a class file for a class that uses classes in the java.awt and java.util standard library packages.
  • A.

    1. package java.conglomo.util
    2. import java.awt.*
    3. import java.util.*
    
  • B.

    1. package conglomo.util ;
    2. import java.awt.* ;
    3. import java.util.* ;
    
  • C.

    1. import java.awt.* ;
    2. import java.util.* ;
    3. import conglomo.util.* ;
    
  • D.

    1. package conglomo.util ;
    2. import java.*.* ;
    
A1: Answer B is correct. Note that the package statement must be the first compiler-usable statement. It can follow comment lines and blank lines but must precede all ...

Get Java 2™ Programmer Exam Cram™ 2 (Exam CX-310-035) 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.