Sun Certified Java Programmer Pre-Exam Essentials

©1999, 2000, 2002 Dylan Walsh.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being the disclaimer, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
The exam objectives below are quoted from Sun Microsystems website. Also there are parts quoted from the Javadocs, also the property of Sun Microsystems.


No claims are made about the accuracy of this document and no responsibility is taken for any errors.
If you find any errors contact the maintainer of the site where you found this document, or better still submit a newer version with a correction.
The original author cannot control, and may not be aware of, derived versions of this document.

This guide is available in several forms:
To view this whole document as one long webpage, click here.
To view a printer friendly-version, click here.
To download all the files related to this document, click here.



Useful links
The Exam
About This Document

Declarations and Access Control

Write code that declares, constructs and initializes arrays of any base type using any of the permitted forms both for declaration and for initialization.
Declaring arrays:
Construct arrays:
To initialize an array using loop iteration:
Write code to initialize an array using the combined declaration and initialization format:
Declare classes, nested classes, methods, instance variables, static variables and automatic (method local) variables making appropriate use of all permitted modifiers (such as public, final, static, abstract etc.). State the significance of each of these modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers.
Some terms and their synonyms:
Scoping Types
Declare classes using the modifiers public, abstract or final:
Using the modifiers private, protected, public, static, final, native or abstract:
Nested Classes
To define a non-static nested class either in a class or method scope:
To define, in method scope, an anonymous nested class that implements a specified interface:
Write code in a non-static method of the outer class to construct an instance of the nested class.
Write code to construct an instance on a nested class where either no this object exists, or the current this object is not an instance of the outer class.
State which variables and methods in enclosing scopes are accessible from methods of the inner class.
For a given class, determine if a default constructor will be created and if so state the prototype of that constructor.

Flow Control, Assertions and Exception Handling

Write code using if, and switch statements and identify legal argument types for these statements.
Write code using all forms of loops including labeled and unlabeled, use of break and continue, and state the values taken by loop counter variables during and after loop execution.
Write code that makes proper use of exceptions and exception handling clauses (try, catch(), finally) and declares methods and overriding methods that throw exceptions.
Declaring exceptions in a method
Overriding and exceptions
To create and throw a specified exception
Recognize the effect of an exception arising at a specified point in a code fragment. Note: The exception may be a runtime exception, a checked exception, or an error (the code may include try, catch, or finally clauses in any legitimate combination).
Write code that makes proper use of assertions, and distinguish appropriate from inappropriate uses of assertions.
Identify correct statements about the assertion mechanism.

Garbage Collection

State the behavior that is guaranteed by the garbage collection system.
Write code that explicitly makes objects eligible for garbage collection.
Recognize the point in a piece of source code at which an object becomes eligible for garbage collection.

Language Fundamentals

Identify correctly constructed package declarations, import statements, class declarations (of all forms including inner classes) interface declarations, method declarations (including the main method that is used to start execution of a class), variable declarations, and identifiers.
Order of package declarations, import statements, public class declarations
Correct declaration for a main() method.
Legal and illegal identifiers
State the correspondence between index values in the argument array passed to a main method and command line arguments.
Identify classes that correctly implement an interface where that interface is either java.lang.Runnable or a fully specified interface in the question.
Identify all Java programming language keywords. Note: There will not be any questions regarding esoteric distinctions between keywords and manifest constants.
State the effect of using a variable or array element of any kind when no explicit assignment has been made to it.
State the range of all primitive formats, data types and declare literal values for String and all primitive types using all permitted formats bases and representations.
Range of primitive data types.
Constructing literal numeric values using decimal, octal and hexadecimal formats.
Construct literal String values using quoted format.
Construct a literal value of char type using Java's unicode escape format for a specified character code.

Operators and Assignments

Determine the result of applying any operator (including assignment operators and instance of) to operands of any type class scope or accessibility or any combination of these.
Applying the '>>', '>>>' and '<<' operators to an int value specified as a bit pattern.
The + operator
Using the '==' comparison operator with two objects of any type.
Using the ternary operator.
When assignment is permitted between any two variables of possibly different types.
Effect of assignment and modification operations upon variables .
Determine the result of applying the boolean equals() (Object) method to objects of any combination of the classes java.lang.String, java.lang.Boolean, and java.lang.Object.
In an expression involving the operators &, |, && and ||, state which operands are evaluated and determine the resulting value of the expression.
Determine the effect upon objects and primitive values of passing variables into methods and performing assignments or other modifying operations in that method.

Overloading, Overriding, Runtime Type, and Object Orientation

State the benefits of encapsulation in object oriented design and write code that implements tightly encapsulated classes and the relationships "is a" and "has a".
Write classes that implement object oriented relationships specified using the clauses 'is a' and 'has a'.
Determine at run time if an object is an instance of a specified class or some subclass of that class using the instanceof operator.
Write code to invoke overridden or overloaded methods and parental or overloaded constructors; and describe the effect of invoking these methods.
Overloaded and overridden methods.
Legal return types for an overloading method
State legal return types for an overriding method given the original method declaration.
Invoking overridden method in base and derived classes.
Write code for any overridden method that invokes the parental method, using super.
Write code to construct instances of any concrete class including normal top level classes and nested classes.
Creating constructors which use this() and super() to access overloaded or parent-class constructors.


Write code to define, instantiate and start new threads using both java.lang.Thread and java.lang.Runnable.
Recognize conditions that might prevent a thread from executing.
Write code using synchronized wait, notify and notifyAll to protect against concurrent access problems and to communicate between threads.
Using the synchronized keyword to require a thread of execution to obtain an object lock prior to proceeding.
The wait() method.
The notify() or notifyAll() methods of an object.
Define the interaction among threads and object locks when executing synchronized wait, notify or notifyAll.

Fundamental classes in the java.lang package

Write code using the following methods of the java.lang.Math class: abs(), ceil(), floor(), max(), min(), random(), round(), sin(), cos(), tan(), sqrt().
Describe the significance of the immutability of String objects.
Describe the significance of wrapper classes, including making appropriate selections in the wrapper classes to suit specified behavior requirements, stating the result of executing a fragment of code that includes an instance of one of the wrapper classes, and writing code using the following methods of the wrapper classes (e.g., Integer, Double, etc.): doubleValue()floatValue()intValue()longValue()parseXxx()getXxx()toString()toHexString()

The Collections Framework

Make appropriate selection of collection classes/interfaces to suit specified behavior requirements.
Distinguish between correct and incorrect implementations of hashcode methods.

1.2 Exam Only: The java.awt package - Components and Facilities

Write code to demonstrate the use of the following methods of the java.awt.Component class: setVisible(boolean), setEnabled(boolean), getSize(), setForeground() and setBackground().
Construct a java.awt.TextArea or java.awt.List that prefers to display a specified number of columns.
Construct a java.awt.TextArea or java.awt.TextField that prefers to display a specified number of columns.
State the significance of a "column" where one of the text components is using a proportional (variable) pitch font or a fixed pitch font.

1.2 Exam Only: The java.awt package - Layout

Demonstrate the use of the methods add(Component) and add(String, Component) of the java.awt.Container class and recognize which classes in the java.awt and java.awt packages are valid arguments to these methods.
Distinguish between AWT classes which are directly responsible for determining component layout and those which are responsible for implementing that layout.
Write code to change the layout scheme associated with an AWT container.
Use BorderLayout, FlowLayout, and GridLayout to achieve required dynamic resizing behavior of a component.

1.2 Exam Only: The java.awt package - Event Handling

Write a non-abstract class that implements a specified Listener interface, given the interface definition.
Select methods from the classes in the java.awt.event package that identify the affected component, mouse position, nature, and time of the event.
Demonstrate correct uses of the Listener methods in the Component, TextArea, and TextField classes.
For any listener in the java.awt.event package, state the argument type and return type of a specified listener method, given the name of the interface that declares the method and the name of the method itself.

1.2 Exam Only: The package

Write code that uses objects of the file class to navigate a file system.
Write code that uses objects of the classes InputStreamReader and OutputStreamWriter to translate between Unicode and either platform default or ISO 8859-1 character encodings.
Destinguish between conditions under which platform default encoding conversion should be used and conditions under which a specific conversion should be used.
Select valid constructor arguments for FilterInputStream and FilterOutputStream subclasses from a list of classes in the
Write appropriate code to read, write and update files using FileInputStream, FileOutputStream, and RandomAccessFile objects.
Describe the permanent effects on the file system of constructing and using FileInputStream, FileOutputStream, and RandomAccessFile objects.

1.2 Exam Only: Miscellaneous

Write code to demonstrate the use of the following methods of the java.lang.String class: length(), toUpperCase(), toLowerCase(), equals(), equalsIgnoreCase(), charAt(), concat(), indexOf(), lastIndexOf(), substring(), toString(), trim().
State all operators that are legal in String expressions.

GNU Free Documentation License