Abstraction using language features
Introduction / Definition
Programming languages provide classes, interfaces, modules, access modifiers, and generics to create abstractions. These features hide representation and expose useful behavior. Abstraction reduces coupling and improves reuse. The client should depend on the contract rather than internal details.
Syntax / Structure / Formula
public contract + hidden implementation
Detailed Explanation
Interfaces describe operations, private fields hide state, and generics allow one structure to support many types.
Example
Example: List<T> can represent lists of Integer, String, or custom objects.
Output / Result
One abstraction is reused across multiple element types.
Important Points / Notes
- Encapsulation supports abstraction.
- Generics improve reusable designs.
Mini Practice Question
Which feature hides a class's internal fields?