Previous
Index

Next


Objective 4, identify keywords

Identify all Java programming language keywords. Note: There will not be any questions regarding esoteric distinctions between keywords and manifest constants.

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. The second part of this objective mentioning esoteric distinctions was added with the objectives for the JDK 1.4 version of the exam. It seems to have grown out of the number of people worrying if true/false and null were keywords. I think you can take it from this comment that you will not be questioned on true/false and null.

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

package

private

protected

public

return

short

static

strictfp

super

switch

synchronized

this

throw

throws

transient

try

void

volatile

while



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

volatile
transiernt
native
strictfp

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.

Questions

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

The Java Language Specification
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#229308

This topic is covered in the Sun Tutorial
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html


Michael Thomas

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




Previous
Index

Next