Practice 20 Encapsulation & Abstraction multiple-choice questions designed for CDAC CCAT exam preparation. Click "Show Answer" to reveal the correct option with detailed explanation.
Show Answer & Explanation
Correct Answer: B — Bundling data and methods together
Encapsulation wraps data and methods that operate on data within a class.
Show Answer & Explanation
Correct Answer: B — Making members private
Private members hide data from outside access.
Show Answer & Explanation
Correct Answer: B — Controlled access to private data
Getters/setters provide controlled access to private members.
Show Answer & Explanation
Correct Answer: B — Hiding implementation details
Abstraction hides complex implementation and shows only necessary features.
Show Answer & Explanation
Correct Answer: C — private
Private is most restrictive - accessible only within the class.
Show Answer & Explanation
Correct Answer: B — Same class and derived classes
Protected members are accessible in the class and its derived classes.
Show Answer & Explanation
Correct Answer: B — Compilation
Four pillars of OOP: Encapsulation, Abstraction, Inheritance, Polymorphism.
Show Answer & Explanation
Correct Answer: B — Abstract class with pure virtual functions
C++ doesn't have interface keyword; uses abstract classes with pure virtual functions.
Show Answer & Explanation
Correct Answer: B — Data protection and modularity
Encapsulation protects data and provides modularity.
Show Answer & Explanation
Correct Answer: B — Cannot modify non-static members
const member function cannot modify non-static data members.
Show Answer & Explanation
Correct Answer: A — Hiding implementation details
Data abstraction hides implementation details and shows only functionality to users.
Show Answer & Explanation
Correct Answer: B — = 0 syntax
Pure virtual function is declared with = 0: virtual void func() = 0;
Show Answer & Explanation
Correct Answer: B — Both pure virtual and regular functions
Abstract class can have both pure virtual functions and regular member functions.
Show Answer & Explanation
Correct Answer: B — Read private data safely
Getter (accessor) methods provide controlled read access to private data members.
Show Answer & Explanation
Correct Answer: B — Modify private data with validation
Setter (mutator) methods provide controlled write access with optional validation.
Show Answer & Explanation
Correct Answer: B — Classes have minimal dependencies
Loose coupling means classes have minimal dependencies on each other, improving maintainability.
Show Answer & Explanation
Correct Answer: B — Private members and public interfaces
Information hiding uses private members accessed through public methods (getters/setters).
Show Answer & Explanation
Correct Answer: B — Abstract class or interface
Abstract classes and interfaces provide better abstraction by defining contracts without implementation.
Show Answer & Explanation
Correct Answer: B — Easier maintenance and data integrity
Encapsulation provides easier maintenance, data integrity, and protection from misuse.
Show Answer & Explanation
Correct Answer: B — Interface abstraction and separate compilation
Header files separate interface from implementation, promoting abstraction and modularity.