This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi guys I gave exam in JohnJuntMockExam There is one question Q-8 : which of these is the correct format to use to create the literal char value a? (1) ?a? (2) "a" (3) new Character(a) (4) \000a Ans is (1) I gave ans (3) but it is wrong I can't understand why it is ?a? Himanshu Amin ------------------ "JAVA BANAYE BAVA"
To be honest, I have never seen ?a? before. However, I found this on page 570 of Mughal and Rasmussen's "A Programmer's Guide to Java Certification": "Not all Unicode characters can be represented in other encoding schemes. In that case, the '?' character is usually used to denote any such character in the resulting output, during translation from Unicode." Could this be what is going on in your example? Anyone have any ideas? Chris [This message has been edited by Chris Cingrani (edited January 09, 2001).]
I don't understand this!!! what in the world is ?a? I've tried it in a small class, with the code char c = ?a?; but, as i excpected, i get compile error. is the way I used this strang ?a? correct? anyone can give more professional help on this?
A Software life cycle can be greater than its Developer's
I am also confused why it is not answer c. I suppose if it because new Character( a ) creates the reference but the literal value. Am I right? Besides, my question is: When I should use primitive type and when reference to char,int and others? Thanks.
Joined: Jun 30, 2000
Option 3 doesn't create a literal char 'a' it creates a wrapper class for char 'a'. This create a Character object, not a char primitive. Bill
Joined: Jan 03, 2001
The question remains when i should create a wrapper class and when primitive. Similar question about other primitive type. Thanks.