"public static class CheapCar {
private void printlnDesire()"
"public static class GeoMetro extends CheapCar {
public void printlnDesire()"
I thought that private methods can not be inherited. Why it is written this way?
Khamdam
Level 38
Is it allowed to inherit private methods?
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Anonymous #11267629 (Anouk)Expert
2 June, 12:48
You cannot inherit private methods, because the class cannot access these methods directly.
0
Thomas
27 May, 07:37
You can not inherit private methods. However you can write a method with the same name in a descendant class. But that method isn't polymorphic.
+1