wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes keyword doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "keyword doubt" Watch "keyword doubt" New topic
Author

keyword doubt

Janet Yap
Greenhorn

Joined: Mar 13, 2004
Posts: 24

Which of the following are Key-words in java ???.
1)switch
2)class
3)extends
4)null
5)true
6)goto
7)const
8)implements

I know that
case1:: 6),7) are reserved words , so can we include it into key words ???
case2:: 4) is string literals and 5) is boolean literals. can we include it into keywords???
case3:: 1),2),3),8) are keywords

But my doubt is mainly in case1 and case2. I have gone through so many tests but everywhere i have found different things so please anybody help me. I am taking the exam in the next week.

Thanx
sp
Sanjay Mishra
Ranch Hand

Joined: Jul 08, 2000
Posts: 84
I am pasting the list of Keywords from the Java Language Specifications (JLS). This list very much contains "goto" and "const".
Consult JLS when in doubt for these kind of questions.
Keyword:
abstract default if private this
boolean do implements protected throw
break double import public throws
byte else instanceof return transient
case extends int short try
catch final interface static void
char finally long strictfp volatile
class float native super while
const for new switch
continue goto package synchronized
The keywords const and goto are reserved, even though they are not currently used.
Regards
Sanjay
Sagar Sharma
Ranch Hand

Joined: Aug 31, 2000
Posts: 92
hi,

all are java keywords
refer Phillip Heller's book on JAVA 2 Certification
sankar
Greenhorn

Joined: Oct 02, 2000
Posts: 17
hi SP,
I think it is better to understand difference between the Keywords and Reserved word. The reserved words are set of words defined by the language and the user cannot use those words other then specified purpose.
The Keywords are the reserved words that are currently used by that language version, like Java 2.0 does not support the use of goto and const. But the persons who developed jave have defined these words meaning that it may be made possible to be used by some other versions.
Hope this will clear u'r doubt

So the case one is ruled out. coming to the case 2, the literals null, true and false are not considered as reserved words.

Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi ...
Think the confusion with null, true and false occurs because you can't use them as identifiers but they are not keywords.


JLS §3.8


An identifier cannot have the same spelling (Unicode character
sequence) as a keyword (�3.9), boolean literal (�3.10.3), or the null literal (�3.10.7).


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Rajiv Kannan
Greenhorn

Joined: Feb 23, 2007
Posts: 2
hi sp,
This is from JLS.
The keywords const and goto are reserved by Java, even though they are not currently used in Java. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in Java programs.
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).

sanjay
Originally posted by sp:

Which of the following are Key-words in java ???.
1)switch
2)class
3)extends
4)null
5)true
6)goto
7)const
8)implements

I know that
case1:: 6),7) are reserved words , so can we include it into key words ???
case2:: 4) is string literals and 5) is boolean literals. can we include it into keywords???
case3:: 1),2),3),8) are keywords

But my doubt is mainly in case1 and case2. I have gone through so many tests but everywhere i have found different things so please anybody help me. I am taking the exam in the next week.

Thanx
sp

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: keyword doubt