Return to Tutorial Index

Back to the home page of this site
morterboard

Java2 Certification
Tutorial

 

Your feedback is valued, please send comments to feedback@marcusgreen.co.uk

4) Language Fundamentals

Objective 3)

Identify all Java programming language keywords.

Note on this objective: You may like to approach this objective on the basis of learning the less frequently used key words and ensuring you do not carry over any "false friends" from other languages you may know, particularly C/C++. The exam places significant emphasis on recognising keywords

You will come to recognise most of the Java keywords through using the language, but there are rarely used exceptions, and reserved words that might come up in the exam.

Examples of the more rarely used words (certainly for a beginner anyway) are


Java Keywords
abstract boolean break byte case catch
char class const * continue default do
double else extends final finally float
for goto * if implements import instanceof
int interface long native new null
package private protected public return short
static super switch synchronized this throw
throws transient try void volatile while

The words with asterisks are reserved and not currently used. Note that all of the keywords are in lowercase, thus for is a keyword but FOR is not. There is some debate as to if null is a keyword but I suggest that for the purposes of the exam you assume it is.


 

Question 1)

Which of the following are Java key words?

1) double
2) Switch
3) then
4) instanceof


Question 2)

Which of the following are not Java keywords?

1)volatile
2)sizeOf
3)goto
4)try

Answers

Answer 1)


1) double
4) instanceof

Note the upper case S on switch means it is not a keyword and the word then is part of Visual Basic but not Java


Answer 2)


2) sizeOf

This is a keyword in C/C++ for determining the size of a primitive for a particular platform. Because primitives have the same size on all platforms in Java this keyword is not needed.


Other sources on this topic

This topic is covered in the Sun Tutorial at
http://java.sun.com/docs/books/jls/html/3.doc.html#229308
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html

Michael Thomas
http://www.michael-thomas.com/java/JCP_Keywords.htm

Last updated
28 Dec 1999
copyright © Marcus Green 1999