Java Certification

» Home
» Publications
» Profile(CV)
» Contact

» Money
» Consulting

» Stock Tracker
» Java.SCJP
» Java.Links
» Oracle.OCA
» Oracle.OCP
» Linux.Certification
» Linux.Articles
» Process.Agile

» Microcontroller
» Album
» Dictionary
» Impressum



» Language Fundamentals: Part 2


 Objectives
You are going to be asked to answer questions in the exam regarding the following subjects. So be sure that you understand everything. After reading each article I suggest you write and compile small Java programs. I believe that practice is always better than theory. At the exam, you will be asked to address the following topics[2].
      Identifiers and Keywords
      Primitive Types
      Literals
      Arrays
      Variable Types and Initialization
If you have any questions after studying this document, do not hesitate to drop me an e-mail, and I will try to clarify things as best as I can. You can read more information about SCJP certification from the SJCP Web page [2], and you can download the .pdf file called "Sun Certified Programmer for Java 2 Platform Success Guide" [3].

 Identifiers and Keywords
Identifiers are used by programmers to give meaningful names used by the Java language to uniquely identify classes, methods, and variables. An identifier must begin with a letter, an underscore '_', or a dollar sign '$'. Subsequent characters can be any of these plus digits between 0 and 9. An identifier cannot begin with a digit; doing so will cause a compile-time exception. Identifiers are case sensitive and cannot have the same name as keywords or reserved words.
myInfo      // legal  
$myVariable // legal  
_anotherId  // legal  
3identifier // illegal  
while       // illegal. This is a keyword.  
While       // legal (Java is case sensitive)  
book        // legal
\u0062ook   // legal.  
%percent    // illegal.
A Unicode character, which can appear anywhere, can be used in a Java source file. Since \u0062 is a valid Unicode character, the given example \u0062ook is a valid Java identifier. The Unicode letter \u0062 substitutes for the letter 'b'. Keywords and reserved words are predefined names used by the Java language, which we cannot use as identifiers. The following table shows the list of Java keywords and reserved words.
Java Keywords and Reserved Words
------------------------------------------------------------
abstract continue  for        int       private   super           
boolean  default   else       goto      interface switch           
break    do        if         long      public    try       
byte     double    implements native    return    synchronized 
case     extends   new        short     this      volatile
catch    final     instanceof package   static    throw        
char     finally   true       transient strictfp
class    float     false      while     throws
const    import    null       void      protected

 Primitive Types and their Wrapper Classes
Java has eight primitive types; each primitive type has a matching wrapper class. A variable declared as type primitive cannot store an object reference. The primitive types are used to store primitive values. All numeric types are signed, except 'boolean' and 'char'. The 'boolean' literal has exactly two values: 'true', and 'false'. There are two kinds of numeric types: the integral and the floating-point types. The integral types are:
      byte
      short
      int
      long
      char
The floating-point types, complying with IEEE 754 specification, are:
      float
      double
Float and Double are wrapper classes of the float and double primitive types. Three constant values -NaN, POSITIVE_INFINITY, and NEGATIVE_INFINITY- have been defined in each wrapper class in order to define results of undefined mathematical operations (non-numerical values). The following table shows these values:
      Float.NaN
      Float.POSITIVE_INFINITY
      Float.NEGATIVE_INFINITY
      Double.NaN
      Double.POSITIVE_INFINITY
      Double.NEGATIVE_INFINITY
The primitive types are passed to methods by value, but Object types are passed by reference. Below you will find each of these primitive types with detailed information. I suggest you studying the following table. You may be asked to answer questions coming out of the following table. For instance, a question might be about the size or the range of a primitive type.
$Revision: 1.1.1.1 $
$Date: 2003/02/23 23:01:42 $

Copyright © 2002 by Koray Güclü.