OCJA exam prep

Only available on StudyMode
  • Download(s): 27
  • Published: December 1, 2013
Read full document
Text Preview
Appendix H
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: The name is similar to that of the basic interpreter utility. Reference: Chapter 1: Packaging, Compiling, and Interpreting Java Code
Objective: Compile and Interpret Java Code
Q6: Import for ArrayList
6. What is the correct import package needed to use the ArrayList class?
A. import java.awt.*;
B. import java.io.*;
C. import java.net.*;
D. import javax.swing.*;

E. import java.util.*;
F. This is a trick question, because it is part of the java.lang package that is imported automatically.
Hint: The package names give you some clue as to what it contains. Reference: Chapter 1: Packaging, Compiling, and Interpreting Java Code
Objective: Understand Package-Derived Classes
Q7: Packages for graphical toolkits
7. Of the following packages, which contain classes for building a graphical interface? (Choose all that apply.)
A. java.awt
B. java.io
C. java.net
D. javax.swing
E. java.util
Hint: Rule out the packages with obvious names. Packages for graphical interfaces have names that make the least sense.
Reference: Chapter 1: Packaging, Compiling, and Interpreting Java Code
Objective: Understand Package-Derived Classes
Q8: Extending classes
8. Which of the following statements is correct?

A. A Java class can extend only one superclass.
B. A Java class can extend multiple superclasses.
C. A Java class cannot extend any superclasses.
D. A Java class does not extend superclasses; it implements them. Hint: Interfaces are implemented.
Reference: Chapter 1: Packaging, Compiling, and Interpreting Java Code
Objective: Understand Class Structure
Q9: Packages
9. You have created a set of classes for your company and would like to include them in a package. Which one of the following would be a valid package name?
A. your company name
B. com.your company name
C. java.your company name
D. java.your_company_name
E. com.your_company_name
Hint: Look for the answer that uses invalid names or characters. Reference: Chapter 1: Packaging, Compiling, and Interpreting...
tracking img