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


    Question

    Which OOP principle focuses on showing only essential

    information and hiding the complex implementation details from the user?
    A Encapsulation Correct Answer Incorrect Answer
    B Inheritance Correct Answer Incorrect Answer
    C Polymorphism Correct Answer Incorrect Answer
    D Abstraction Correct Answer Incorrect Answer
    E Association Correct Answer Incorrect Answer

    Solution

    o Abstraction is the principle of hiding complex implementation details and showing only the necessary or relevant information to the user. It focuses on "what" an object does rather than "how" it does it. For example, when you drive a car, you interact with the steering wheel and pedals (the abstract interface) without needing to know the intricate details of the engine or transmission (the hidden implementation). o Encapsulation (A) is the bundling of data and methods that operate on the data within a single unit (e.g., a class) and restricting direct access to some of the component's internals. It's a mechanism often used to achieve abstraction, but it's not the concept of hiding complexity itself. o Inheritance (B) is a mechanism where one class acquires the properties and behaviors of another class. o Polymorphism (C) allows objects of different classes to be treated as objects of a common type, enabling a single interface to represent different underlying forms. o Association (E) describes a relationship between two separate classes where one class uses the services of another class.

    Practice Next
    ask-question