| Author |
question on unicode
|
Abacus White
Greenhorn
Joined: Jul 23, 2004
Posts: 8
|
|
class JSC201 { static byte m1() { final char c = '\u0001'; return c; // 1 } static byte m3(final char c) {return c;} // 2 public static void main(String[] args) { char c = '\u0003'; System.out.print(""+m1()+m3(c)); }} What is the result of attempting to compile and run the program? a. Prints: 13 b. Prints: 4 c. Compile-time error at 1 d. Compile-time error at 2 e. Run-time error f. None of the above
|
 |
Corey McGlone
Ranch Hand
Joined: Dec 20, 2001
Posts: 3271
|
|
|
So what's your question? I assume you're quite capable of compiling and executing yourself, so what are you confused about?
|
SCJP Tipline, etc.
|
 |
Abacus White
Greenhorn
Joined: Jul 23, 2004
Posts: 8
|
|
f.java: In class `f': f.java: In method `f.m1()': f.java:33665: warning: Constant expression `0xfc00000003' too wide for narrowing primitive conversion to `byte'. <<file too short - unexpected EOF>> This is the outcome.I would like to know as to why this occured.
|
 |
Corey McGlone
Ranch Hand
Joined: Dec 20, 2001
Posts: 3271
|
|
Hmmm...that is not the output I received. When trying to compile that, I got this: That error makes perfect sense as you can't implictly cast a char to a byte as going from a char to a byte is a narrowing conversion. I'm not sure why you're getting the error you are. What version of Java are you comiling on?
|
 |
Abacus White
Greenhorn
Joined: Jul 23, 2004
Posts: 8
|
|
|
i'm using j2sdk1.4.1_01
|
 |
 |
|
|
subject: question on unicode
|
|
|