Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

keywords and reserved word

 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It is kind of a very beginner question, but could someone tell me the difference between the java reserved words and java keywords.

Thanks
Kaps
 
Shilpi M Ag
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see link http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html

true false and null are not keywords but they are reserved. When asked in scjp we should not choose these three as reserved
 
Geoff Wass
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
true false and null are represent literals (the first two are boolean literals, the third is assigned to objects), that is why they are reserved.

The keywords are actually "words" used by the Java language, that is why you can't use them as properties, class or method names.
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keywords are words that have a special meaning in Java. Things like "while" and "if" are keywords. Literals are words that represent a specific value, such as "true" and "false." Reserved words is the union of those two sets.

In short, reserved words are all of the Strings that you can't use for your own purposes (variable names, class names, etc.) For example, you can't have a variable named "while" or "false."

As far as the SCJP exam goes, you need not be able to differentiate between keywords and literals. You only need to know what words make up the set of reserved words (which consists of all of the keywords and all of the literals).
 
N Rao
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. 'true', 'false' and 'null' are called as "manifest constants". They are treated as reserved keywords but they are, practically, just reserved literals (that is, using which as identifiers would cause a compiler error!).

2. 'goto' and 'const' are reserved keywords but are not used.

However, the SCJP Exam Objectives/Pre-requisites quotes:
There will not be any questions regarding esoteric distinctions between keywords and manifest constants.


Hope this helps!

Good luck!
-Rao
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot friends for your reply.

Actually I have never come across such type of distinction between keywords and reserved words, so I just wanted to know the difference.

Thanks
Kaps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic