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
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, 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,<P>Raj.<BR>-------------------------<BR>Afforts should be Appriciated.<BR>-------------------------
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
Joined: Aug 26, 2000
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.