aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Guys Help me Out 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 "Guys Help me Out" Watch "Guys Help me Out" New topic
Author

Guys Help me Out

deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39
class JSC201 {
static byte m1() {
final char c1 = '\u0001';
return c1; // 1
}
static byte m2(final char c2) {return c2;} // 2
public static void main(String[] args) {
char c3 = '\u0003';
System.out.print(""+m1()+m2(c3)); // 3
}}


help me out in Solving this Question
vidya sagar
Ranch Hand

Joined: Mar 02, 2005
Posts: 580
HI

final char c1 = '\u0001';

now the value of c cannot be changed there after.
and determined at the time of compilation itself.
so byte b=c;
is same as byte b=1;
and no problem.

but

byte m2(final char c2) {return c2;}
the argument may be anything .
even it may exceed the range of byte.
and cannot be converted into byte implicitly.
so compilation error.
deepu Bhalotia
Ranch Hand

Joined: Apr 19, 2005
Posts: 39
Thanks Vidya....
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Guys Help me Out