This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes q 25 from Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "q 25 from" Watch "q 25 from" New topic

q 25 from

jake noi

Joined: Jan 07, 2001
Posts: 6
From TipSmart's sample paper
class MyClass
public static void main(String []args)
final int i = 100;
byte b = i;
Here is the answer from website => Will compile and print 100
How come that we don't need to explicitly cast from int to byte?
Thank you for your clarification
Michael Burke
Ranch Hand

Joined: Jul 29, 2000
Posts: 103
Because the int is final and so is a constant. The compiler can figure out the value at compile time and since 100 fits into a byte the compiler allows it. Anyone else want to clarify?
Vladimir Kositsky
Ranch Hand

Joined: Nov 03, 2000
Posts: 116
My compiler issued approval
It does not compile without final
I agree. Here's the link:
subject: q 25 from
It's not a secret anymore!