Method Overloading:
1. Writing two are more methods with the same name but different signature is called method Overloading.
2. Method Overloading is done in the same class.
3. In Method Overloading method return type can be same or different.
4. JVM decides which method is called depending on the difference in the method signature.
5. Method Overloading is done when the programmer want to extend the already available feature.
6. Method Overloading is code refinement. same method is refined to perform a different task.
Method Overriding:
1. Writing two are more methods with the same name and same signature is called method Overriding.
2. Method Overriding is done in super and sub classes.
3. In Method Overriding method return type should be same.
4. JVM decides which method is called depending on the data type of the object used to call the method.
5. Method Overriding is done when the programmer wants to provide a different implementation for the same features.
6. Method Overriding is code replacement. the sub class method overrides the super class method.
No comments:
Post a Comment