Bird
Raised Fist0

What is the outcome?

medium🧠🧾 Concept Trace Q4 of Q15
OOP & Design Patterns - Abstraction - Abstract Class vs Interface - When to Use Which
A developer extends an abstract class that provides a concrete method and declares an abstract method. The subclass overrides the concrete method but does not implement the abstract method. What is the outcome?
AThe subclass must be declared abstract or implement the abstract method to compile.
BThe subclass runtime throws an error when the abstract method is called.
CThe subclass inherits the abstract method implementation from the abstract class.
DThe subclass compiles successfully because it overrides the concrete method.
Step-by-Step Solution
Solution:
  1. Step 1: Understand abstract method requirements

    Abstract methods must be implemented by concrete subclasses or the subclass must be abstract.
  2. Step 2: Analyze subclass behavior

    Overriding concrete methods is allowed but does not satisfy abstract method implementation.
  3. Step 3: Compilation consequences

    Subclass without abstract method implementation must be abstract or compilation fails.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    Abstract methods require implementation or subclass must be abstract [OK]
Quick Trick: Abstract methods must be implemented or subclass declared abstract [OK]
Common Mistakes:
MISTAKES
  • Assuming overriding concrete methods suffices
  • Believing abstract methods have default implementations
  • Thinking runtime errors occur instead of compile errors
Trap Explanation:
PITFALL
  • Candidates confuse concrete method overrides with abstract method implementation requirements.
Interviewer Note:
CONTEXT
  • Checks understanding of abstract class inheritance rules and method implementation.
Master "Abstraction - Abstract Class vs Interface - When to Use Which" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes