CompTIA Tech+ (FC0-U71)Software Development ConceptsHard
A software architect is designing a system where different components need to interact by sending messages to each other. The design specifies that each component should expose a well-defined interface, and other components should only interact with it through this interface, without needing to know the internal workings of the component. Which object-oriented programming principle is being applied here?
- AInheritance
- BPolymorphism
- CEncapsulation
- DAbstraction
Show answer & explanationAnswer & explanation
Correct answer: D. Abstraction
Abstraction focuses on showing only essential information and hiding complex implementation details. By defining a well-defined interface and requiring interaction only through it, the internal workings are hidden, which is the core concept of abstraction.
Why the other options are wrong
- A. Inheritance is about creating new classes from existing ones, reusing code and establishing 'is-a' relationships.
- B. Polymorphism allows objects of different classes to be treated as objects of a common type, responding uniquely to the same method call.
- C. Encapsulation is about bundling data and methods into a single unit (an object) and controlling access to its internal state, but abstraction specifically focuses on hiding complexity through interfaces.
Abstraction (OOP)
An OOP principle that focuses on showing only essential information to the outside world and hiding complex implementation details. It provides a simplified view of an object or system through interfaces.
- Hides complexity, shows essentials.
- Achieved through interfaces and abstract classes.
- Focuses on 'what' an object does, not 'how'.
Memory trick: APIE: Abstraction, Polymorphism, Inheritance, Encapsulation.