» 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


$Revision: 1.1.1.1 $
$Date: 2003/02/23 23:01:42 $
|
|