0% found this document useful (0 votes)
62 views

Sun Certified Programmer For Java 2 Study Guide Tables and Figures

This document contains various tables and figures related to Java programming concepts for the Sun Certified Programmer for Java 2 certification. It includes tables on inheritance hierarchies, modifiers and access modifiers for classes, variables, methods and constructors, default values for array elements, Java primitive data types, escape sequences, class member accessibility, and Java operators.

Uploaded by

Yeri Yezyan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Sun Certified Programmer For Java 2 Study Guide Tables and Figures

This document contains various tables and figures related to Java programming concepts for the Sun Certified Programmer for Java 2 certification. It includes tables on inheritance hierarchies, modifiers and access modifiers for classes, variables, methods and constructors, default values for array elements, Java primitive data types, escape sequences, class member accessibility, and Java operators.

Uploaded by

Yeri Yezyan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

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

“Car extends Vehicle” means “Car IS-A Vehicle.”


“Subaru extends Car” means “Subaru IS-A Car.”

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

Modifiers and Access Modifiers

Local Variables Variables (non-Local) Methods Classes

final
public
public
final protected
default
public private
protected static
final
private
static abstract
transient synchronized
Final
strictfp
native

Modifiers and Access Modifiers


Free-Floating
Modifier Class Variable Method Constructor Block
public yes yes yes yes no
protected no yes yes yes no
(default) yes yes yes yes yes
private no yes yes yes no
final yes yes yes no no
abstract yes no yes no no
static no yes yes no yes
native no no yes no no
transient no yes no no no
volatile no yes no no no
synchronized no no yes no yes

JCTV 9 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures

Default Values for Array Elements


Array Type Default Value
byte 0
char '\u0000'
short 0
int 0
long 0L
float 0.0F
double 0.0
Boolean false
Object reference null

Java Primitive Data Types


Type Contains Default Size Min/Max Value
boolean true or false false 1 bit N.A.
N.A.
char Unicode character \u0000 16 bits, two’s complement \u0000
\uFFFF
byte signed integer 0 8 bits, two’s complement
-27 Æ 27 -1

short signed integer 0 16 bits, two’s complement


-215 Æ 215 -1

int signed integer 0 32 bits, two’s complement


-231 Æ 231 -1

long signed integer 0 64 bits, two’s complement


-263 Æ 263 -1

float floating-point 0.0 32 bits, IEEE 754 +/-1.40239846E-45


+/-3.40282347E+38
double floating-point 0.0 64 bits, IEEE 754 +/-4.94065645841246544E-324
+/-1.79769313486231570E+308

Java Escape Sequences


Escape Sequence Unicode Equivalent Meaning
\b \u0008 Backspace
\t \u0009 Horizontal tab
\n \u000a Linefeed
\f \u000c Form feed
\r \u000d Carriage return
\" \u0022 Double quote
\' \u0027 Single quote
\\ \u005c Backslash
\xxx \u0000 to \u00ff The character corresponding to the octal value xxx

JCTV 10 3/12/2007
Sun Certified Programmer for Java 2 Study Guide Tables and Figures

Class Member Accessibility


Member Visibility
Modifier
same class same package subclass Universe
private yes
default yes yes
protected yes yes yes
public yes yes yes yes

Class Member Accessibility


Member Visibility
Accessible to:
public protected package o private
default
Same class yes yes yes yes
Class in same package yes yes yes
Subclass in same package yes yes yes
Subclass in different package yes yes
Non-subclass, different package yes

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

Legal Conversions Between Numeric Types


char

byte short int long

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

You might also like