1.

While using encapsulation, which among the following is possible?(a) Code modification can be additional overhead(b) Data member’s data type can be changed without changing any other code(c) Data member’s type can’t be changed, or whole code have to be changed(d) Member functions can be used to change the data type of data membersThis question was addressed to me during an interview.My question is based upon Encapsulation in section OOPs Concept & Features of Object Oriented Programming

Answer»

Correct option is (b) Data member’s data TYPE can be changed without changing any other code

To explain I WOULD say: Data member’s data type can be changed without changing any further code. All the members using that data can continue in the same way without any modification. Member FUNCTIONS can NEVER change the data type of same class data members.



Discussion

No Comment Found

Related InterviewSolutions