jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Character Array 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 "Character Array " Watch "Character Array " New topic

Character Array

kapil apshankar
Ranch Hand

Joined: Dec 17, 2000
Posts: 66
After the declaration:
char[] c = new char[100];
what is the value of c[50]?
a) 50
b) 49
c) '\u0000'
d) '\u0020'
e) " "
f) cannot be determined
g) always null until a value is assigned
I thought the answer is 'c' as characters are initialised to '\u0000'. Am I wrong?
Because this is not the right answer and the key to answers is not provided!

Hope this helps. Correct me if I am wrong.<p>Cheers <img src="smile.gif" border="0"> ,<br />Kapil
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3635
You are right. c should be the right answer.
Get Certified, Guaranteed!
(Now Revised for the new Pattern)

Try out the world's only WebCompiler!

Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Vinod Mehta

Joined: Mar 13, 2001
Posts: 9
Here is an example to proove you are right:
Character class have
public static int getNumericValue(char ch) which
Returns the Unicode numeric value of the character as a nonnegative integer. If the character does not have a numeric value, then -1 is returned. If the character has a numeric value that cannot be represented as a nonnegative integer (for example, a fractional value), then -2 is returned.

Vinod Mehta

Joined: Mar 13, 2001
Posts: 9
O/P is
---------- Java Run ----------
In Main
Value of \u0000 is -1
Value of cMain[50] is -1
Value of cLocal[50] is -1
Normal Termination
Output completed (0 sec consumed).
I agree. Here's the link: http://aspose.com/file-tools
subject: Character Array
It's not a secret anymore!