Can someone please explain that in case a questions is there that which of these are keywords 1) true 2) false 3) null Are these keywords or not. Thanks Mahesh
Hi Mahesh, true and false are boolean literals null is a null literal While they are not, technically, keywords, you cannot use them as identifier names ie you can't name a variable, method or class true, false or null. Hope that helps. ------------------ Jane Griscti Sun Certified Java 2 Programmer "When ideas fail, words come in very handy" -- Goethe
Yes All threee are Literals but from Exam point of view I think If question is select Keywords and options are : a) true b) false c) string d) short e) null then answer will be a,b,d and e. (all mocks exams are considering them as a keywords.)
But my question still remains answered. Whether in the exam if literals are given and question is are these keywords ? Should we say true or false. Thanks for the advice. Mahesh
Mahesh, The best approach to take is to watch the wording of the question. If it says "what words cannot be used as identifiers" and the answer list includes true, false, null or any keyword then you would select them. If the question asks "which are not Java keywords" and the answer list includes true, false or null, I would select them as not being keywords. If the question asks "which words are reserved in Java"; select any keywords and true, false or null if they are listed. The exam questions on keywords tend to include captialized words or C words (they're always trying to catch out C coders) so I don't think the real questions will cause you much anxiety. Hope that helps. ------------------ Jane Griscti Sun Certified Java 2 Programmer "When ideas fail, words come in very handy" -- Goethe
Hi, 1. According to the Sun's Java tutorial: a. reserved words = keywords (including goto and const) + the literals null, true, false 2. According to the Java Language Specification: a. keywords (include goto and const) are reserved b. null, true, false are not keywords but literals Regards, Sandeep.