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

How does compareto work in java?

780


Can you extend main method in java?

838


What are the 6 boolean operators?

768


What is the range of the short type?

781


What is high level language in computer?

752


Why Java doesn’t support multiple inheritance?

815


What is the purpose of an interface?

775


How many ways can you break a singleton class in java?

710


What is difference overloading and overriding?

805


How to convert string to byte array and vice versa?

787


What are different access specifiers in java? Explain

831


How big is a 64 bit float?

761


Which java ide is used the most?

750


What is the declaration statement?

713


What are the main differences between notify and notifyAll in Java?

829