1. Name the four pillars of OOP in Java and give one-liner benefits for each.
Encapsulation (data safety), Abstraction (hide detail), Inheritance (reuse), Polymorphism (flexible behavior).
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Java · Question Set
OOP Deep Dive interview questions for placements and exams.
Questions
14
Included in this set
Subject
Java
Explore more sets
Difficulty
Mixed
Level of this set
Go through each question and its explanation. Use this set as a focused practice pack for Java.
Encapsulation (data safety), Abstraction (hide detail), Inheritance (reuse), Polymorphism (flexible behavior).
Abstract class for shared state/base implementation and ctor control; interface for capability types, multiple inheritance of behavior (default/static).
final forbids overriding; private isn’t visible to subclasses. static methods are hidden, not overridden.
Constructors tie to class identity. Subclass chains initialization via super(...) call to construct the parent part first.
Overloading resolved at compile-time; overriding at runtime via dynamic dispatch.
sealed ... permits ... restricts the subclassing hierarchy for better design and exhaustiveness.
Prefer composition to avoid tight coupling and fragile base class—e.g., reuse behavior by delegating to a helper instead of extending.
Clients coded to the base shouldn’t observe incorrect behavior when given the subtype.
Mutations can break set/map invariants and lookup; cross-type symmetry/consistency can also be violated.
Overridden instance methods are chosen by the actual object type at runtime.
Template Method fixes algorithm skeleton in a base class with overridable steps; Strategy composes behavior by swapping implementations at runtime.
this → current instance; super → immediate parent’s members/ctor.
Overriding allows covariant return; access cannot be narrowed; static methods are hidden, not overridden.
Class must override and can delegate to a specific interface’s default via Interface.super.method().
For complete preparation, combine this set with full subject-wise practice for Java. You can also explore other subjects and sets from the links below.