Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

True, false and null = keyword or identifier?

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Example:
Which of the following are java keyword?
1) if
2) goto
3) case
4) null
5) true
6) then
For the exam should the right answer should be:
12345or
123??
Thanks
 
Saritha Pilla
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be 12345
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I Agree.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According with http://www.software.u%2dnet.com/J2Tutor/04_03Tut.htm the correct answer is: 1234. "True" and "then" are not keywords in Java.
 
Rolf Weasel
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no way! as per the JLS it is 123. null is not a keyword but a null literal. null is also the only null literal. true and false are boolean literals. check out the JLS.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
goto is a reserved word. So can it be considered as a keyword as far as Exam is concerned.
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't include <CODE>null</CODE>, <CODE>true</CODE> and <CODE>false</CODE> in Java reserved words, you'll get the question wrong. Don't spend energy trying to split hairs between keywords and literals. They are all reserved.
 
Rolf Weasel
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I quote from the JLS:
3.9 Keywords
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
abstractdefaultifprivatethrow
booleandoimplementsprotectedthrows
breakdoubleimportpublictransient
byteelseinstanceofreturntry
caseextendsintshortvoid
catchfinalinterfacestaticvolatile
charfinallylongsuperwhile
classfloatnativeswitch
constfornewsynchronized
continuegotopackagethis
The keywords const and goto are reserved by Java, even though they are not currently used in Java. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in Java programs.
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).
and the question explicitly says keywords
also, the syllabus states:
Identify all Java programming language keywords and correctly constructed identifiers.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rolf's post got in just before mine, so now I'm back to agreeing with him (Rolf that is).
Mughal and Rasmussen define null, true and false as "reserved literals" on a table separate from the list of keywords, which led me to believe that they are NOT keywords. Also that question came up on the Jaworski mock test, and that exam did not consider null, true or false to be keywords. Bill Brogden's Java Exam Cram lists these words together with the other keywords in a table called "All Java reserved words". Maybe the wording of the question on the exam will give us a clue (reserved vs keyword) as to the correct answer.
[This message has been edited by Joe Java (edited March 01, 2000).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
according to
http://indigo.ie/~dywalsh/certification/javacert.htm
only 1234 are key words.
and not "true" and "then"
could u be more specific tony.
thanxx
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More specific? I don't know how to be. Please read my post again and look at the emphasis/fonts used, thanks.
OK: One more time. Forget about the questions "What are Java keywords" and learn only that you cannot use null, true or false as your own identifiers. That's what you will be tested for.
 
Ramana Namuduri
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Saritha Pilla.
Jave keywords are those which you cannot use as a variable to store any value for that. So, one cannot create null, true,false variables of whatever may be the type, to contain any value of that type. My answer is 12345
 
Divakar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True is not a java keyword.
true is java keyword. I think you haven't noticed the case of t in True.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
Going to have the SCJP next week
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic