- Overloaded methods MUST change the argument list
- Overloaded methods CAN change the return type
- Overloaded methods CAN change the access modifier
- Overloaded methods CAN declare new or broader checked exceptions
- A method can be overloaded in the same class or in a subclass
- The overriding method cannot have a more restrictive access modifier than the method being overridden (Ex: You can’t override a method marked public and make it protected).
- You cannot override a method marked final.
- You cannot override a method marked static.
1.They appear in the same class or a subclass.
2.They have the same method name but, have different argument lists(Compulsory).
3. Can have different return type(Not compulsory).
4. It has nothing to do with inheritance and polymorphism.
Interfaces cannot be instantiated— they can only be implemented by classes or extended by other interfaces.
Interface in Java
Interfaces cannot be instantiated, but rather are implemented. A class that implements an interface must implement all of the methods described in the interface, or be an abstract class.
Abstraction in Java
"If a class is abstract and cannot be instantiated, the class does not have much use unless it is subclassed."
A parent class contains the common functionality of a collection of child classes, but the parent class itself is too abstract to be used on its own.
DDD (Deadly Diamond of Death)
Java doesn't support multiple inheritance because of Deadly Diamond of Death(DDD). What it is ?? Here is an example--
Multilevel Inheritance in Java
"Cow Class" calling methods that are available inside classes "Herbivore & Animal". Though "Cow" extends only class "Herbivore", it would in turn inherit the properties of "Animal" extended by "Herbivore" .
Base classes(child class) can inherit attributes and behavior from pre-existing classes (superclasses, parent classes)
Single level inheritance