aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes  question on unicode Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark " question on unicode" Watch " question on unicode" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question on unicode