Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

keywords or reserved words?

 
dx wu
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,all:
could someone tell me what's the difference of keywords and reserved words? and true,false,null are reserved words or keywords?
thanks!
 
Netty poestel
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reserved words are reserved and not currently used e.g "goto" , "const"
so something maybe for the future (?!)


true /flase/null are certainly not Java keywords...so they fall outside this set...and afaik....the exam doesn't indulge in this paradigm...

Phew.. one worry less
 
janne s
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

check this link on keywords 'n' reserved words

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html


jaya
 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaya,
Just FYI... the link you provided doesn't have ASSERT keyword, which is important as far as the exam is concerned.
 
Louie van Bommel
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Quote from Sun:
Section 4: Language Fundamentals
...
Identify all Java programming language keywords. Note: There will not be any questions regarding esoteric distinctions between keywords and manifest constants.


Now for something useful: On the exam look for words such as
instanceOf, sizeof friend virtual include
which look like they might be Java reserved words, but they are not.

The Java Language Specification refers to 49 words (yes I know jls2 had only 48 because "assert" was not there) as Keywords.

The 52 words of interest (which include null, true, false) are NOT allowed to be used as identifiers in Java.

Quote from JLS Second Edition:

3.9 Keywords
The following character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers (�3.8):

[all words that we are interested in except for null true false omitted for brevity]...

The keywords const and goto are reserved, even though they are not currently used. ...

While true and false might appear to be keywords, they are technically Boolean literals (�3.10.3). Similarly, while null might appear to be a keyword, it is technically the null literal (�3.10.7).

[ October 01, 2004: Message edited by: Louie van Bommel ]
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The key point to remember from Louie's post is that you don't need to know the difference between keywords and reserved words for the exam. You just need to know which words are reserved and can't be used as identifiers.

So, even though "for" is a keyword and "true" is a literal, you only need to know that neither one is allowed as an identifier.
 
dx wu
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks very much
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic