aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes null is a keyword? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


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

null is a keyword?

Peng Cedar
Greenhorn

Joined: Jul 25, 2001
Posts: 10
On Complete Java2 Study Guide said "null" is keyword.
But on http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
say it's not. Who knows?


I love MySQL<BR>Sun Certified Programmer for Java 2 Platform
r balasubramanian
Greenhorn

Joined: Jul 25, 2001
Posts: 11
Yes, null is a key word
Aakanksha
Ranch Hand

Joined: Jul 17, 2001
Posts: 60
No, null is not a keyword. It is a reserved word in Java, which means it cannot be used as name in java.

/Aakanksha
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
(this is not actually part of the exam objectives, but)
How can you tell the difference between reserved words and actual keywords?
I know that const and goto are reserved words.
Are all const literals reserved words (true,false,null)?
Are all literal object refs reserved words (this,super)?
Are anything else actual keywords?

------------------
Antti Barck
It Solutions Consultant, NSD Oy
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Yes, it is!

<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Originally posted by Desai Sandeep:
Yes, it is!

What is?

------------------
Antti Barck
It Solutions Consultant, NSD Oy
r balasubramanian
Greenhorn

Joined: Jul 25, 2001
Posts: 11
Sorry, null is not a key word (perhaps typing mistake). however, please note that true, false and null are literals and hence we cannot use it as int null=10
R.Balasubramanian
Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
Hi,
true ,false & null are reserved literals,atleast i think so.
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Hi,
null is a keyword only when u r appearing SCJP exam. Thenafter it is a reserved literal or reserved word.

------------------
azaman


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157

Originally posted by Antti Barck:
What is?
------------------
Antti Barck
It Solutions Consultant, NSD Oy

Antti,
The subject is the answer/question to your question
Call null,true,false a reserved literal or a keyword; it is one and the same thing.I understand JLS distinguishes it by using different words.However one cannot deny that they have specialized meaning in Java and cannot be used by Java Developer for some other purposes.
Hope this helps,
Sandeep
SCJP2, OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)
[This message has been edited by Desai Sandeep (edited July 28, 2001).]
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
Hi guys,
All the keywords can be found in JLS §3.9.

null is a keyword only when u r appearing SCJP exam. Thenafter it is a reserved literal or reserved word.

This is not the correct way to look at 'literals'.
JLS §3.9 specifically states that <code>true</code> and <code>false</code> are <code>boolean literals</code> and <code>null</code> is a <code>null literal</code>.
The literals <code>true, false</code> and <code>null</code> may not be used as identifiers i.e. you cannot name a variable, class, method, etc <code>true</code>, or <code>false</code> or <code>null</code>. The same goes for all the keywords.
On the exam, watch what you are being asked: to select keywords or to select legal identifiers.
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Ragu Sivaraman
Ranch Hand

Joined: Jul 20, 2001
Posts: 464
So what exactly the difference between keywords and reserved words? in regards to compiler?
Peng Cedar
Greenhorn

Joined: Jul 25, 2001
Posts: 10
Thanks for everyone reply my question.
To my surprise, there are so many different opions on
this topic.
But, just for the SCJP EXAM, who can give me a
complete and exact anwser?
payal bansal
Greenhorn

Joined: May 01, 2001
Posts: 23
accordind to my opinion, from exam point of view, its a keyword
nan sh
Ranch Hand

Joined: Jan 05, 2001
Posts: 167
"But, just for the SCJP EXAM, who can give me a
complete and exact anwser?"
Don't worry about it. Please read RHE book, page6, the bottem part Note
------------------
Have you tried this Mock Exam yet? www.geocities.com/pei4nan/index.html
[This message has been edited by nan sh (edited July 29, 2001).]


Have you tried this Mock Exam Testing Engine yet?<br /><a href="http://www.mycgiserver.com/~nan111/index.html" target="_blank" rel="nofollow">www.mycgiserver.com/~nan111/index.html</a>
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
Don't be concerned about whether null is a keyword or a reserved literal.You will not get questions in the real test which are ambiguous.
I believe JLS has differentiated between the two to specify that reserved literals represents a value for a primitive,object or null type.On the other hands, you cannot assign keywords as values to primitives,objects or null type.
The similarity between the two is both cannot be used as identifiers in Java.
Hope this helps,
Sandeep
SCJP2, OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)
ashok khetan
Ranch Hand

Joined: Jul 29, 2001
Posts: 153
from SCJP2 exam point of view, take 'null' as a keyword.dont't make urself confused!
ashok
Originally posted by Peng Cedar:
On Complete Java2 Study Guide said "null" is keyword.
But on http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
say it's not. Who knows?

ashok khetan
Ranch Hand

Joined: Jul 29, 2001
Posts: 153
yes, it is !
Eric Pramono
Ranch Hand

Joined: Jul 09, 2001
Posts: 74
Hi all,
According to JLS, and what everyone says that whatever JLS says is true, then null is not a keyword.
Please refer to JLS 3.9 Keywords
quote:
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)
hope this helps.
- eric
John McErkland
Greenhorn

Joined: Jul 29, 2001
Posts: 4
Keywords are part of the language itself. null, true and false are not part of the language per se, but may not be used as identifiers (only because this would be too confusing for others to read). Hence they are reserved words. Other reserved words which are not a part of the language (and are therefore not keywords) include goto.
Apurba Khatua
Greenhorn

Joined: Jul 24, 2001
Posts: 9
quote
===============================
This is not the correct way to look at 'literals'.
JLS �3.9 specifically states that true and false are boolean literals and null is a null literal.
The literals true, false and null may not be used as identifiers i.e. you cannot name a variable, class, method, etc true, or false or null. The same goes for all the keywords.
On the exam, watch what you are being asked: to select keywords or to select legal identifiers.
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
================================
What Jane says is very true.

------------------
Sun Certified Java2 Programmer


A K<br />Sun Certified Programmer for the Java 2 Platform
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: null is a keyword?