OOPs Interview Mastery
- 84 lessons
- About 9 hours
- Self-paced
Start with lesson 1
First up: Class vs object. 84 lessons. The first one is free, no signup needed.
- Encapsulation
- invariant protection with private state
- immutable class design
- defensive copy of mutable fields
- Inheritance
- extends and single class inheritance
- super constructor call
- inheritance vs composition
- Polymorphism
- runtime dispatch on overridden methods
- overloading resolved at compile time
- covariant return types
- field access not polymorphic
- Abstraction
- abstract class vs interface
- default methods in interfaces
- private interface methods
- abstract class with a constructor
- Overriding Rules
- override requires same signature
- @override annotation purpose
- access weakening in override
- static method hiding vs overriding
- field hiding
- Construction Order
- superclass constructor runs first
- calling overridable method from constructor
- initializer block order
- Interface Design
- multiple interface implementation
- constant fields in interfaces
- functional interface
- marker interface
- Default and Static Methods
- default method diamond conflict
- static interface method
- Restricting Inheritance
- final class and final method
- sealed classes and permits
- sealed interface hierarchies
- Records
- record as data carrier
- record equality
- compact constructor validation
- records cannot extend classes
- Enums
- enum with fields and methods
- enum vs int constants
- enum in switch
- Nested and Inner Classes
- static nested vs inner class
- inner class outer reference
- anonymous class capture
- Core Principles
- composition over inheritance
- liskov substitution violation
- single responsibility in classes
- dependency inversion with interfaces
- Coupling and Cohesion
- tight vs loose coupling
- high cohesion in a class
- law of demeter
- Common Patterns
- factory method for creation
- builder for many optional fields
- strategy replaces type checks
- Generic Types
- generic class type parameter
- type erasure at runtime
- bounded type parameter
- Variance
- wildcard extends vs super
- invariance of list of string vs object
- Checked and Unchecked
- checked vs unchecked exceptions
- throws clause in overriding
- catching throwable mistakes
- Resources
- try with resources and autocloseable
- suppressed exceptions
- finally vs return ordering
- Comparisons
- overloading vs overriding
- overriding vs hiding a method
- final vs sealed class
- record vs plain class
- When to Use
- when to use inheritance
- when to use an interface
- when to use a sealed hierarchy
- when to use a record
- In Practice
- strategy in payment processing
- template method in report generation
- immutable value object in a cart
- factory method in notification channels
What you'll learn
- Explain classes, objects, identity versus equality, and encapsulation with a defensible answer each time.
- Predict overriding, overloading, hiding and constructor-order behaviour in Java.
- Choose between an abstract class, an interface, a sealed hierarchy and a record, and say why.
- Apply composition over inheritance and name the SOLID and coupling ideas an interviewer probes.
- Read a short generics or checked-exception snippet and say what compiles and what fails.
About this course
Object-oriented design questions are where many interviews separate candidates who have memorised definitions from those who can predict what a piece of Java code does. This course prepares you for those questions. It covers classes and objects, the four pillars, overriding and construction order, interfaces, records, sealed types, generics and the design principles interviewers probe, using Java 25 LTS. Each idea is shown with one running example, a grocery cart that stores money in paise, so the answers stay concrete rather than abstract.
Who this OOPs interview course is for
It is written for developers and fresh graduates in India who are preparing for interviews that ask object-oriented design questions, at product companies, service companies and global capability centres. It suits a learner who can write a class but freezes when asked why a field is chosen by the reference type while a method is chosen by the actual object. It also suits an experienced developer who wants to explain design choices clearly, such as why composition often beats inheritance, or when a record is the right tool for a value. You should know basic Java syntax before you start. The course prepares you for interview questions on these topics; it does not promise an offer.
Interviewers in this area rarely ask for a definition alone. They give a short snippet and ask what it prints, whether it compiles, or which design fits a change request. A good answer names the rule that decides the outcome and then shows the consequence. The course is built around that pattern, so each lesson asks you to predict before it explains.
How the lessons work
Each lesson is a short set of reading cards on one question, followed by a multiple-choice quiz. Cards use small Java snippets, most short enough to trace by hand. You are asked to say what the code prints or whether it compiles, and then the card shows the reasoning. The examples reuse the same cart, money and payment classes across the course, so a later card can build on an earlier one without you re-reading the setup. The sequence starts with classes and objects, moves through constructors, overriding and interfaces, and ends with design principles and generics. You work at your own pace and can return to any lesson before an interview round.
The quiz choices are designed to look like things people actually say. A wrong option is often a rule that is true in another language, or true for methods but not for fields. If you pick one, the explanation shows the exact rule you mixed up, which is more useful than a plain right or wrong mark.
MCQ practice vs video courses for OOPs
Video courses on Udemy and Coursera explain object-oriented programming through a lecture and a live demo, which suits a first pass at the ideas. This course uses a different format: a short explanation followed straight away by a question that asks you to choose between plausible answers. For interview preparation that difference matters. Rounds reward a quick, reasoned answer, and you cannot build that by watching someone else reason. Practising the choice one idea at a time builds the habit. Many learners use both: a video course for the first understanding, and short MCQ practice to find the gaps that a lecture does not reveal.
Common OOPs interview traps
- Saying Java supports multiple inheritance of classes. A class has one superclass and can implement any number of interfaces.
- Saying an overridden method is chosen by the reference type. An instance method is chosen by the object's actual class, while a field is chosen by the reference type.
- Saying == compares the contents of two objects. For objects it compares references, and equals compares content only when the class defines it.
- Saying a static method in a subclass overrides the superclass method. With the same signature it hides the method instead.
- Saying a record can extend another class. Records are implicitly final and cannot extend a class, though they can implement interfaces.
- Saying an overriding method may weaken access, such as public to protected. The compiler rejects it.
- Saying a superclass constructor can safely call an overridable method. The subclass fields still hold their default values at that point.
Best way to prepare for OOPs interviews
Before you answer a design question, identify what it is testing: object identity, dispatch, construction order, a restriction on inheritance, or a principle such as dependency inversion. Then give the answer with one short Java example and one sentence on why the tempting alternative fails. Practise saying that answer out loud, as you would in a room, and only then check it against the explanation. Return to the same quiz the next day, since recall fades faster than understanding.
When you meet a design question at work, sketch the classes on paper before you open the editor. Note which class owns the state, which behaviour is shared, and which part should change without touching the rest. That sketch is the same reasoning an interviewer wants to hear, and it makes the answer easier to defend in your own words.