Encapsulation Interview Questions

    Question 1C++ OOPS - Encapsulation Concept

    What is encapsulation in C++?

    Question 2C++ OOPS - Access Modifiers in Encapsulation

    Which access modifier is mainly used to achieve encapsulation in C++?

    Question 3C++ OOPS - Example of Encapsulation

    If age is a private member of class Person, how should it be accessed?

    Question 4C++ OOPS - Benefit of Encapsulation

    Which of the following is NOT a benefit of encapsulation?

    Question 5C++ OOPS - Access Control

    What will happen if you try to directly access a private data member of a class?

    Question 6C++ OOPS - Encapsulation & Abstraction

    How is encapsulation different from abstraction?

    Question 7C++ OOPS - Getter Method

    Which is the correct way to write a getter for salary (private) in class Employee?

    Question 8C++ OOPS - Setter Method

    Which is the best way to define a setter for salary in class Employee?

    Question 9C++ OOPS - Encapsulation Security

    Why does encapsulation improve security?

    Question 10C++ OOPS - Real-life Example of Encapsulation

    Which of the following is a real-world analogy for encapsulation?