CERTguide Sun Certified Java Programmer V1.4 Study Guide

What is Java?

n          high-level programming language

n          developed by Sun Microsystems

n          object-oriented

n          language is similar to C++ yet simplified

n          source code files with a .java extension

n          bytecode files with a .class extension

n          bytecode executed by a Java interpreter

n          “compiled” Java code can run on most computers

n          Java interpreters and runtime environments are known as Java Virtual Machines

n          small Java applications called Java applets can be downloaded from a Web server and run on your computer by a Java-compatible Web browser

It has been said that, to a certain extent, Java is the “no pointer” variant of C++. Pointer is the most troublesome part of programming.

 

What is the CJP Exam all about?

According to Sun:

“This certification is for programmers experienced in using the basic syntax and structure of the Java[tm] programming language. Certification is available for the Java 2 Platform. Certification consists of one exam.”

You have one exam to take. The exam consists of MC and Fill in the blank questions.

What Java version are we dealing with?

Sun Certified Programmer for the Java 2 Platform 1.4 (310-035). This exam will be available in August 2002.

You must have experience in Object Oriented programming! Java is heavily OO! If you are new to the world of programming, CJP may not be the right thing to go for.

Learning Java

Before you are ready to cram-study for the exam, go learn the language – make yourself a practical Java programmer. Below are the links that provide very good Java tutorials. Make sure you go through them in detail:

The Java Tutorial at http://java.sun.com/docs/books/tutorial/ :

New to Java Programming Center at http://developer.java.sun.com/developer/onlineTraining/new2java/

 

Practice coding! Download the Java SDK at http://java.sun.com/downloads.html !

Remember, the exam does not only test your memorization skill – it does test your real programming skills!

Types, Values, and Variables

Types

n          Java is strongly typed - strong typing helps detect errors at compile time.

n          every variable and every expression has a type that is known at compile time

n          Types:

u        limit the values that a variable can hold or that an expression can produce

u        limit the operations supported on values

u        determine the meaning of the operations

u        are divided into two categories: primitive types and reference types.

n          Primitive types:

u        boolean type and numeric types

u        numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double

n          Reference types:

u        class types

u        interface types

u        array types

n          values of a reference type are references to objects

n          all objects support the methods of class Object

n          String literals are represented by String objects

n          Names of types are used in:

u        declarations

u        casts

u        class instance creation expressions

u        array creation expressions

u        class literals

u        instanceof operator expressions.

Variable

n          a storage location in memory

n          variable of a primitive type always holds a value of that exact type

n          variable of a class type T can hold a null reference or a reference to an instance of class T or of any class that is a subclass of T

n          variable of an interface type can hold a null reference or a reference to any instance of any class that implements the interface

Conversions and Promotions

Conversion

n          "conversion" is used to describe the process of choosing a specific conversion for such a context

n          every expression written has a type that can be deduced from the structure of the expression and the types of the literals, variables, and methods mentioned

n          it is possible to write an expression in a context where the type of the expression is not appropriate

n          the context may be able to accept a type that is related to the type of the expression

n          the language can perform an implicit conversion from the type of the expression to a type acceptable for its surrounding context

n          conversion requirements

u        a specific conversion from type S to type T allows an expression of type S to be treated at compile time as if it had type T instead

u        a conversion from type Object to type Thread requires a run-time check to make sure that the run-time value is actually an instance of class Thread or one of its subclasses

u        a conversion from type Thread to type Object requires no run-time action

u        a conversion from type int to type long requires run-time sign-extension of a 32-bit integer value to the 64-bit long representation

u        a conversion from type double to type long requires a nontrivial translation from a 64-bit floating-point value to the 64-bit integer representation

n          specific conversions that are possible in the Java programming language are grouped into the following broad categories:

u        Identity conversions

u        Widening primitive conversions

u        Narrowing primitive conversions

u        Widening reference conversions

u        Narrowing reference conversions

u        String conversions

u        Value set conversions

n          Types of conversions

u        Assignment conversion converts the type of an expression to the type of a specified variable.

u        Method invocation conversion is applied to each argument in a method or constructor invocation – it never causes an exception.

u        Casting conversion converts the type of an expression to a type explicitly specified by a cast operator

u        String conversion allows any type to be converted to type String.

u        Numeric promotion brings the operands of a numeric operator to a common type

Make sure you memorize these:

n          Widening primitive conversions:

u        byte to short, int, long, float, or double

u        short to int, long, float, or double

u        char to int, long, float, or double

u        int to long, float, or double

u        long to float or double

u        float to double

n          Narrowing primitive conversions:

u        byte to char

u        short to byte or char

u        char to byte or short

u        int to byte, short, or char

u        long to byte, short, char, or int

u        float to byte, short, char, int, or long

u        double to byte, short, char, int, long, or float

 

Names

n          can be either simple or qualified:

u        simple names in programs consist of a single identifier

u        qualified name consists of a sequence of identifiers separated by "." tokens

n          used to refer to entities declared in a program

n          declared entity - a package, class type, interface type, member (class, interface, field, or method) of a reference type, parameter (to a method, constructor, or exception handler), or local variable.

n          Every declaration that introduces a name has a scope

u        scope - the part of the program text within which the declared entity can be referred to by a simple name.

n          Packages and reference types have members

u        a member can be referred to using a qualified name

n          to determine the meaning of a name, the context of the occurrence is used to disambiguate among the below items that are of the same name:

u        packages

u        types

u        variables

u        methods

n          access control:

u        can be specified in a class, interface, method, or field declaration to control when access to a member is allowed

u        access specifies the part of the program text within which the declared entity can be referred to

u        the default access is that a member can be accessed anywhere within the package that contains its declaration

n          names:

u        name of a field, parameter, or local variable may be used as an expression

u        name of a method may appear in an expression only as part of a method invocation expression

u        name of a class or interface type may appear in an expression only as part of a class literal, a qualified this expression, a class instance creation expression, an array creation expression, a cast expression, or an instanceof expression, or as part of a qualified name for a field or method.

u        name of a package may appear in an expression only as part of a qualified name for a class or interface type.

Packages

Package:

n          Programs are organized as sets of packages

u        a package can be stored in a file system or in a database

u        a package can be unnamed

u        a package can have a simple name

n          Each package has its own set of names for types

n          Each package can consist of a number of compilation units

n          Package helps to prevent name conflicts.

n          A top level type is accessible outside the package that declares it, only if the type is declared public.

n          The naming structure is hierarchical

n          Members of a package are class and interface types

n          class and interface types are declared in compilation units of the package

n          subpackages may contain compilation units and subpackages of their own

Compilation unit:

n          automatically has access to all types declared in its package

n          automatically imports all of the public types declared in the predefined package java.lang.

Classes

Class declarations:

n          define new reference types

n          describe how they are implemented

Nested class:

n          any class whose declaration occurs within the body of another class or interface

n          top level class is a class that is not a nested class

Named class:

n          may be declared abstract

n          must be declared abstract if it is incompletely implemented

n          a class may be declared final - it cannot have subclasses.

n          a class may be declared public - it can be referred to from other packages.

Class:

n          Each class except Object is an extension of a single existing class

n          Each class except Object may implement interfaces

n          The body of a class declares members

n          The scope of a member is the entire declaration of the class to which the member belongs.

n          Field, method, member class, member interface, and constructor declarations may include the access modifiers public, protected, or private.

n          Members of a class include both declared and inherited members

n          Newly declared fields can hide fields declared in a superclass or superinterface. Newly declared class members and interface members can hide class or interface members declared in a superclass or superinterface.

n          Newly declared methods can hide, implement, or override methods declared in a superclass or superinterface.

Field declarations:

n          describe class variables

n          a field may be declared final - it can be assigned to only once

n          any field declaration may include an initializer.

Member class declarations:

n          describe nested classes that are members of the surrounding class

n          Member classes may be static - they have no access to the instance variables of the surrounding class; or they may be inner classes

n          Member interface declarations describe nested interfaces that are members of the surrounding class.

n          Method declarations describe code that may be invoked by method invocation expressions

Methods

n          class method is invoked relative to the class type

n          an instance method is invoked with respect to some particular object that is an instance of the class type

n          method whose declaration does not indicate how it is implemented must be declared abstract

n          method may be declared final - it cannot be hidden or overridden

n          method may be implemented by platform dependent native code

n          synchronized method automatically locks an object before executing its body and automatically unlocks the object on return

n          method names may be overloaded

n          Initializers:

u        Instance initializers initialize an instance when it is created

u        Static initializers initialize a class when it is first loaded

n          Constructors:

u        initialize new class instances

u        may be overloaded

Interfaces

n          may be declared to be a direct extension of one or more other interfaces

n          interface declaration - introduces a new reference type whose members are:

u        classes

u        interfaces

u        constants

u        abstract methods

n          nested interface - any interface whose declaration occurs within the body of another class or interface

n          top-level interface - an interface that is not a nested interface.

n          class may be declared to directly implement one or more interfaces

n          multiple interface inheritance allows objects to support multiple common behaviors without sharing any implementation

n          variable whose declared type is an interface type may have as its value a reference to any instance of a class which implements the specified interface

 

Exceptions

n          When a program violates the semantic constraints of Java, the Java VM throws an exception:

u        an exception is said to be thrown from the point where it occurred

u        an exception is said to be caught at the point to which control is transferred

n          Java specifies that an exception will be thrown when semantic constraints are violated and will cause a non-local transfer of control from the point where the exception occurred to a point that can be specified by the programmer

n          Programs can throw exceptions explicitly using throw statements

n          Every exception is represented by an instance of the class Throwable or one of its subclasses

n          Handlers are established by catch clauses of try statements

n          Exception is integrated with Java synchronization model - locks are released as synchronized statements and invocations of synchronized methods complete abruptly.

Reference Books

Effective Java Programming Language Guide

by Joshua Bloch (Paperback)

http://www.amazon.com/exec/obidos/ASIN/0201310058/edsspace

Java How to Program (4th Edition)

by Harvey M. Deitel, Paul J. Deitel (Paperback)

http://www.amazon.com/exec/obidos/ASIN/0130341517/edsspace

Beginning Java 2 SDK 1.4 Edition

by Ivor Horton (Paperback - March 2002)

http://www.amazon.com/exec/obidos/ASIN/1861005695/edsspace

A Programmer's Guide to Java (tm) Certification

by Khalid Azim Mughal, Rolf Rasmussen (Paperback)

http://www.amazon.com/exec/obidos/ASIN/0201596148/edsspace

Java in a Nutshell (4th Edition)

by David Flanagan (Paperback - March 2002)

http://www.amazon.com/exec/obidos/ASIN/0596002831/edsspace

This study guide is developed by Michael Yu Chak Tin. He can be reached at Michael@examreview.net.

 

   
Join our mailing list
Name:
Email Address:
Choose a Newsletter(s):
Updates Newsletter
70-210 exam
70-215 exam
70-216 exam
70-217 exam
Network+ exam
CCNA exam
A+ Core exam
A+ OS exam
Linux+ exam
70-221 exam
Delivery Format:
Manage Subscriptions