• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

true or false

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
pls help me for the following question:
which of the following staments are true or false?
i) In java extends clause is used to specify inhertince.
ii) subclass of nonabstract class can be declared abstract
iii) All the members of super class inherited by subclass.
iv) A final class can be abstract class.
i think ans is i,ii ?but they have specified that iii is also correct but from sentences according to me u can not inherited private members so all members are not inherited right?
pls explain me ?if i am wrong
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to the Java Lang Spec, private members are NOT inherited, but they do still exist, just hidden in the implementation of the super class. Remember, inheritance is a concept, not related to any implementation.
However, depending on how you define inheritance, the answer could be true or false. Its a misleading question, to say the least. However, go by the Java Lang Spec. Privates, constructors, initializers, and any statics are NOT inherited by subclasses.
 
Rishi Yagnik
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank u luke
so answer 1 and 2 is correct right?
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are right. There is no reason why i and ii are not correct.
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rishi,
From which mock test you have got this question. Please give that mock test reference here. As this question is fit for Mock Errata Forum.
Luke is right in his explanation.Buttom line about members inherited from superclass is that "Privates, constructors, initializers, and any statics are NOT inherited by subclasses."

Regards
Raj.
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi rishi
I think option iii) is also right because all the members of the superclass are inherited in the subclass.
You CANNOT 'ACCESS' private members in the subclass.
There is a difference between inheriting and accessing
I hope i am right.
Tell me if you think otherwise
bye
Arif
 
Rajpal Kandhari
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Arif,
You r right in saying that there is differencec between Inheriting and Accessing.
But pls read my above post in which i have hilighted the point made by Luke. For your reference i am copying the same point here:
Buttom line about inheritence from superclass is that "Privates, constructors, initializers, and any statics are NOT inherited by subclasses."
Regards
Raj.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic