Practice Exam
Q1: Package statements
1. Which statement is not true about package statements?
A. Package statements are optional.
B. Package statements are limited to one per source file.
C. Standard Java coding convention for package names reverses the domain name of the organization or group creating the package.
D. The package names beginning with javas.* and javaw.* are reserved. Hint: Consider the package names java.util and javax.swing. Reference: Chapter 1: Packaging, Compiling, and Interpreting Java
Code
Objective: Understand Packages
Q2: Import statements
2. Which statement represents a valid statement that will allow for the inclusion of classes from the java.util package?
A. import java.util;
B. import java.util.*;
C. #include java.util;
D. #include java.util.*;
Hint: Consider valid Java keywords.
Reference: Chapter 1: Packaging, Compiling, and Interpreting Java
Code
Objective: Understand Packages
Q3: Collections API
3. List four interfaces of the Collections API.
A. ArrayList, Map, Set, Queue
B. List, Map, Set, Queue
C. List, Map, HashSet, PriorityQueue
D. List, HashMap, HashSet, PriorityQueue
Hint: Consider the differences between interfaces and implementations (concrete classes).
Reference: Chapter 1: Packaging, Compiling, and Interpreting Java
Code
Objective: Understand Package-Derived Classes
Q4: Basic input/output classes
4. Which class in the java.io package allows for the reading and writing of files to specified locations within a file?
A. File
B. FileDescriptor
C. FilenameFilter
D. RandomAccessFile
Hint: This class implements DataOutput, DataInput, and Closeable.
Reference: Chapter 1: Packaging, Compiling, and Interpreting Java
Code
Objective: Understand Package-Derived Classes
Q5: Java interpreter
5. Which MS Windows–based command-line utility will allow you to run the Java interpreter without launching the console window?
A. javaw
B. interpw
C. java -wo
D. jconsole
Hint: