Inheritance and Access

Contact Us or call 1-877-932-8228
Inheritance and Access

Inheritance and Access

When inheritance is used to create a new (derived) class from an existing (base) class, everything in the base class is also in the derived class. It may not be accessible; however, the access in the derived class depends on the access in the base class:

Base class access Accessibility in derived class
public public
protected protected
private Inaccessible
Unspecified (package access) Unspecified (package access)

Note that private elements become inaccessible to the derived class - this does not mean that they disappear, or that that there is no way to affect their values, just that they can't be referenced by name in code within the derived class

Also note that a class can extend a class from a different package