Beginner
What are encapsulation, abstraction and polymorphism?
Reveal answer and example
Encapsulation protects state and invariants. Abstraction exposes the capabilities callers need, while polymorphism lets implementations satisfy the same contract with different behavior.
Example: A PaymentGateway contract hides provider-specific network details from checkout.
Big O is not intrinsic to this conceptual question. Define the implementation, input size and operation before assigning a complexity.
Common mistake: Getters and setters for every field do not automatically produce meaningful encapsulation.
Follow-up: Where should payment validation live?