• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Null keyword

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is null not considered a keyword ? Any explanations will be helpful.
Thanks.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then the Roberts,Heller and Ernest SCJP Guide is misleading, as it says that null,false and true ARE keywords.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot. I'll check them out.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?)
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
As far as SCJP is concern null true and false are keywords
ALkesh
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
null seems to be a keyword (sorry about the case in the previous reply), alongwith false and true too.
Thanks to all.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Surely it cleared all the ambiguity. Thanks everybody .
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey nalini,
this is the list given in the sun site.
so it is more appropriate to follow according to sun .
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic