Two Laptop Bag
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ?a? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "?a?" Watch "?a?" New topic


Hemant Patel

Joined: Dec 15, 2000
Posts: 20
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
Chris Cingrani
Ranch Hand

Joined: Nov 21, 2000
Posts: 69
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?
[This message has been edited by Chris Cingrani (edited January 09, 2001).]
Maitham H

Joined: Jan 07, 2001
Posts: 29
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
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
The question really states:
1. 'a'
Bin Wu
Ranch Hand

Joined: Jan 03, 2001
Posts: 32
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.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
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.
Bin Wu
Ranch Hand

Joined: Jan 03, 2001
Posts: 32
The question remains when i should create a wrapper class and when primitive. Similar question about other primitive type.
I agree. Here's the link:
subject: ?a?
It's not a secret anymore!