Member-only story
What Interviewers Expect When They Say: ‘Tell Me the Relationship Between These Classes..🎯
So, you’re sitting in an interview. You’re caffeinated, confident, and ready to crush it.
Then the interviewer casually throws this at you:
“Imagine you have a
Rectangle
, aColor
, aShape
, and something calledDrawable
. Tell me how they’re related. Use interfaces, abstract classes, inheritance. Oh, and mention ‘is-a’ and ‘has-a’ relationships."
Your brain goes: “Wait… what does this even mean?”
Don’t worry. This is one of those classic Java OOP design questions interviewers love because it checks multiple boxes — inheritance, abstraction, interfaces, and your ability to model relationships like a real-world system.
Let’s break this down — not just to answer this one question, but to build a mindset to handle any such object-oriented design question thrown at you.
🌟 Access Alert! 🌟
If you’re a member, just scroll and enjoy! Non-members, click here for full access.
💡 First Principles: Understand the Entities
Before jumping into code or terminology, understand what each entity represents:
- 🔷 Shape — An abstract idea; base for all…