• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

null is a keyword?

 
Peng Cedar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
r balasubramanian
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, null is a key word
 
Aakanksha
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(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
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is!
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Desai Sandeep:
Yes, it is!

What is?

------------------
Antti Barck
It Solutions Consultant, NSD Oy
 
r balasubramanian
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
true ,false & null are reserved literals,atleast i think so.
 
Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
null is a keyword only when u r appearing SCJP exam. Thenafter it is a reserved literal or reserved word.

------------------
azaman
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ragu Sivaraman
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what exactly the difference between keywords and reserved words? in regards to compiler?
 
Peng Cedar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
accordind to my opinion, from exam point of view, its a keyword
 
nan sh
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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).]
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, it is !
 
Eric Pramono
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic