Method overloading is the way of implementing static/compile time polymorphism in java. Method overloading means more than one methods in a class with same name but different parameters. Parameters can be differing in types, numbers or order. Compiler resolve method call by matching method signature at compile time, that’s why it is known as static or compile time polymorphism. It is also known as static binding.
If a subclass provides a method with the same signature (name and parameter) as in its super class, then subclass overrides the method of its super class. This process of overriding a super class method by subclass is known as method overriding.
Java interview questions on method overloading and overriding
- What is method overloading in java?
- Can we declare an overloaded method as static and another one as non-static?
- Can overloaded methods be synchronized?
- Can we declare overloaded methods as final?
- Can overloaded method be overridden?
- What is method overriding in java?
- Can static method be overridden?
- Difference between method overloading and overriding in java?
- Can we override private methods in java?
- Is it possible to override non static method as static method?