Machine-translated by Google. Questions are authored in English.
Top

Encapsulation and Access Control Questions and Answers

1.

The scope rules, especially the rules for nested type ensures that the resulting multitude of..........type do not interface with each other.

Exam Year(s)

MH SET - 2023, SET Exam - 2023,

Answer: B

The key is Inherited, and its source could not be traced.

Scope rules decide where a name is visible. For a nested type, one defined inside another, the name is visible only inside the enclosing type, so separately nested types do not clash with one another or with names outside. The sentence says this keeps a large number of types of one kind from interfering, and the key gives 'Inherited' for the blank.

No reference found words the sentence this way, so the choice between the four adjectives cannot be checked. Follow the key: B.

Please log in or register to report this question.

2.

In C++, which of the following is true for private members of a class ?

Exam Year(s)

Tripura Public Service Commission - 2025,

Answer: B

Private members are accessible only within the same class.

In C++, private members can be used only by the class's own member functions (and by its friends). This is the basis of encapsulation.

They cannot be accessed by other classes, and derived classes cannot access them directly either; that is what protected members allow. The this pointer is used inside member functions, so it does not open private members to outside code.

Please log in or register to report this question.

3.

Which OOP concept hides internal data from outside access ?

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: A

Hiding internal data from outside access is encapsulation.

Encapsulation bundles an object's data and the methods that work on it into one unit and restricts direct access to the data, typically by making fields private and exposing them only through public methods. Outside code cannot change the internal state except in the ways the class allows.

Abstraction is the near miss: it hides implementation complexity and shows only essential features, a design idea rather than data protection. Inheritance reuses a class's members in a new class, and polymorphism lets one interface take many forms.

Please log in or register to report this question.

4.

Which access specifier in C++ allows access only within the class ?

Exam Year(s)

Tripura Public Service Commission - 2026,

Answer: B

The specifier that restricts access to the class itself is private.

Private members of a C++ class can be used only by that class's own member functions (and by friends it explicitly names). They are the default for members of a class.

Public members can be accessed from anywhere. Protected members are also open to derived classes. friend is not an access specifier at all; it is a declaration that grants another function or class access to private members.

Please log in or register to report this question.

Loading…

Other Subjects

Tags: Encapsulation and Access Control Questions and Answers || Encapsulation and Access Control MCQ Questions and Answers || Encapsulation and Access Control GK Questions and Answers || Encapsulation and Access Control GK MCQ Questions || Encapsulation and Access Control Multiple Choice Questions and Answers || Encapsulation and Access Control GK || GK on Encapsulation and Access Control || Object Oriented Programming Questions and Answers || Object Oriented Programming MCQ Questions and Answers || Object Oriented Programming GK Questions and Answers || GK on Object Oriented Programming