October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Dynamic Method Invocation in Java: What It Means at Runtime

Dynamic method invocation in Java selects an applicable overridden instance-method implementation at runtime, after compile-time resolution determines the method signature.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Java, dynamic method invocation means that an eligible instance-method call can run an overridden implementation chosen at runtime from the target object’s actual class. Compile-time resolution first determines which method signature the call refers to; runtime dispatch then selects the matching implementation. This is the core of polymorphic method calls—not a rule that Java reselects among every overload based on the object’s runtime type.

How dynamic method dispatch works in Java

Consider a variable declared as a superclass or interface type that refers to an object of a subclass. When the variable calls an instance method that the subclass overrides, the call can execute the subclass implementation. The declared type helps determine which method invocation is valid and which method descriptor is resolved; the object’s runtime class guides the subsequent lookup for an applicable overridden implementation.

As an Amazon Associate I earn from qualifying purchases.

The Java Language Specification describes method invocation as involving compile-time resolution and, for relevant invocation modes, runtime lookup. For an ordinary virtual or interface call, lookup starts from the target object’s actual runtime class. The specification also notes that this behavior need not appear as a repeated search: implementations may use per-class dispatch tables or other structures to provide the specified result. Oracle’s Java SE 20 Language Specification, Chapter 15 defines the language behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A small example

class Animal {
    void speak() { System.out.println("Animal"); }
}

class Dog extends Animal {
    @Override
    void speak() { System.out.println("Dog"); }
}

Animal pet = new Dog();
pet.speak();

The reference is declared as Animal, but it refers to a Dog. Since Dog overrides the instance method speak(), this call can use the Dog implementation. The example illustrates the distinction between the reference’s compile-time type and the object’s runtime class; it does not mean every aspect of the call is postponed until runtime. The National University of Singapore’s method-invocation lesson explains the method descriptor and implementation lookup as separate decisions.

Dynamic dispatch is not overload resolution

Overloading and overriding describe different decisions. With overloaded methods, Java resolves which signature a call refers to using compile-time information, including the declared types and argument types. With an eligible overridden instance method, runtime dispatch can choose which class implementation of that resolved method runs.

For example, a class may define both print(Object) and print(String). Which overload a call selects is determined during compile-time resolution, not by rechecking the receiver’s runtime class and choosing a different overload. If the selected signature is an overridable instance method, the implementation for that signature can still be chosen through runtime dispatch.

  • Overloading: selects a method signature during compile-time resolution.
  • Overriding: lets a subclass provide an implementation that may be selected for an eligible instance call at runtime.

Which Java calls use this mechanism?

Dynamic method lookup is especially useful for understanding polymorphic calls to overridden instance methods. It does not describe every Java method call in the same way.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Instance calls: Applicable virtual and interface invocations can use runtime lookup to select an overriding implementation.
  • Static methods: They are not overridden through ordinary instance-method dispatch. Do not treat a static call as a polymorphic instance call.
  • super calls: These use a distinct invocation mode and lookup starting point. They should not be explained as ordinary virtual calls that simply begin lookup at the target object’s runtime class.

The precise rules and invocation modes are specified in Java SE 20’s method-invocation rules.

How reflection relates to dynamic invocation

Reflection is an API for invoking a method represented by a Method object; it is not another name for dynamic dispatch. For an instance method, however, invoking through reflection does not necessarily bypass overriding: the implementation corresponding to the target object’s runtime type can still be used. Android’s Method API reference documents this behavior.

That distinction is useful when reading code: reflection describes how the program identifies and invokes a method through an API, while dynamic dispatch describes how an eligible instance invocation reaches an implementation. Reflection’s presence alone does not define the dispatch behavior.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why the phrase can mean something else

In distributed-systems writing, “dynamic method invocation” may refer to a client requesting a service by describing what it needs without knowing the specific object identifier or class that will provide it. At runtime, the system can discover a suitable service implementation and route the request. In that usage, lookup happens across a service registry or repository rather than through Java’s class-based method dispatch. A ScienceDirect Topics entry drawing on Richard John Anthony’s 2016 Systems Programming presents this separate systems-programming sense.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

So the surrounding context matters: in Java language discussions, the phrase usually concerns runtime selection of an overridden instance implementation; in distributed systems, it can describe runtime discovery and routing to a service.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.