copyright © 2003 prosofttraining. all rights reserved. sun certified java programmer exam...
TRANSCRIPT
Copyright © 2003 ProsoftTraining. All rights reserved.
Sun Certified Java Programmer Exam Preparation Guide
Copyright © 2003 ProsoftTraining. All rights reserved.
Lesson 1:Java Language Fundamentals
Objectives
• Identify correctly constructed source files, package declarations, import statements, class declarations, interface declarations and implementations, method declarations, variable declarations and identifiers
• State the correspondence between index values in the argument array passed to a main method and command-line arguments
• Identify all Java programming language keywords and correctly constructed identifiers
Objectives (cont’d)
• 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 data types• State the behavior that is guaranteed by the
garbage collection system• Write code using methods of the java.lang.Math class
JavaSource Files
• Java package and import statements• class
Keywords
• Creating identifiers
PrimitiveData Types
• Eight types– boolean, char, byte, short, int, long, float, double
• Literals– Boolean– Character– Integral– Floating-point– String
The Javamain Method
• Must be defined within a class• Must be defined as follows
Public static void main(String [] args)
VariableInitialization
• Member variables• Method local variables
TheMath Class
• Math class methods
GarbageCollection
• Frees previously allocated heap space that is no longer needed
• Helps prevent most memory leaks
Summary
Identify correctly constructed source files, package declarations, import statements, class declarations, interface declarations and implementations, method declarations, variable declarations and identifiers
State the correspondence between index values in the argument array passed to a main method and command-line arguments
Identify all Java programming language keywords and correctly constructed identifiers
Summary (cont’d)
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 data types State the behavior that is guaranteed by the
garbage collection system Write code using methods of the java.lang.Math class
Copyright © 2003 ProsoftTraining. All rights reserved.
Lesson 2:Java Modifiers
Objectives
• Declare classes, inner classes, methods, instance variables, static variables, and automatic variables making appropriate use of all permitted modifiers. 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
Introductionto Java Modifiers
• Access modifiers• Other modifiers
Classes
• Abstract classes• Final classes
Methods
• Abstract methods• Final methods• Native methods• Static methods• Synchronized methods
Variables
• Final variables• Static variables• Transient variables• Volatile variables
StaticInitializers
• Free-floating blocks of code that are executed at the time a class is loaded
Summary
Declare classes, inner classes, methods, instance variables, static variables, and automatic variables making appropriate use of all permitted modifiers. 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
Copyright © 2003 ProsoftTraining. All rights reserved.
Lesson 3:Flow Control
in Java
Objectives
• Write code using if and switch statements• Write code using all forms of loops, and state
the values taken by loop control variables during and after loop execution
• Write code that makes proper use of exceptions and exception handling clauses, and declare methods and overriding methods that throw exceptions
Thewhile Loop
• Simplest type of loop• Executes a statement or code block
continuously until some Boolean expression evaluates as false
Thedo Loop
• Special form of the while loop• Guaranteed to execute at least once
Thefor Loop
• Allows you to initialize a variable and perform some iterative arithmetic on that variable, executing a loop until some Boolean condition evaluates to false
• Comma separators
Thecontinue Statement
• Ends the current iteration of a loop and continues execution at the top of the loop
The breakStatement
• Used to exit a loop prematurely
The if / elseStatement
• Permits execution of a statement or code block only if some Boolean expression is true
The switchStatement
• Uses an integer value to select between multiple alternative threads of execution
Exceptions
• Errors• Runtime exceptions• Checked exceptions
Java ExceptionClass Hierarchy
Throwable
Exception Error
RuntimeException
ThrowingExceptions
• throws statement
CatchingExceptions
• try/catch block• Using multiple catch statements• Rethrowing exceptions• finally block
Summary
Write code using if and switch statements Write code using all forms of loops, and state
the values taken by loop control variables during and after loop execution
Write code that makes proper use of exceptions and exception handling clauses, and declare methods and overriding methods that throw exceptions
Copyright © 2003 ProsoftTraining. All rights reserved.
Lesson 4:Operators
and Assignments
Objectives
• Determine the result of applying any operator, to operands of any type, class, scope or accessibility, or any combination of these
• 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
Objectives (cont'd)
• In an expression involving the operators &, |, &&, || and variables of known values, state which operands are evaluated and the 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
Introductionto Expressions
• Operators• Operator precedence
UnaryOperators
• The increment (++) and decrement (--) operators
• The plus (+) and minus (-) operators• The Boolean complement operator (!)• The bitwise inversion operator (~)• The cast operator
ArithmeticOperators
• The multiplication (*) and division (/) operators• The modulus operator (%)• The addition (+) and subtraction (-) operators
BinaryShift Operators
• The left-shift operator (<<)• The right-shift operator (>>)• The unsigned right-shift operator (>>>)• The right operand
ComparisonOperators
• The equals method• The instanceof operator• Bitwise operators• The and operator (&)• The or operator (|)• The exclusive-or operator (^)
Short-CircuitOperators
• Similar to bitwise operators• Only applied to Boolean operands• Always generate a Boolean result
TernaryOperator
• Requires three operands
AssignmentOperators
• Methods and assignments
Summary
Determine the result of applying any operator, to operands of any type, class, scope or accessibility, or any combination of these
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
Summary (cont'd)
In an expression involving the operators &, |, &&, || and variables of known values, state which operands are evaluated and the 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
Copyright © 2003 ProsoftTraining. All rights reserved.
Lesson 5:Object Orientation
Objectives
• State the benefits of encapsulation in object-oriented design, and write code that implements tightly encapsulated classes and the "is a" and "has a" relationships
• Write code to invoke overridden or overloaded methods and parental or overloaded constructors
• Write code to construct instances of any concrete class
Objectives (cont'd)
• State the legal return types for any method given the declarations of all related methods in this or parent classes
• Write code that declares, constructs and initializes arrays of any base type using any of the permitted forms for both declaration and initialization
• For a given class, determine whether a default constructor will be created, and state the prototype of that constructor
Encapsulation
• Accessors• Mutators• Encapsulation
Encapsulationof the Book Class
getTitle
getAuthor
getIS
BN
titleauthor
isbn
Abstraction
• The process of developing classes in terms of their– Interfaces– Functionality
• Used to manage complexity
MethodOverloading and Overriding
• Overloading– Defining several methods with the same
name within a single class• Overriding
– Refining the functionality of a subclass by modifying a class method under certain circumstances
• The super keyword
Constructors
• Instantiating a class• The this keyword• Constructors and inheritance• The super keyword and constructors
InnerClasses
• Member inner classes– Member access
• Static inner classes• Method inner classes• Anonymous inner classes
Arrays
• Array declarations• Constructing arrays• Initializing arrays
Summary
State the benefits of encapsulation in object-oriented design, and write code that implements tightly encapsulated classes and the "is a" and "has a" relationships
Write code to invoke overridden or overloaded methods and parental or overloaded constructors
Write code to construct instances of any concrete class
Summary (cont'd)
State the legal return types for any method given the declarations of all related methods in this or parent classes
Write code that declares, constructs and initializes arrays of any base type using any of the permitted forms for both declaration and initialization
For a given class, determine whether a default constructor will be created, and state the prototype of that constructor
Copyright © 2003 ProsoftTraining. All rights reserved.
Lesson 6:Threads
Objectives
• 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
Objectives (cont'd)
• Write code using synchronized, wait, notify and notifyAll to protect against concurrent access problems and to communicate between threads. Define the interaction between threads, and between threads and object locks
• Identify correctly constructed source files, package declarations, import statements, class declarations, interface declarations and implementations, method declarations, variable declarations and identifiers
CreatingThreads
• Extending the Thread class• Implementing the Runnable interface
ThreadStates
• Setting thread priority• Yielding threads• The suspended state• The sleeping state• The blocked state
LiveThread States
Running
Ready
Suspended Sleeping Blocked
ThreadSynchronization
• Controlling the flow of multiple simultaneous threads
• The synchronized keyword• Monitors• Synchronized code blocks• The wait, notify and notifyAll methods• Deadlock
Deadlock
Summary
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
Summary (cont'd)
Write code using synchronized, wait, notify and notifyAll to protect against concurrent access problems and to communicate between threads. Define the interaction between threads, and between threads and object locks
Identify correctly constructed source files, package declarations, import statements, class declarations, interface declarations and implementations, method declarations, variable declarations and identifiers
Copyright © 2003 ProsoftTraining. All rights reserved.
Lesson 7:The java.awt Package
Objectives
• Write code using component, container and layout manager classes of the java.awt package to present a GUI with specified appearance and resize behavior, and distinguish the responsibilities of layout managers from those of containers
• Write code to implement listener classes and methods; in listener methods, extract information from the event to determine the affected component, mouse position, nature and time of the event
LayoutManagers
• Flow layout manager• Border layout manager• Grid layout manager• Card layout manager• GridBag layout manager
Events
• Event classes• Event listeners• Event enabling
Summary
Write code using component, container and layout manager classes of the java.awt package to present a GUI with specified appearance and resize behavior, and distinguish the responsibilities of layout managers from those of containers
Write code to implement listener classes and methods; in listener methods, extract information from the event to determine the affected component, mouse position, nature and time of the event
Copyright © 2003 ProsoftTraining. All rights reserved.
Lesson 8:The Collections API
Objective
• Make appropriate selection of collection classes/interfaces to suit specified behavior requirements
Introductionto Collections
• Simple collections– Vectors– Hash tables
• Types of collections– Collection– List– Set– Map
TheCollections API
• Java application programming interface that provides an extensible framework for creating data structures
• Using the Collections API
Summary
Make appropriate selection of collection classes/interfaces to suit specified behavior requirements
Sun Certified Java Programmer Exam Preparation Guide
Java Language Fundamentals Java Modifiers Flow Control in Java Operators and Assignments Object Orientation Threads The java.awt Package The Collections API