KnowledgeBoat Logo
|

Computer Applications

Give reasons:

(a) In what circumstances is a class derived publicly?

(b) In what circumstances is a class derived privately?

Encapsulation & Inheritance in Java

15 Likes

Answer

(a) In what circumstances is a class derived publicly?

In Java, a base class can be derived by a subclass by using only public mode of inheritance. When a class is derived publicly, the public and protected members of the base class are accessible to the derived class. Private members of the base class are not inherited by derived class.

(b) In what circumstances is a class derived privately?

Java doesn't support private and protected modes of Inheritance. Classes are always derived publicly in Java.

Answered By

9 Likes


Related Questions