Skip to content

JavaIsPolymorphic

Stephen Crowley edited this page Dec 10, 2023 · 1 revision

Java is a polymorphic language. Polymorphism in Java is a concept by which we can perform a single action in different ways. Polymorphism is derived from two Greek words: poly (many) and morphs (forms). In Java, polymorphism allows methods to do different things based on the object that it is acting upon.

There are two types of polymorphism in Java:

  1. Compile-time Polymorphism (Static Polymorphism): This type of polymorphism is achieved by method overloading. In method overloading, multiple methods can have the same name with different parameters within the same class.

  2. Runtime Polymorphism (Dynamic Polymorphism): This is achieved by method overriding. Here, a subclass provides a specific implementation of a method already present in its superclass. In runtime polymorphism, the method call is determined by the JVM at runtime, not at compile time.

Polymorphism is a fundamental concept in object-oriented programming and it helps in making the Java program more flexible and reusable.

Clone this wiki locally