Skip to main content

Encapsulation

1).What is encapsulation in C++?

1) Bundling data and methods together
2) Inheritance of data members
3) Separating data from methods
4) None of the above

2).Which access specifier provides the highest level of protection?

1) private
2) protected
3) public
4) None of the above

3).What is the main purpose of encapsulation?

1) Data hiding
2) Memory management
3) Inheritance
4) None of the above

4).Which of the following is true about encapsulation?

1) Encapsulation allows direct access to data
2) Encapsulation separates data from behavior
3) Encapsulation combines data and methods
4) None of the above

5).How is encapsulation implemented in C++?

1) Using access specifiers
2) Using constructors and destructors
3) Using templates
4) None of the above

6).Which access specifier allows inheritance but restricts direct access?

1) protected
2) private
3) public
4) None of the above

7).What is the difference between encapsulation and abstraction?

1) Encapsulation hides implementation, abstraction hides complexity
2) Abstraction focuses on design, encapsulation focuses on security
3) Both A and B
4) None of the above

8).Can private members of a class be accessed outside the class?

1) No
2) Yes
3) Only using friend functions
4) None of the above

9).What is a getter function?

1) A function to access private data
2) A function to modify private data
3) A function to initialize private data
4) None of the above

10).Why is encapsulation considered a pillar of OOP?

1) It protects object integrity
2) It allows data hiding
3) It provides a clear interface
4) All of the above