This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Mock Exam Dan - Initialization A (Topic) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Mock Exam Dan - Initialization A (Topic)" Watch "Mock Exam Dan - Initialization A (Topic)" New topic

Mock Exam Dan - Initialization A (Topic)

Isabel Wanderley
Ranch Hand

Joined: Aug 24, 2002
Posts: 42
I didn't understand why it just prints Mainv instead of printing Mainvw...
When an interface is loaded the variables that doesn't need a method like v are initialized??
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
hi isabel
this is wht i made out of the explanation.
if u r implementing an interface, and if the interface has variables which will be initialized at run time like in this example w is. then if ne one of the variables of this interface is used in the class implementing it, then all of them get initialized.
but, if the variables are like 'v', which are initialized at compile time, then only those get initialized which are used in the class implementing it.
hope it makes sense. this is a rule of thumb i made. my exam is this friday. hope this rule works over there too.
It is sorta covered in the JavaRanch Style Guide.
subject: Mock Exam Dan - Initialization A (Topic)
Similar Threads
4m Dan's Exam
interface and initialization
Another one from Dan
HELP~~ august09 comprehensive exam4.Q9