Sign up now
to enroll in courses, follow best educators, interact with the community and track your progress.
54 plays

This lesson is about polymorphism its types and the difference between its types overloading and overriding.

Kshethra Annarapu
Hey everyone,I am Kshethra. I really love explaining to someone it somehow turned up to my passion.I'm really happy to fulfill my passion .

Unacademy user
Difference between epidemic and pandemic - 1. An epidemic refers to a contagious, infectious or viral illness that spreads to many people in one specific geographic region. 2. Like an epidemic, a pandemic refers to a contagious, infectious or viral illness that spreads. However, unlike an epidemic, a pandemic is not limited to one specific geographic region. Instead , a pandemic has the potential to include millions of people in many areas and countries across the globe.

  2. POLYMORPHISM It means to process the objects differently based on its data type.The two types are: Static Polymorphism Dynamic Polymorphism The method Overloading comes under Static Polymorphism and Overriding comes under Dynamic Polymorphism Overloading is two methods having the same ame in a same class Overriding means a derived class implementing the super class method.

  3. OVERLOADING PROGRAM class OverloadDemo void test) System.out.println( No parameters"); void test(int a) System.out.println("a:"+a); void test(int a,int b) System.out.Printin ("a and b"ta+ +b);

  4. class Overload public static void main(String args|]) (); OverloadDemo obi-new OverloadDemo ob.test); ob.test(I0 ob.test(10); ob.test(10,20):

  5. OVERRIDE PROGRAM class Vehcile void run0 System.out.println("Vehcile is running); class Bike extends Vehcile void run) void run0) System.out.println("Bike is running safely"); public static void main(String argsI) Bike obj=new obj(); obj.run0:

  6. Trouble shooters . Can we overide a static method? No, a static method cannot be overriden as static method is bound to class whereas instance method is bound to object. Can we Override a main method? No,because it is a static method.

  7. Differences between Overloading and Overriding Overloading is used . to increase the readability of a program Overloading is performed within the Overriding occurs in class only . Overriding is used to provide specific implementation of the method which is there in super class. two classes. e Here,the parameter Here,the parameters must be different in the methods. in the methods must be same