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
What is callablestatement? How you can call stored procedure to pass in parameter?
What are the different types of constructor?
explain the concept of virtual method invocation in polymorphism in detail?
How do I start learning java?
Why do we use predicate in java?
What is a java developer salary?
What is toarray method in java?
What is the collection interface?
What do the thread?class methods run() and start() do?
What are the differences between Java 1.0 and Java 2.0?
How do we access static members in java?
What are java packages? What's the significance of packages?
Define an abstract class with reference to java.
What is stack example?
What is pangram in java?