Interview Q&A / Object-Oriented Programming

AdvancedQuick answer1 min readUpdated 3 Oct 2026

Your interface has twelve methods and most implementers leave several empty. How do you fix it without breaking everything?

SHORT ANSWER

Introduce smaller role interfaces, make the big interface extend them, move clients to the small ones gradually, then retire the old one. Existing code keeps compiling throughout.

Explain it simply

Renovating a shop without closing it: first build the new counters, then move customers over one by one, and only then remove the old counter. A sudden removal would break every caller at once.

Example

java
// Step 1: extract roles
interface Readable  { String read(String id); }
interface Writable  { void write(String id, String data); }
interface Deletable { void delete(String id); }

// Step 2: old interface keeps working, now built from the roles
interface Storage extends Readable, Writable, Deletable { }

// Step 3: clients ask for what they need
class Report {
    String build(Readable source) { return source.read("sales"); }
}

// Step 4: new implementers pick roles
class ArchiveStore implements Readable { public String read(String id) { return "..."; } }

Old implementers of Storage still compile. Over time, callers switch to the narrow roles, and Storage can be removed once nothing uses it.

What to say in the interview

"I extract role interfaces, have the old interface extend them for compatibility, migrate callers to the narrow ones, and delete the old one at the end. This avoids a big-bang change while giving new classes small contracts."

Common mistakes

  • Deleting the big interface in one commit and fixing the build afterwards.

#solid#isp#refactoring

Related questions

Practise more Object-Oriented Programming questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Object-Oriented Programming quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.