Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock Exam Dan - Initialization A (Topic)

 
Isabel Wanderley
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
sabby
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic