Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inquisition question

 
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


i think this doesnt compile....but the exam says that the answer is 8 since x2is static.....how? what does static has to do with this?
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We can access static member using ClassName,
In your example we cam access x2 using pack, since x2 is a static variable.


 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh ya....since it is static it is being inherited.....never looked that way before
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, it has nothing to do whether it is static or not.

In your example, you can access x2 because you class extends Pack. The static member x2 in Pack is protected, which means classes extending this one have access to it.

The previous post simply implied that you do not need an instance of Pack to get access to x2, because x2 is a static member. Therefore, you could simply right Pack.x2 to gain access to it.
 
rohan yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Edwin Dalorzo wrote:Actually, it has nothing to do whether it is static or not.

In your example, you can access x2 because you class extends Pack. The static member x2 in Pack is protected, which means classes extending this one have access to it.

The previous post simply implied that you do not need an instance of Pack to get access to x2, because x2 is a static member. Therefore, you could simply right Pack.x2 to gain access to it.


Thats what i am trying to say
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya got it...thanks again both of you....you know what this paid mock tests suck...free mock tests(inquisition) are the best....
 
reply
    Bookmark Topic Watch Topic
  • New Topic