Posted On: Oct 13, 2020
Differences between overloading and overriding
Overloading | Overriding |
---|---|
Overloading is performed at compilation time. | Overriding is performed at runtime |
Overloading is also called static binding. | Overriding is also called dynamic binding. |
Overloading is done within the class. | Overriding occurs in between two classes that have an IS-A (inheritance) relationship. |
It is an example of compile-time polymorphism. | It is an example of run time polymorphism. |
Overloading Example: class ExampleClass{ static int sum(int a,int b){return a+b;} static int sum(int a,int b,int c){return a+b+c;} } | Overriding Example: class Animal{ void eat(){System.out.println("eating...");} } class Dog extends Animal{ void eat(){System.out.println("eating bread...");} } |
Never Miss an Articles from us.
It is a process in java through which multiple threads can be executed simultaneously. A thread can be explained as a lightweight sub-process, it is the smallest unit of processing. Both multiprocessi...
In Java, A HashMap is a map used to store mappings or links of key-value pairs that works on the hashing principle. It is considered as a data structure that allows us to store objects and retrieve it...