← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Amazon SWE interview with a classic OOP theory question plus a live coding component. Pretty standard technical phone screen stuff, though the combination of explaining concepts AND writing code in the same question caught me slightly off guard.

Questions Asked (1)

Q1

Explain the difference between inheritance and polymorphism in OOP, then write a code example where a child class overrides a parent method and that override gets called polymorphically.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

I knew the definitions fine but fumbled a bit when they asked me to show polymorphism in the code itself, not just write a subclass.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly defining inheritance as a mechanism for code reuse and establishing an 'is-a' relationship, and polymorphism as the ability of different types to respond to the same interface. Then, provide a concise code example that demonstrates method overriding and dynamic dispatch, explaining how the child class's method is called at runtime based on the actual object type.

Pro tip: Emphasize that polymorphism enables extensibility and decoupling, which are crucial for scalable systems like those at Amazon. Mention that while inheritance is one way to achieve polymorphism, composition and interfaces often provide more flexible designs.

1. Define Inheritance

Explain that inheritance allows a child class to acquire properties and methods from a parent class, promoting code reuse and hierarchical classification.

2. Define Polymorphism

Describe polymorphism as the ability of objects of different classes to be treated as objects of a common superclass, with method calls resolved at runtime (dynamic dispatch).

3. Contrast the Two

Highlight that inheritance is about reusing and extending behavior, while polymorphism is about flexibility in invoking behavior, often enabled by inheritance but also achievable via interfaces.

4. Provide Code Example

Write a simple code snippet (e.g., in Java or Python) with a parent class and a child class that overrides a method, then show a polymorphic call using a parent reference to a child object.

5. Explain the Output

Walk through the code to show that the child's overridden method is invoked, demonstrating dynamic dispatch and the practical impact of polymorphism.

Key Points to Mention

  • Inheritance establishes an 'is-a' relationship and promotes code reuse.
  • Polymorphism allows a single interface to represent different underlying forms (e.g., method overriding).
  • Method overriding vs. method overloading: overriding is runtime polymorphism, overloading is compile-time.
  • Dynamic dispatch: the JVM/CLR determines which method to call based on the actual object type at runtime.
  • Polymorphism enables writing generic code that can work with multiple types, enhancing extensibility.
  • Inheritance can lead to tight coupling; consider composition or interfaces for more flexible designs.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.