📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    Encapsulation is often described as a "protective

    barrier" that prevents the data from being accessed by the code outside the class. This statement is:
    A False, encapsulation is about inheritance. Correct Answer Incorrect Answer
    B True, it's about data hiding and controlled access. Correct Answer Incorrect Answer
    C False, it's about polymorphism. Correct Answer Incorrect Answer
    D True, but only for abstract classes. Correct Answer Incorrect Answer
    E False, it's about code reusability. Correct Answer Incorrect Answer

    Solution

    This description accurately captures the essence of encapsulation. By making data private and providing public methods for interaction, the class acts as a protective barrier, ensuring that its internal state is managed consistently and correctly.

    Practice Next
    ask-question