Java Fundamentals: Polymorphism and Monolith Versus Microservices

Read the full interview experience this question came from →

Quick Overview

A Java fundamentals question pair: explain polymorphism, including overriding, dynamic dispatch and overload resolution, and compare monolithic and microservices architectures. It tests precise language mechanics, concrete examples, and balanced reasoning about deployment, scaling, consistency and operational trade-offs.

Java Fundamentals: Polymorphism and Monolith Versus Microservices

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

This round opened with Java fundamentals. Two of the questions were reported: explain polymorphism, and compare a monolithic architecture with microservices. ### Clarifying Questions - Should the polymorphism answer focus on Java's mechanics specifically, or on the object-oriented concept in general? - For the architecture comparison, is there a particular system, team size or product stage in mind? ### Part 1 — Polymorphism in Java What is polymorphism? Explain the forms it takes in Java and how the JVM decides which method implementation runs, and give a short code example. ```hint Compile time versus run time Consider which decisions the compiler makes from declared types, and which are deferred until the object's actual class is known. ``` #### What This Part Should Cover - Runtime polymorphism through overriding and dynamic dispatch, contrasted with compile-time overload resolution. - What cannot be overridden (static, private and final methods, and fields), and why. - A concrete example in which a superclass or interface reference points to subclass objects, and the design benefit that brings. ### Part 2 — Monolith versus microservices Compare a monolithic architecture with a microservices architecture. When would you choose each, and what does moving from one to the other cost? ```hint Argue from the team and the domain The choice depends less on technology than on team size, the need for independent deployment, and how cleanly the domain splits. Tie each advantage to the cost that comes with it. ``` #### What This Part Should Cover - Deployment, scaling, fault isolation and technology independence. - The costs of distribution: network failures, data consistency across services, observability and operational overhead. - A reasoned recommendation for a given situation, and an incremental migration path. ### What a Strong Answer Covers - Precise definitions backed by correct Java mechanics, not just textbook phrases. - A concrete example for each part. - Balanced trade-offs rather than presenting microservices as always better. - A link between the two topics: interfaces and polymorphism as the seam that later allows a module to be split out. ### Follow-up Questions - How does the JVM implement virtual method calls, and how does the JIT compiler make them cheap? - Is an overloaded method chosen from the runtime types of its arguments? Show an example where the result surprises people. - How would you keep data consistent when one operation spans two microservices that each own a database? - What is a modular monolith, and when is it a better choice than either extreme?

Overview: A Java fundamentals question pair: explain polymorphism, including overriding, dynamic dispatch and overload resolution, and compare monolithic and microservices architectures. It tests precise language mechanics, concrete examples, and balanced reasoning about deployment, scaling, consistency and operational trade-offs.

Read the full Software Engineer interview experience this question came from

|Home/Software Engineering Fundamentals
Sep 27, 2026
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

This round opened with Java fundamentals. Two of the questions were reported: explain polymorphism, and compare a monolithic architecture with microservices.

Clarifying Questions Guidance

  • Should the polymorphism answer focus on Java's mechanics specifically, or on the object-oriented concept in general?
  • For the architecture comparison, is there a particular system, team size or product stage in mind?

Part 1 — Polymorphism in Java

What is polymorphism? Explain the forms it takes in Java and how the JVM decides which method implementation runs, and give a short code example.

What This Part Should Cover Guidance

  • Runtime polymorphism through overriding and dynamic dispatch, contrasted with compile-time overload resolution.
  • What cannot be overridden (static, private and final methods, and fields), and why.
  • A concrete example in which a superclass or interface reference points to subclass objects, and the design benefit that brings.

Part 2 — Monolith versus microservices

Compare a monolithic architecture with a microservices architecture. When would you choose each, and what does moving from one to the other cost?

What This Part Should Cover Guidance

  • Deployment, scaling, fault isolation and technology independence.
  • The costs of distribution: network failures, data consistency across services, observability and operational overhead.
  • A reasoned recommendation for a given situation, and an incremental migration path.

What a Strong Answer Covers Guidance

  • Precise definitions backed by correct Java mechanics, not just textbook phrases.
  • A concrete example for each part.
  • Balanced trade-offs rather than presenting microservices as always better.
  • A link between the two topics: interfaces and polymorphism as the seam that later allows a module to be split out.

Follow-up Questions Guidance

  • How does the JVM implement virtual method calls, and how does the JIT compiler make them cheap?
  • Is an overloaded method chosen from the runtime types of its arguments? Show an example where the result surprises people.
  • How would you keep data consistent when one operation spans two microservices that each own a database?
  • What is a modular monolith, and when is it a better choice than either extreme?
Loading comments...