Cover image for A programmer's guide to java SCJP certification : a comprehensive primer
A programmer's guide to java SCJP certification : a comprehensive primer
Personal Author:
3rd ed.
Publication Information:
Upper Saddle River, NJ : Pearson Education, 2009
Physical Description:
xlvi, 1039 p. : ill. ; 24 cm.
Added Author:


Item Barcode
Call Number
Material Type
30000010202645 QA76.3 M83 2009 Open Access Book

On Order



This book will help you prepare for and pass the Sun Certified Programmer for the Java Platform SE 6 (CX-310-065) Exam. It is written for any experienced programmer (with or without previous knowledge of Java) interested in mastering the Java programming language and passing the SCJP 1.6 Exam.

A Programmer's Guide to Java(tm) SCJP Certification, Third Edition, provides detailed coverage of all exam topics and objectives, readily runnable code examples, programming exercises, extensive review questions, and a new mock exam. In addition, as a comprehensive primer to the Java programming language, this book is an invaluable reference tool.

This new edition has been thoroughly updated to focus on the latest version of the exam (CX-310-065). In particular, it contains in-depth explanations of the language features. Their usage is illustrated by way of code scenarios, as required by the exam. The companion Web site ( ) contains a version of the SCJP 1.6 Exam Simulator developed by the authors. The site also contains the complete source code for all the book's examples, as well as solutions to the programming exercises.

What you will find in this book:

Extensive coverage of all the objectives defined for the Sun Certified Programmer for the Java Platform, Standard Edition 6 (CX-310-065) Exam An easy-to-follow structure with chapters organized according to the exam objectives, as laid out by Sun Microsystems Summaries that clearly state and differentiate the exam objectives and the supplementary objectives to be covered in each chapter A list of Sun's objectives for the SCJP 1.6 Exam and a guide to taking the exam A complete mock exam with new questions (not repeats of review questions) Numerous exam-relevant review questions to test your understanding of each major topic, with annotated answers Programming exercises and solutions at the end of each chapter Copious code examples illustrating concepts, where the code has been compiled and thoroughly tested on multiple platforms Program output demonstrating expected results from running the examples Extensive use of UML (Unified Modeling Language) for illustration purposes An introduction to basic terminology and concepts in object-oriented programming Advice on how to avoid common pitfalls in mastering the language and taking the exam Platform- and tool-independent coverage Information about the SCJP 1.6 Upgrade (CX-310-066) Exam

Author Notes

Khalid A. Mughal is an Associate Professor at the Department of Informatics at the University of Bergen, Norway. Professor Mughal is responsible for designing and implementing various courses, which use Java, at the Department of Informatics. Over the years, he has taught Programming Languages (Java, C/C++, Pascal), Software Engineering (Object-Oriented System Development), Data bases (Data Modeling and Database Management Systems), and Compiler Techniques. He has also given numerous courses and seminars at various levels in object-oriented programming and system development, using Java and Javarelated technology, both at the University and for the IT industry. He is the principal author of the book, responsible for writing the material covering the Java topics.

Professor Mughal is also the principal author of an introductory Norwegian textbook on programming in Java ( Java som første programmeringsspråk/Java as First Programming Language, Third Edition, Cappelen Akademisk Forlag, ISBN-10: 82-02-24554-0, 2006), which he co-authored with Torill Hamre and Rolf W. Rasmussen. Together they have also published another textbook for a 2-semester course in programming ( Java Actually: A Comprehensive Primer in Programming, Cengage Learning, ISBN-10: 1844809331, 2008).

His current work involves applying Object Technology in the development of content management systems for publication on the Web, and security issues related to web applications. For the past seven years he has been responsible for developing and running web-based programming courses in Java, which are offered to offcampus students.

He is also a member of the Association for Computing Machinery (ACM).

Rolf W. Rasmussen is the System Development Manager at vizrt, a company that develops solutions for the TV broadcast industry, including real-time 3D graphic renderers, and content and control systems.

Rasmussen works mainly on control and automation systems, video processing, typography, and real-time visualization. He has worked on clean room implementations of the Java class libraries in the past, and is a contributor to the Free Software Foundation.

Over the years, Rasmussen has worked both academically and professionally with numerous programming languages, including Java. He is primarily responsible for developing the review questions and answers, the programming exercises and their solutions, the mock exam, and all the practical aspects related to taking the SCJP exam presented in this book.

As mentioned above, he is also a co-author of two introductory textbooks on programming in Java.



Foreword Consider the following observations: Software continues to become ever more pervasive, ever more ubiquitous in our lives. Incompetence seems to be the only thing we can count on in today's world and, especially, in the domain of software. The Java programming language has become a lingua franca for programmers all over the world. One can draw varied conclusions from these comments. One of them is that it is of great importance that programmers working with the Java programming language should be as competent as possible. The Java certification program is an important effort aimed at precisely this goal. Practitioners looking to obtain such certification need good quality training materials, which brings us to this book. Programming is still more of an art than a science, and will continue to be so for the foreseeable future. Mastering the intricacies of a large and complex programming language is a challenging task that requires time and effort, and above all experience. Real programming requires more than just mastery of a programming language. It requires mastery of a computing platform, with a rich set of libraries. These libraries are designed to simplify the task of building realistic applications, and they do. Again, the practitioner is faced with a daunting task. To address the clear need for professional training material, a plethora of books have been written purporting to tutor programmers in the programming language and platform skills they require. The choice is as mind boggling as the material within the books themselves. Should one try Java forFrontally Lobotomized Simians or Postmodern Java Dialectics? The readership for these books is largely self selecting. I trust that if you, the reader, have gotten this far, you are looking for something that is intelligent, yet practical. This book is one of the finest efforts in this crowded arena. It brings a necessary level of academic rigor to an area much in need of it, while retaining an essentially pragmatic flavor. The material in this book is probably all you need to pass the Java certification exam. It certainly isn't all you need to be a good software engineer. You must continue learning about new technologies. The hardest part of this is dealing with things that are completely different from what you are familiar with. Yet this is what distinguishes the top flight engineer from the mediocre one. Keep an open mind; it pays. Gilad Bracha Computational Theologist Sun Java Software (c) Copyright Pearson Education. All rights reserved. Excerpted from A Programmer's Guide to Java SCJP Certification: A Comprehensive Primer by Khalid Mughal, Rolf Rasmussen All rights reserved by the original copyright owners. Excerpts are provided for display purposes only and may not be reproduced, reprinted or distributed without the written permission of the publisher.

Table of Contents

List of Figures ?p. xxiii
List of Tables ?p. xxvii
List of Examples ?p. xxix
Foreword ?p. xxxv
Preface ?p. xxxvii
Chapter 1 Basics of Java Programmingp. 1
1.1 Introductionp. 2
1.2 Classesp. 2
1.3 Objectsp. 4
1.4 Instance Membersp. 6
1.5 Static Membersp. 7
1.6 Inheritancep. 10
1.7 Aggregationp. 12
1.8 Tenets of Javap. 13
1.9 Java Programsp. 15
1.10 Sample Java Applicationp. 15
Chapter 2 Language Fundamentalsp. 19
2.1 Basic Language Elementsp. 20
2.2 Primitive Data Typesp. 28
2.3 Variable Declarationsp. 31
2.4 Initial Values for Variablesp. 33
Chapter Summaryp. 37
Programming Exercisep. 37
Chapter 3 Declarationsp. 39
3.1 Class Declarationsp. 40
3.2 JavaBeans Standardp. 41
3.3 Method Declarationsp. 44
3.4 Constructorsp. 48
3.5 Enumerated Typesp. 54
3.6 Arraysp. 69
3.7 Parameter Passingp. 81
3.8 Variable Arity Methodsp. 90
Chapter Summaryp. 100
Programming Exercisesp. 101
Chapter 4 Access Controlp. 103
4.1 Java Source File Structurep. 104
4.2 Packagesp. 105
4.3 Searching for Classesp. 117
4.4 The JAR Utilityp. 120
4.5 System Propertiesp. 122
4.6 Scope Rulesp. 129
4.7 Accessibility Modifiers for Top-Level Type Declarationsp. 132
4.8 Other Modifiers for Classesp. 135
4.9 Member Accessibility Modifiersp. 138
4.10 Other Modifiers for Membersp. 146
Chapter Summaryp. 157
Programming Exercisep. 157
Chapter 5 Operators and Expressionsp. 159
5.1 Conversionsp. 160
5.2 Type Conversion Contextsp. 163
5.3 Precedence and Associativity Rules for Operatorsp. 166
5.4 Evaluation Order of Operandsp. 168
5.5 The Simple Assignment Operator =p. 169
5.6 Arithmetic Operators: *, /, %, +, -p. 174
5.7 The Binary String Concatenation Operator +p. 185
5.8 Variable Increment and Decrement Operators: ++, --p. 186
5.9 Boolean Expressionsp. 190
5.10 Relational Operators: , > =p. 190
5.11 Equalityp. 191
5.12 Boolean Logical Operators: !, ^, &p. 194
5.13 Conditional Operators: &p. 196
5.14 The Conditional Operator:?:p. 201
5.15 Other Operators: new, [], instanceofp. 201
Chapter Summaryp. 202
Programming Exercisep. 202
Chapter 6 Control Flowp. 203
6.1 Overview of Control Flow Statementsp. 204
6.2 Selection Statementsp. 204
6.3 Iteration Statementsp. 216
6.4 Transfer Statementsp. 223
6.5 Stack-Based Execution and Exception Propagationp. 235
6.6 Exception Typesp. 239
6.7 Exception Handling: try, catch, and finallyp. 245
6.8 The throw Statementp. 255
6.9 The throws Clausep. 257
6.10 Assertionsp. 265
Chapter Summaryp. 279
Programming Exercisesp. 279
Chapter 7 Object-Oriented Programmingp. 283
7.1 Single Implementation Inheritancep. 284
7.2 Overriding Methodsp. 288
7.3 Hiding Membersp. 294
7.4 The Object Reference superp. 295
7.5 Chaining Constructors Using this() and super()p. 302
7.6 Interfacesp. 309
7.7 Arrays and Subtypingp. 317
7.8 Reference Values and Conversionsp. 319
7.9 Reference Value Assignment Conversionsp. 320
7.10 Method Invocation Conversions Involving Referencesp. 323
7.11 Reference Casting and the instanceof Operatorp. 327
7.12 Polymorphism and Dynamic Method Lookupp. 340
7.13 Inheritance Versus Aggregationp. 342
7.14 Basic Concepts in Object-Oriented Design 345
Chapter Summaryp. 349
Programming Exercisesp. 349
Chapter 8 Nested Type Declarationsp. 351
8.1 Overview of Nested Type Declarationsp. 352
8.2 Static Member Typesp. 355
8.3 Non-Static Member Classesp. 359
8.4 Local C