This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Null keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Null keyword" Watch "Null keyword" New topic
Author

Null keyword

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Why is null not considered a keyword ? Any explanations will be helpful.
Thanks.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I believe the Java Language Spec. from Sun defines "null" as a literal and not a keyword. In my opinion, this is semantics. For test purposes, null is not a keyword. The same goes for "true" and "false". These are also defined as literals vs. keywords.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Then the Roberts,Heller and Ernest SCJP Guide is misleading, as it says that null,false and true ARE keywords.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Bill Brogden, author of Java2 Exam Cram has a list of keywords on his site that is derived from the list provided in the Java Language spec....you can also go to the java.sun.com and look for the Language Spec. In that doc. you will find the end all be all list for "keywords".
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks a lot. I'll check them out.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
http://java.sun.com/aboutJava/communityprocess/maintenance/JLS/jls2draft.pdf
This is a draft copy.....
Go to page 22 of this text.....
Page 23 defines a literal....hope this clears it up...
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Just a further clarification.
Does that mean that you can declare identifiers with null,false and true names ?(I know its not a good programming practise to do so, but will it be legal ?)
Nilesh Parikh
Ranch Hand

Joined: Mar 14, 2000
Posts: 52
Hi all,
As far as SCJP is concern null true and false are keywords
ALkesh
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi ,
I've checked out the sample questions at the sun site, and one of them asks whether null is a keyword, and surprisingly, it does not mark it as a keyword. So, with respect to SCJP, WHAT IS NULL?
Nilesh Parikh
Ranch Hand

Joined: Mar 14, 2000
Posts: 52
hi vid
NULL is not the keyword as u are asking.With respect to the exam null(check the case)is a keyword
ALkesh
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi ,
null seems to be a keyword (sorry about the case in the previous reply), alongwith false and true too.
Thanks to all.
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Hello all,
From the exam point of view , you just think in this way. Can the given choice be used as an identifier? If No, then the answer is ,the given choice is reserved word/keyword. For example true,null,false,strictfp,goto,const are all can't be used as an identifier in a Java program. The exam just tests this point only. It does not ask us to distinguish between keywords and reserved words. This is the feedback given by people who have taken the exam and says confidently from the exam point of view what should we do. So what I think is,just taking it what they say ,instead of keep on arguing is wise in this case.This should help to answer the qstn.
regds
maha anna
[This message has been edited by maha anna (edited March 22, 2000).]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Surely it cleared all the ambiguity. Thanks everybody .
newtojava
Greenhorn

Joined: Aug 10, 2000
Posts: 6
Java2.0 Language Keywords
Here's a list of Java's keywords. These words are reserved--
you cannot use any of these words as names in your Java programs. true, false, and null are not keywords but they are reserved words, so you cannot use them as names in your programs either.

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

* indicates a keyword that is not currently used
** indicates a keyword that was added for Java 2
regards
Nalini Mistry
Ranch Hand

Joined: Mar 21, 2000
Posts: 64
bill brogden gives a whole lot more like future, generic, byvalue, widefp, rest, var, cast, operator, inner, outer. most are unused but still are reserved words.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Did you check his errata files to Exam Cram and Exam Prep books?
That list from the books is changed quite a lot.
newtojava
Greenhorn

Joined: Aug 10, 2000
Posts: 6
hey nalini,
this is the list given in the sun site.
so it is more appropriate to follow according to sun .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Null keyword
 
Similar Threads
null
Is null a keyword......
null
Null Literals
WA #1.....word association