• Post Reply Bookmark Topic Watch Topic
  • New Topic

interface question  RSS feed

 
Soumy Kumar
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


answer is 0 ..
what happens to interface variable x??
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apple's x was "shadowed" or "hidden" by AppleClass's x, so AppleClass can't see the x in the interface any more.
 
Soumy Kumar
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means

"The instance variable can shadow the local varibale & interface variable "

thanks a lot.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Soumy S:
"The instance variable can shadow the local varibale & interface variable "
Partly true. First, note that the "static int x" of AppleClass is a class member variable -- not an instance member variable. Second, local variables and parameters shadow class/instance/interface variables -- not the other way around.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!