1. List two practical benefits of encapsulation for large codebases.
Improves invariants and validation at a single point; reduces coupling and exposes a minimal API, easing refactoring.
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 Pillars 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.
Improves invariants and validation at a single point; reduces coupling and exposes a minimal API, easing refactoring.
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.
Java classes form single-inheritance trees; interfaces allow multiple inheritance of type.
Access cannot be reduced; checked exceptions can be same/narrower; return can be covariant.
When reusing behavior without inheriting unwanted API; when behavior needs to vary at runtime (strategy pattern); to avoid fragile base-class coupling.
LSP requires subtypes to be usable anywhere the base is expected without breaking semantics.
The compiler applies a ranking (most specific) that can pick unexpected overloads with boxing/widening/varargs.
They define stable boundaries—hiding internals (private), exposing minimal extension points (protected), and clear public APIs—reducing coupling and easing evolution.
Inheritance models an is-a relationship; composition/aggregation model has-a.
final cannot be overridden; static resolves by compile-time binding; private is not visible to subclasses.
Encapsulation bundles state and behavior, typically with private fields and public getters/setters.
Overloading is compile-time (choose method by signature); overriding is runtime (dispatch by actual object).
Abstract classes: partial implementation + state; interfaces: contracts of behavior; since Java 8+, interfaces can have default/static methods but no instance state.
They can declare constants but not instance fields; cannot be instantiated; may extend other interfaces.
Sealed types control extension points, improving maintainability and exhaustiveness checks.