explain about method overloading and method overriding with
difficult examples

Answer Posted / suja

Overloading:
Method Overloading, allows the user to achieve the compile time polymorphism.Overloaded methods are always the part of the same class. These methods have the same name, but they may take different input parameters.The arguments passed to a overloaded method may differ in type or in number, or both.
Overloaded methods may have the same or different return types.
Overriding:
Method overriding in java means a subclass method overriding a super class method. Superclass method should be non-static. Subclass uses extends keyword to extend the super class. In the example class B is is the sub class and class A is the super class. In overriding methods of both subclass and superclass possess same signatures. Overriding is used in modifying the methods of the super class. In overriding return types and constructor parameters of methods should match .

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are thread groups?

578


How do you use compareto method?

537


Can we use a default constructor of a class even if an explicit constructor is defined?

657


What is an association?

551


What is array in java?

537






What methodology can be utilized to link to a database?

506


Which keyword specify that a variable is effectively final ?

578


Write a java program to check if a number is prime or not?

539


Is there any limitation of using inheritance?

571


What is string data?

559


what are the methods in object?

633


What are the actions that can occur when a thread enters blocked state?

585


Can a method be static?

528


Why Java is not pure Object Oriented language?

650


What does java edition mean?

540