• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

null is java keywork or not?.

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
null is java keywork or not?.
-SR
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
null is a keyworld.
Bye.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
null is not a keyword but a literal !!
See JLS 3.9 Keywords and JLS 3.10.7 The null literal
HIH
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
according to

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).


The "null" may be keywords,I think.
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a technical difference between a keyword, and a reserved word...but for purposes of the test, you just need to know what the reserved words are.
null, true, and false are reserved words. They are not keywords.

Rob
 
Ranch Hand
Posts: 5397
1
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thses are only Keywords define by JLS:


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


true, false, null are neither KEYWORD nor RESERVED words.
true - booloean litral
fasle- booloean litral
null - null litral
there are only 2 reserved words : goto & const which are KEYWORDS also.
reserved are words that are not used by java and can not be used as identifier. they are here to help programmer who migrate from C background.
HTH
[ January 23, 2002: Message edited by: ravish kumar ]
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by ravish kumar:
Thses are only Keywords define by JLS:

true, false, null are neither KEYWORD nor RESERVED words.
true - booloean litral
fasle- booloean litral
null - null litral
there are only 2 reserved words : goto & const which are KEYWORDS also.
reserved are words that are not used by java and can not be used as identifier. they are here to help programmer who migrate from C background.
kumar ]


Ravish, not true.
A reserved word is a sequence of characters that obeys the rules of a lexical identifier, but that the compiler will prevent you from using as an identifier for your own objects; ie, you cannot use a reserved word to name your variables, classes, interfaces, etc, because the word has been reserved for use. All keywords are reserved. So are the lexical symbols 'null', 'true', and 'false'.
A keyword is a parsed token that invokes special semantic processing; it is semantically different than an identifier, and appears in your source code in positions that are syntactically distinct from an identifer.
The confusion I think comes because in the JLS section 3.9 states:
Keywords
"The following character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers (3.8) ...(long list omitted)... The keywords const and goto are reserved, even though they are not currently used...While true and false might appear to be keywords, they are technically Boolean literals. Similarly, while null might appear to be a keyword, it is technically the null literal"
For the purpses of the SCJP, they are not going to ask you to understand the differences between keywords and reserved words. The questions will be "which are reserved words in java?"
People should *stop* using the term "keyword" because in the majority of instances, they are using it incorrectly.
Rob
[ January 23, 2002: Message edited by: Rob Ross ]
[ January 23, 2002: Message edited by: Rob Ross ]
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this handy set of 4 science fiction-like sentances to help remember the java reserved words:
1. Abstract native try break default interface while byte finally throws
public case for do
2. super short volatile private synchronized this final return continue
throw long char
3. if long protected static continue float Boolean extends strictfp else
implements void instanceof int
4. const goto class catch new transient package import double protected
switch
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by John Lynn:
I found this handy set of 4 science fiction-like sentances to help remember the java reserved words:
1. Abstract native try break default interface while byte finally throws
public case for do
2. super short volatile private synchronized this final return continue
throw long char
3. if long protected static continue float Boolean extends strictfp else
implements void instanceof int
4. const goto class catch new transient package import double protected
switch



Wow. That's quite a little story you wrote there John!! :roll:
I wonder if it would be easier to remember the list alphabetically, or if it would be the same effort to memorize these 4 sentances?
Interesting idea though!
Rob
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by John Lynn:
I found this handy set of 4 science fiction-like sentances to help remember the java reserved words:
1. Abstract native try break default interface while byte finally throws
public case for do
2. super short volatile private synchronized this final return continue
throw long char
3. if long protected static continue float Boolean extends strictfp else
implements void instanceof int
4. const goto class catch new transient package import double protected
switch


strictfp What is this ?
Regards
Eric
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
strictfp is a modifier that makes its block use a particular implementation of floating-point algorithms for calculations...mainly to ensure strict compliance and repeatability of a floating point operation accross multiple platforms and hardware.
It can modify a method declaration, or an interface or class declaration...

public strictfp class foo {...
protected strictfp float addMyNumber(...
etc.

Rob
 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the answer
null is a reserved word. right ?

Originally posted by Rob Ross:

Ravish, not true.
A reserved word is a sequence of characters that obeys the rules of a lexical identifier, but that the compiler will prevent you from using as an identifier for your own objects; ie, you cannot use a reserved word to name your variables, classes, interfaces, etc, because the word has been reserved for use. All keywords are reserved. So are the lexical symbols 'null', 'true', and 'false'.
A keyword is a parsed token that invokes special semantic processing; it is semantically different than an identifier, and appears in your source code in positions that are syntactically distinct from an identifer.
The confusion I think comes because in the JLS section 3.9 states:
Keywords
"The following character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers (3.8) ...(long list omitted)... The keywords const and goto are reserved, even though they are not currently used...While true and false might appear to be keywords, they are technically Boolean literals. Similarly, while null might appear to be a keyword, it is technically the null literal"
For the purpses of the SCJP, they are not going to ask you to understand the differences between keywords and reserved words. The questions will be "which are reserved words in java?"
People should *stop* using the term "keyword" because in the majority of instances, they are using it incorrectly.
Rob
[ January 23, 2002: Message edited by: Rob Ross ]
[ January 23, 2002: Message edited by: Rob Ross ]

 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, null is a reserved word.

true is a reserved word
false is a reserved word
all the java keywords are also reserved words.
Rob
 
R K Singh
Ranch Hand
Posts: 5397
1
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Rob Ross:
Yes, null is a reserved word.-- WRONG

true is a reserved word -- WRONG
false is a reserved word -- WRONG
all the java keywords are also reserved words. -- WRONG
Rob


null is a litral (JLS: 3.10.7)
true/false is a litral (JLS 3.10.3)
All reserved words are keywords, vice versa is not true.
for more reference
HTH
 
R K Singh
Ranch Hand
Posts: 5397
1
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rob Ross:
Ravish, not true. - (false)
A reserved (RK- not reserved word, it is KEYWORD and as all reserved are also KEYWORD, they also can not be used as lexical identifier)word is a sequence of characters that obeys the rules of a lexical identifier, but that the compiler will prevent you from using as an identifier for your own objects; ie, you cannot use a reserved word to name your variables, classes, interfaces, etc, because the word has been reserved for use.
All keywords are reserved. So are the lexical symbols 'null', 'true', and 'false'.(RK --WRONG)
A keyword is a parsed token that invokes special semantic processing; it is semantically different than an identifier, and appears in your source code in positions that are syntactically distinct from an identifer. (RK-looks cool)
The confusion I think comes because in the JLS section 3.9 states:(RK- very true)
Keywords
"The following character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers (3.8) ...(long list omitted)... (RK- if you see the list then will find that in that list null,true,false are missing)
NOTE:
The keywords const and goto are reserved, even though they are not currently used...(RK- read these dots, why they are reserved words)

NOTE:
While true and false might appear to be keywords, they are technically Boolean literals.
NOTE:
Similarly, while null might appear to be a keyword, it is technically the null literal"
The questions will be "which are reserved words in java?"
Ans: const AND goto
People should *stop* using the term "keyword" because in the majority of instances, they are using it incorrectly. (RK: THEY REMOVE CONFUSION)
Rob
==================================================
Hi rob
I think ur confusion is because of these words:
The following character sequences, formed from ASCII letters, are reserved for use as keywords
YES JLS is right as here it as talking abt reserved character sequences for used to be as KEYWORDS.
NOTE: after list of KEYWORDS..
The keywords const and goto are reserved, even though they are not currently used..........
here it says that const & goto are RESERVED words.
SO all RESERVED words are KEYWORDS but all KEYWORDS are not RESERVED words.
abt null,true,false..... I think till now things should be clear in your mind.
language of JLS is tough ... read it properly.. or say thanks to RHE and Khalid.
HTH
I am not writing CMIW
[ January 23, 2002: Message edited by: ravish kumar ]
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The following character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers (�3.8):
Keyword: one of
abstract default if private this
boolean do implements protected throw
break double import public throws
byte else instanceof return transient
case extends int short try
catch final interface static void
char finally long strictfp volatile
class float native super while
const for new switch
continue goto package synchronized


JLS states that const and goto are keywords. It also states they are reserved.
reserved means the language is using these character sequences for a special purpose, and therefore you are not allowed to use them for your own purposes. That's all, no more,no less. You're making the distinction between a "keyword" and a "reserved" word more than it is. All keywords are reserved words. NOT all reserved words are keywords- null, true, and false are reserved words. They are also literals. They can be both, just like I am a programmer, and I am an American are not mutually exclusive.
But true, false, and null are not keywords. Therefore, you cannot say all reserved words are keywords. You have it backwards.
Rob
[ January 23, 2002: Message edited by: Rob Ross ]
 
R K Singh
Ranch Hand
Posts: 5397
1
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Rob
Can you plz tell me where did you read that:
null,true,false are RESERVED words.
Thanks In Advance
 
Sheriff
Posts: 16036
266
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravish,
Rob is right: you have it backwards. All keywords are reserved words. The boolean literals true and false and the null literal are reserved literals (they have special meaning to the compiler and you may not use them in your code as identifiers).
Re-read the section of the JLS that you referenced and you can infer all of the above from it.
None of the following statements will compile:
int null = 0; // "null" is reserved!
int true = 0; // "true" is reserved!
int false = 0; // "false" is reserved!

Again, for purposes of the certification exam, you are not expected to make a distinction between reserved words and keywords. You simply need to know whether a word can be used as an identifier (a variable name, method, or class name) or not.
HTH
[ January 24, 2002: Message edited by: Junilu Lacar ]
[ January 24, 2002: Message edited by: Junilu Lacar ]
 
R K Singh
Ranch Hand
Posts: 5397
1
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Rob and Junilu
But really I did not know this .. or I never interpret this ...(sometimes you think you know and you do not know that you do not know)
In one mock i think i get such que. where they ask abt null...
so what should answer..
thats what I think plz CMIW
1) null, true, false are reserved WORD (as they are RESERVED LITRALS)
2) null, true, false are NOT keywords.
3) All Keywords are RESERVED words and viceversa is NOT true.
THANKS A LOT again .....I will repeat after you Rob
Now I am
 
R K Singh
Ranch Hand
Posts: 5397
1
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Junilu
can you throw some light here too as code compiles but does not run ...
JLS says NO, but it compiles... but does not run...
TIA
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The real answer is "it depends". For the purpose of passing the exam you should assume that null is a keyword. However I have never heard of anyone getting a question where they had to choose if it was or was not a keyword, so I would really not worry about it. (Note I have been reading the responses and feedback from people who have taken the exam every day for the last two years or so).
For all other purposes, you can read the previous debate and make up your own mind. Whichever way you decide it will not affect any code you write. Although the JLS is considered the final arbiter, it is not uncommon for one part of Sun to disagree with another about how many angels can dance on the head of a a single object.
Marcus
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree. I've seen practice questions like...
Which of the following is not a reserved word in Java:
1. if
2. goto
3. null
4. then
The key is being able to recognize the keywords and literals used by the java language, and being able to recognize what's NOT java - like the "then" choice, which exists is many programming language, but not java.

Also, in the RHE study guide, in a footnote, they write "The exam is careful to avoid potentially ambiguous questions that require you to make purely academic distinctions between reserved words and keywords". And since two of the authors actually worked at Sun developing the exam, I will take their word for it on this one!
Rob
[ January 24, 2002: Message edited by: Rob Ross ]
 
R K Singh
Ranch Hand
Posts: 5397
1
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to All to all for correcting me
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic