Skip to main content
PreparationZone Logo
PreparationZone
Back to Fundamentals

Fundamentals · Medium · Free

What is abstraction? How do abstract classes and interfaces differ?

FresherFundamentalsOOP & Language Fundamentals
Model answer

Abstraction

Abstraction exposes what an object does, not how. Abstract classes can share partial implementation; interfaces define contracts only.

Abstract classInterface
FieldsCan have stateOnly constants (pre-Java 8+ default methods)
Use whenShared base codeMultiple roles / APIs
ExampleBase HttpClient with retryRepository<T>
Backend fresher answer: interfaces for repositories and payment gateways—swap implementations in tests.