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 tipsmart mock 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 "tipsmart mock" Watch "tipsmart mock" New topic

tipsmart mock

sona gold
Ranch Hand

Joined: Feb 14, 2001
Posts: 234
Q8. What will be the result of compiling following code
public class MyClass
public class MyClass
final int i ;
public static void main(String[] arguments)
System.out.println(new MyClass().i);
gives compile time error

sona<br />SCJP
Ravindra Mohan
Ranch Hand

Joined: Mar 16, 2001
Posts: 216
Hi Sona,
The error is on account of the fact that final values need to
be expilitilely initialised before using it. Please note
that final values are not set to their default values.
You may checkout the similar discussion at JavaRanch.
Ravindra Mohan.
Samith Nambiar
Ranch Hand

Joined: Mar 14, 2001
Posts: 147
compilation error is because a blank final variable (i.e a final variable which has not been initialized) must be initialized once before it is used or must be initialized in every constructor
hope that helps
harder u try luckier u get
I agree. Here's the link:
subject: tipsmart mock
jQuery in Action, 3rd edition