1)What is polymorphism and what are the types of it in Java?
Word Polymorphism made of two words, poly and morphism. Poly means many and morphism means form so polymorphism means many form. Method overloading and method overriding are example of polymorphism in Java.
2)What is method overriding?
When child class contains same method name and same arguments but different implementation then at runtime child class is called. It is called method overriding or runtime polymorphism.
3)What is method overloading?- public class SumOfDigits{
- public static void m1(String a, int b){
- System.out.println("first method");
- }
- public static void m1(int a, String b){
- System.out.println("Second method");
- }
- public static void m1(int a, double b){
- System.out.println("Second method");
- }
- public static void main(String [] args){
- SumOfDigits.m1("ritesh",2);
- SumOfDigits.m1(3, "ranjan");
- SumOfDigits.m1(5, 6.5);
- }
- }

