what is true about an Inheritance?
i. Derived classes can access a private variable of base class, if it (base class) is having a public nested class.
ii. Derived classes can access a private variable indirectly, if base class is having a public class which is accessing that private class.
iii. Non derived classes of other packages can call protected function of base class.
i & ii
i, ii, & iii
you can access a private variable of base class in derived class through some indirect ways like through nested public classes of base class or public functions of base class which access those private variables. A protected function of a base class can be accessed by a derived class of other package , but not other classes of other package.
Back To Top