Computer Applications

Describe the methods of accessing the data members and member functions of a class in the following cases:

(a) in the member function of the same class.

(b) in the member function of another class.

(c) in the member function of base class.

Encapsulation & Inheritance in Java

32 Likes

Answer

(a) in the member function of the same class.

All the data members and member functions of a class are accessible from the member function of the same class.

(b) in the member function of another class.

This other class should be a subclass of the given class then the public and protected data members and member functions will be accessible in this other class.

(c) in the member function of base class.

Base class doesn't have access to the data members and member functions of the derived class.

Answered By

15 Likes


Related Questions