• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Private members n Inheritence

 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
( Khalid , page 178 )
Is following statement True or False ?
All the members of the superclass are inherited by the subclass.
ans given is True
But I guess it shld be false . As private members of superclass are NEVER inherited by subclass ( JLS chapter 8)
any opinions ?


------------------
Gagan (/^_^\)
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gagan,
Yes, I agree with you. As the statement is written the answer should be false. From the Java Spec, section 6.6.8, we get the following quote to support us.


A private class member or constructor is accessible only within the class body in which the member is declared and is not inherited by subclasses.


Regards,
Manfred.
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could it be possible that when constructing an object on the heap all the (instance) fields of the parent class were copied there, but they were accessible based on the modifiers with which they were declared?
 
Gagan Indus
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jose
almost same query came into my mind .. but for dat to be true , word "inheritence" seems too rigid in its definition
but now i know , this is indeed a error in Khild's book
( Mr. Oleg Stakhov ,Uni of Kyiv pointed out this , to me , my sincere thanks to him )
u can check this n other errata's in KAM-book at : http://www.ii.uib.no/~khalid/pgjc/jcbook/4-printing-errata.html
( go to the bottom of the page , and check out the sub topic "Clarification on Inheritance of Superclass Members" )
------------------
Gagan (/^_^\)
    Bookmark Topic Watch Topic
  • New Topic