SCJP Sun Certified Programmer for Java 5 Study Guide (Exam 310-055) (Certification Press)

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Get the book that shows you not only what to study, but how to study. The only classroom-based integrated study system for professional certification gives you complete coverage of all objectives for the Sun Certified Programmer for Java 5 exam, hundreds of practice exam questions, and hands-on exercises. The CD-ROM features full practice exam software plus an adaptive test engine.

Author(s): Katherine Sierra, Bert Bates
Edition: 1
Publisher: McGraw-Hill Osborne Media
Year: 2005

Language: English
Pages: 825

Contents......Page 15
About the Contributors......Page 11
Acknowledgments......Page 23
Preface......Page 25
Introduction......Page 27
1 Declarations and Access Control......Page 41
Java Refresher......Page 42
Identifiers & JavaBeans (Objectives 1.3 and 1.4)......Page 44
Legal Identifiers......Page 45
Sun's Java Code Conventions......Page 46
JavaBeans Standards......Page 48
Declare Classes (Exam Objective 1.1)......Page 50
Source File Declaration Rules......Page 51
Class Declarations and Modifiers......Page 52
Exercise 1-1: Creating an Abstract Superclass and Concrete Subclass......Page 58
Declaring an Interface......Page 59
Declaring Interface Constants......Page 62
Access Modifiers......Page 64
Nonaccess Member Modifiers......Page 79
Constructor Declarations......Page 87
Variable Declarations......Page 89
Declaring Enums......Page 100
Two-Minute Drill......Page 108
Q&A Self Test......Page 114
Self Test Answers......Page 117
2 Object Orientation......Page 121
Encapsulation (Exam Objective 5.1)......Page 122
Inheritance, Is-A, Has-A (Exam Objective 5.5)......Page 126
IS-A......Page 130
HAS-A......Page 132
Polymorphism (Exam Objective 5.2)......Page 134
Overridden Methods......Page 139
Overloaded Methods......Page 145
Reference Variable Casting (Objective 5.2)......Page 152
Implementing an Interface (Exam Objective 1.2)......Page 156
Return Type Declarations......Page 162
Returning a Value......Page 164
Constructors and Instantiation (Exam Objectives 1.6 and 5.4)......Page 166
Determine Whether a Default Constructor Will Be Created......Page 171
Overloaded Constructors......Page 175
Static Variables and Methods......Page 181
Coupling and Cohesion (Exam Objective 5.1)......Page 187
Two-Minute Drill......Page 193
Q&A Self Test......Page 198
Self Test Answers......Page 204
3 Assignments......Page 213
Stack and Heap—Quick Review......Page 214
Literal Values for All Primitive Types......Page 216
Assignment Operators......Page 220
Exercise 3-1: Casting Primitives......Page 225
Using a Variable or Array Element That Is Uninitialized and Unassigned......Page 233
Local (Stack, Automatic) Primitives and Objects......Page 237
Passing Object Reference Variables......Page 243
Does Java Use Pass-By-Value Semantics?......Page 244
Passing Primitive Variables......Page 245
Declaring an Array......Page 249
Constructing an Array......Page 250
Initializing an Array......Page 254
Initialization Blocks......Page 264
Using Wrapper Classes and Boxing (Exam Objective 3.1)......Page 267
An Overview of the Wrapper Classes......Page 268
Creating Wrapper Objects......Page 269
Using Wrapper Conversion Utilities......Page 270
Autoboxing......Page 274
Overloading (Exam Objectives 1.5 and 5.4)......Page 277
Overview of Memory Management and Garbage Collection......Page 284
Overview of Java's Garbage Collector......Page 285
Writing Code That Explicitly Makes Objects Eligible for Collection......Page 287
Exercise 3-2: GC Analysis......Page 292
Two-Minute Drill......Page 295
Q&A Self Test......Page 299
Self Test Answers......Page 306
4 Operators......Page 315
Assignment Operators......Page 316
Relational Operators......Page 318
instanceof Comparison......Page 323
Arithmetic Operators......Page 326
Conditional Operator......Page 332
Logical Operators......Page 333
Two-Minute Drill......Page 339
Q&A Self Test......Page 341
Self Test Answers......Page 347
5 Flow Control, Exceptions, and Assertions......Page 355
if and switch Statements (Exam Objective 2.1)......Page 356
if-else Branching......Page 357
switch Statements......Page 362
Exercise 5-1: Creating a switch-case Statement......Page 370
Using while Loops......Page 371
Using do Loops......Page 372
Using for Loops......Page 373
Using break and continue......Page 380
Unlabeled Statements......Page 381
Labeled Statements......Page 382
Handling Exceptions (Exam Objectives 2.4 and 2.5)......Page 384
Catching an Exception Using try and catch......Page 385
Using finally......Page 387
Propagating Uncaught Exceptions......Page 390
Exercise 5-3: Propagating and Catching an Exception......Page 392
Defining Exceptions......Page 393
Exception Hierarchy......Page 394
Handling an Entire Class Hierarchy of Exceptions......Page 396
Exception Matching......Page 397
Exception Declaration and the Public Interface......Page 399
Rethrowing the Same Exception......Page 404
Exercise 5-4: Creating an Exception......Page 405
Common Exceptions and Errors (Exam Objective 2.6)......Page 406
Working with the Assertion Mechanism (Exam Objective 2.3)......Page 411
Assertions Overview......Page 412
Enabling Assertions......Page 415
Using Assertions Appropriately......Page 420
Two-Minute Drill......Page 425
Q&A Self Test......Page 429
Self Test Answers......Page 439
6 Strings, I/O, Formatting, and Parsing......Page 451
The String Class......Page 452
Important Facts About Strings and Memory......Page 459
Important Methods in the String Class......Page 460
The StringBuffer and StringBuilder Classes......Page 464
Important Methods in the StringBuffer and StringBuilder Classes......Page 466
File Navigation and I/O (Exam Objective 3.2)......Page 469
Serialization (Exam Objective 3.3)......Page 483
Dates, Numbers, and Currency (Exam Objective 3.4)......Page 497
Working with Dates, Numbers, and Currencies......Page 498
Parsing, Tokenizing, and Formatting (Exam Objective 3.5)......Page 511
A Search Tutorial......Page 512
Locating Data via Pattern Matching......Page 522
Tokenizing......Page 525
Formatting with printf() and format()......Page 529
Two-Minute Drill......Page 534
Q&A Self Test......Page 538
Self Test Answers......Page 548
7 Generics and Collections......Page 561
Overriding hashCode() and equals() (Objective 6.2)......Page 562
Overriding equals()......Page 564
Overriding hashCode()......Page 569
So What Do You Do with a Collection?......Page 576
Using the Collections Framework (Objective 6.5)......Page 586
ArrayList Basics......Page 587
Sorting Collections and Arrays......Page 588
Generic Types (Objectives 6.3 and 6.4)......Page 610
Generics and Legacy Code......Page 615
Mixing Generic and Non-generic Collections......Page 616
Polymorphism and Generics......Page 622
Generic Methods......Page 624
Generic Declarations......Page 637
Two-Minute Drill......Page 646
Q&A Self Test......Page 651
Self Test Answers......Page 662
8 Inner Classes......Page 675
Inner Classes......Page 677
Coding a "Regular" Inner Class......Page 678
Referencing the Inner or Outer Instance from Within the Inner Class......Page 682
Method-Local Inner Classes......Page 684
What a Method-Local Inner Object Can and Can't Do......Page 685
Plain-Old Anonymous Inner Classes, Flavor One......Page 687
Plain-Old Anonymous Inner Classes, Flavor Two......Page 691
Argument-Defined Anonymous Inner Class......Page 692
Static Nested Classes......Page 694
Instantiating and Using Static Nested Classes......Page 695
Two-Minute Drill......Page 697
Q&A Self Test......Page 699
Self Test Answers......Page 705
9 Threads......Page 713
Defining, Instantiating, and Starting Threads (Exam Objective 4.1)......Page 714
Defining a Thread......Page 717
Instantiating a Thread......Page 718
Starting a Thread......Page 721
Thread States......Page 730
Preventing Thread Execution......Page 732
Sleeping......Page 733
Exercise 9-1: Creating a Thread and Putting It to Sleep......Page 735
Thread Priorities and yield()......Page 736
Synchronizing Code (Exam Objective 4.3)......Page 740
Synchronization and Locks......Page 747
Exercise 9-2: Synchronizing a Block of Code......Page 750
Thread Deadlock......Page 757
Thread Interaction (Exam Objective 4.4)......Page 758
Using notifyAll() When Many Threads May Be Waiting......Page 764
Two-Minute Drill......Page 770
Q&A Self Test......Page 773
Self Test Answers......Page 784
Exercise Answers......Page 798
10 Development......Page 799
Compiling with javac......Page 800
Launching Applications with Java......Page 803
Searching for Other Classes......Page 806
JAR Files (Exam Objective 7.5)......Page 812
JAR Files and Searching......Page 813
Static Imports......Page 816
Two-Minute Drill......Page 819
Q&A Self Test......Page 821
Self Test Answers......Page 829
A: About the CD......Page 839
Master Exam......Page 840
LearnKey Technical Support......Page 841
A......Page 843
B......Page 845
C......Page 846
D......Page 848
E......Page 850
G......Page 851
I......Page 852
L......Page 854
M......Page 855
N......Page 856
O......Page 857
P......Page 858
R......Page 859
S......Page 860
T......Page 863
U......Page 864
Y......Page 865