Flat 10% & up to 50% off + Free additional Courses. Hurry up!



Polymorphism is the ability to take more than one form. It means you can perform single action using multiple ways. There are two types of polymorphism:

  • Compile time Polymorphism (Method Overloading)
  • Run time Polymorphism (Method Overriding)


1. Compile time Polymorphism (Method Overloading) – The ability to execute the methods which have same name with different arguments are known as method overloading.


public class Intellipaat{

public void sample(int a){



public void sample(String s){



public void sample(int a, int b){

System.out.println((a + b));


public static void main(String []args){

Intellipaat i = new Intellipaat ();



i.sample(10, 20);








2. Run time Polymorphism (Method Overriding) – The ability to execute the method which have same name with same arguments is known as method overriding. It is a process in which a call to an overridden method is determined at runtime rather than compile-time. When reference variable of Parent class refers to the object of Child class then it is known as upcasting.

In method overriding case both classes contain same method so it is  unknown that which method is executed so in this condition JVM decides which method to call at runtime so that’s why it is known as run time polymorphism.


class A


public void sample() //Base class method


System.out.println ("Class A method");



public class B extends A


public void sample() //Derived Class method


System.out.println ("Class B method ");


public static void main (String args []) {

A ob1 = new A(); // Reference and object A

A ob2 = new B(); // A reference but B object(upcasting)

B ob3 = new B(); // Reference and object B







Class A method

Class B method

Class B method

Learn more about Cross-Platform Mobile Technology for Android and iOS using Java in this insightful blog now!

"0 Responses on Polymorphism"

Training in Cities

Bangalore, Hyderabad, Chennai, Delhi, Kolkata, UK, London, Chicago, San Francisco, Dallas, Washington, New York, Orlando, Boston

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.


Sales Offer

  • To avail this offer, enroll before 21st October 2016.
  • This offer cannot be combined with any other offer.
  • This offer is valid on selected courses only.
  • Please use coupon codes mentioned below to avail the offer


Sign Up or Login to view the Free Polymorphism.