50 deliberately tricky MCQs across 7 topics — overloading vs overriding, static vs dynamic binding, constructors, abstract classes vs interfaces, and the equals/hashCode contract. These are the exact spots where candidates get caught out. Pick an option and the right answer plus a short reasoning shows up instantly.
0/50
questions attempted · 0% complete
0
Correct
0
Wrong
Q1.Which OOP pillar lets the same method call behave differently depending on the actual object type?
Q2.What's the real difference between abstraction and encapsulation?
Q3.Which of these best demonstrates "has-a" composition rather than "is-a" inheritance?
Q4.Why is "favor composition over inheritance" considered good design advice?
Q5.What does "tight coupling" mean in OOP design?
Q6.Which OOP pillar is most directly violated when a class exposes all its fields as `public` with no getters/setters?
Q1.A subclass defines a method with the same name and parameters as a `private` method in its superclass. What actually happens?
Q2.A superclass reference holds a subclass object and calls an overridden instance method. Which version actually runs?
Q3.Can `static` methods be overridden in Java?
Q4.What determines which overloaded method gets selected, and when?
Q5.When overriding a method, can the subclass widen the access modifier — e.g., `protected` in the parent becomes `public` in the override?
Q6.Two methods share the same name and identical parameter lists, but differ ONLY in return type. Is this valid overloading?
Q7.A subclass overrides a parent method that returns `Animal`, but the override returns `Dog` (a subtype of `Animal`). Is this legal?
Q8.Given overloads `print(String)` and `print(Object)`, what does `print(null)` resolve to?
Q1.A class defines only a parameterized constructor and no explicit no-arg constructor. What happens to `new ClassName()`?
Q2.A subclass constructor doesn't explicitly call `super(...)`. What does Java do?
Q3.Can a single constructor call both `this(...)` and `super(...)`?
Q4.In what order do static blocks, instance initializer blocks, and the constructor body actually execute when an object is first created?
Q5.Can a constructor be declared `private`, and if so, why would you do that?
Q6.A `final` instance variable isn't initialized inline at declaration. Where must it be assigned?
Q7.Can an abstract class have a constructor, even though `new AbstractClass()` is never allowed?
Q1.Can an interface declare instance (non-static) fields holding mutable state?
Q2.Since Java 8, interfaces can have `default` methods with full bodies. Does that mean an interface can finally be instantiated with `new` if ALL its methods are default?
Q3.A class implements two interfaces that both declare the same `default` method with conflicting bodies. What must the class do?
Q4.What's the central design trade-off between an abstract class and an interface?
Q5.Can an abstract class have zero abstract methods?
Q6.What must a concrete (non-abstract) class do when it extends an abstract class?
Q7.What is a "marker interface" — like `Serializable` or `Cloneable`?
Q8.What actually qualifies an interface as a "functional interface" usable with a lambda expression?
Q1.Does dynamic dispatch (polymorphism) apply to instance variable (field) access the same way it applies to overridden methods?
Q2.A superclass reference points to a subclass object. The subclass "hides" (doesn't override) a static method from the parent. Which version runs when called through the superclass reference?
Q3.Upcasting — assigning a subclass object to a superclass-typed reference — is:
Q4.Downcasting — explicitly casting a superclass reference back to a subclass type — can:
Q5.What's the safest way to check an object's real runtime type before downcasting it?
Q6.Why is overriding called "runtime polymorphism" but overloading called "compile-time polymorphism"?
Q7.A subclass method shares the exact name and identical parameters with a superclass method, but has a different, non-covariant return type. What happens?
Q1.What's the actual difference between `==` and `.equals()` for two non-primitive Java objects?
Q2.A class overrides `equals()` but NOT `hashCode()`. What problem can this cause?
Q3.Can two genuinely unequal objects (`a.equals(b)` returns `false`) still share the same `hashCode()`?
Q4.What does the default `Object.clone()` actually do, with no override (a "shallow clone")?
Q5.What must a class do to allow `clone()` to be called on it without throwing `CloneNotSupportedException`?
Q6.If a class doesn't override `toString()`, what does `System.out.println(obj)` print by default?
Q7.Why does `String` override `equals()` to compare character content, while a custom class without an override never considers two objects with identical field values "equal"?
Q1.What's the actual difference between `final`, `finally`, and `finalize()`?
Q2.Can a `final` method be overloaded in a subclass?
Q3.Can a `final` class be extended by a subclass?
Q4.Can the `this` keyword be used inside a `static` method?
Q5.What does the `super` keyword let a subclass do?
Q6.What's the visibility scope of the default (package-private) access level — when NO modifier is written at all?
Q7.How does `protected` access actually differ from the default (package-private) access level?