Author Topic:   Null keyword
vid
unregistered
posted March 22, 2000 10:03 AM           
Why is null not considered a keyword ? Any explanations will be helpful.

Thanks.

sandman
greenhorn
posted March 22, 2000 10:08 AM         
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.

vid
unregistered
posted March 22, 2000 10:19 AM           
Then the Roberts,Heller and Ernest SCJP Guide is misleading, as it says that null,false and true ARE keywords.

sandman
greenhorn
posted March 22, 2000 10:28 AM         
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".

vid
unregistered
posted March 22, 2000 10:30 AM           
Thanks a lot. I'll check them out.

sandman
greenhorn
posted March 22, 2000 10:32 AM         

This is a draft copy.....

Go to page 22 of this text.....

Page 23 defines a literal....hope this clears it up...

vid
unregistered
posted March 22, 2000 10:32 AM           
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 ?)

Alkesh Nandanwar
ranch hand
posted March 22, 2000 10:36 AM             
Hi all,
As far as SCJP is concern null true and false are keywords
ALkesh

vid
unregistered
posted March 22, 2000 10:42 AM           
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?

Alkesh Nandanwar
ranch hand
posted March 22, 2000 10:52 AM             
hi vid
NULL is not the keyword as u are asking.With respect to the exam null(check the case)is a keyword
ALkesh

vid
unregistered
posted March 22, 2000 11:12 AM           
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
bartender
posted March 22, 2000 11:15 AM             
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).]

vid
unregistered
posted March 22, 2000 11:22 AM           
Surely it cleared all the ambiguity. Thanks everybody .

newtojava
unregistered
posted March 22, 2000 11:57 PM           
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.

abstract double 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
continue implements 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
posted March 23, 2000 12:32 AM             
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
unregistered
posted March 23, 2000 01:05 AM           
Did you check his errata files to Exam Cram and Exam Prep books?
That list from the books is changed quite a lot.

newtojava
unregistered
posted March 23, 2000 02:23 AM           
hey nalini,
this is the list given in the sun site.
so it is more appropriate to follow according to sun .

|