0

I have read this post: Do subclasses inherit private fields? and I think inheritance is matter of if the sub class can access the data or not, not sure though, but is it true that indirectly or internally the sub class object will be still having the private member variables and private methods from its super class because without them a sub class instance cannot be made through a sub class and super class relationship? I guess this depends on how inheritance is defined?

  • 2
    Does this answer your question? [Do subclasses inherit private fields?](https://stackoverflow.com/questions/4716040/do-subclasses-inherit-private-fields) – sanitizedUser Jul 10 '20 at 01:00

1 Answers1

0

Inheritance is defined quite simply. If

class B extends A {
}

then B has inherited everything defined in class A.

Methods in B have no access to private members of A. But access and inheritance are different concepts.

user13784117
  • 1,124
  • 4
  • 4