Sun Certified Programmer For Java 2 Study Guide Tables and Figures
Sun Certified Programmer For Java 2 Study Guide Tables and Figures
JCTV 1 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
JCTV 2 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
JCTV 3 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
JCTV 4 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
JCTV 5 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
JCTV 6 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
JCTV 7 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
JCTV 8 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
final
public
public
final protected
default
public private
protected static
final
private
static abstract
transient synchronized
Final
strictfp
native
JCTV 9 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
JCTV 10 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
JCTV 11 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
Java Operators
Prec. Operator Operand Type(s) Assoc. Operation Performed
1 ++ arithmetic Å pre-or-post increment (unary)
-- arithmetic Å pre-or-post decrement (unary)
+, - arithmetic Å unary plus, unary minus
~ integral Å bitwise complement (unary)
! boolean Å logical complement (unary)
(type) any Å cast
2 *, /, % arithmetic Æ multiplication, division, remainder
3 +, - arithmetic Æ addition, subtraction
+ string Æ string concatenation
4 << integral Æ left shift
>> integral Æ right shift with sign extension
>>> integral Æ right shift with zero extension
5 <, <= arithmetic Æ less than, less than or equal
>, >= arithmetic Æ greater than, greater than or equal
instanceof object, type Æ type comparison
6 == primitive Æ equal (have identical values)
!= primitive Æ not equal (have different values)
== object Æ equal (refer to same object)
!= object Æ not equal (refer to different objects)
7 & integral Æ bitwise AND
& boolean Æ boolean AND
8 ^ integral Æ bitwise XOR
^ boolean Æ boolean XOR
9 | integral Æ bitwise OR
| boolean Æ boolean OR
10 && boolean Æ conditional AND
11 || boolean Æ conditional OR
12 ?: boolean, any, any Å conditional (ternary) operator
13 = variable, any Å assignment
*=, /=, %=, +=, -=,
<<=, >>=, >>>=, &=, variable, any Å assignment with operation
^=, |=
JCTV 12 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
Java Modifiers
Modifier Used On Meaning
The class contains unimplemented methods and cannot be
class
instantiated.
All interfaces are abstract. The modifier is optional in interface
abstract interface
declarations.
No body is provided for the method (it is provided by a subclass).
method The signature is followed by a semicolon. The enclosing class
must also be abstract.
class The class may not be subclassed.
The field may not have its value changed (compiler may
field
precompute expressions).
final
method The method may not be overridden (compiler may optimize).
Java 1.1 and later: the local variable or method or exception
variable
parameter may not have its value changed.
The method is implemented in C, or in some other platform-
native method dependent way. No body is provided; the signature is followed by a
semicolon.
class A non-public class is accessible only in its package
none (package) interface A non-public interface is accessible only in its package
A member that is not private, protected, or public has package
member
visiblity and is accessible only within its package.
private member The member is only accessible within the class that defines it.
The member is only accessible within the package in which it is
protected member
defined, and within subclasses.
class The class is accessible anywhere its package is.
public interface The interface is accessible anywhere its package is.
member The member is accessible anywhere its class is.
In Java 1.1, a class delared static is a toplevel class, not an inner
class
class.
A static field is a "class field." There is only one instance of the
field field, regardless of the number of class instances created. It may
static be accessed through the class name.
The intializer is run when the class is loaded, rather than when an
initializer
instance is created.
A static method is a "class method." It is not passed as an implicit
method
this object reference. It may be invoked through the class name.
The method makes non-atomic modifications to the class or
instance, and care must be taken to ensure that two threads
cannot modify the class or instance at the same time. For a static
synchronized method
method, a lock for the class is acquired before executing the
method. For a non-static method, a lock for the specific object
instance is acquired.
The field is not part of the persistent state of the object, and should
transient field
not be serialized with the object.
The field may be accessed by unsynchronized threads, so certain
volatile field
code optimizations must not be performed on it.
JCTV 13 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures
float double
Strings
Consider this table showing two situations using the == operator and equals():
s1 == s2 s1.equals(s2)
String s1 = “Java”;
A true true
String s2 = “Java”;
String s = “Ja”;
B String s1 = s + “va”; false true
String s2 = “Java”;
• In situation A, the evaluation will always return true, since there is only one String
object created (s1 and s2 are both pointing to the same one).
• To avoid the above situation, use the new keyword so that s1 and s2 are created as
different objects.
• In situation B, s1 and s2 are pointing to different objects, because s1 is created at
runtime.
JCTV 14 3/12/2007