Once the subclass (MySub) doesn't inherit the private members from its superclass (MySuper), how come the subclass can use the getter and setter methods on a data member that it has not inherited?
The books say that a private member is not "inherited" from a superclass.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
The members of a class type (�8.2) are classes (�8.5, �9.5), interfaces (�8.5, �9.5), fields (�8.3, �9.3, �10.7), and methods (�8.4, �9.4). Members are either declared in the type, or inherited because they are accessible members of a superclass or superinterface which are neither private nor hidden nor overridden (�8.4.6).
8.2.1.3 Inheritance with private
In the example:
the class variable totalMoves can be used only within the class Point; it is not inherited by the subclass Point3d. A compile-time error occurs because method move of class Point3d tries to increment totalMoves.
"JavaRanch, where the deer and the Certified play" - David O'Meara
A compile-time error occurs because method move of class Point3d tries to increment totalMoves.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
... for sake of clearity, it said to "Not be Inherited".
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
"JavaRanch, where the deer and the Certified play" - David O'Meara
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Michael Morris:
but to cast insults instead of explaing to me why I'm wrong is not something that I would ever do in return.
"JavaRanch, where the deer and the Certified play" - David O'Meara
... that it is more a matter of semantics than of opinion, more a matter of definition than of right or wrong.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Gee, I don't see where I insulted you, but sorry if you feel that I did.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
"I'm not back." - Bill Harding, Twister
Originally posted by Jim Yingst:
but that's not the same as being "ambiguous" or "inconsistent".
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|