Java
Programming and Technical
Programming
Definition
Q. What is method overloading and method overriding?
A. Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding.
Read Solution (Total 1)
-
- Method Overloading:
In a class we have multiple methods with same name but with different formal arguments. We have to perform same operation for different types.
Example: add(1,2) ----> It is used to add two numbers.
add("Siva",1)-----> It is used to concatinate.
Method Overriding:
It means the super class method gets implement with the help of subclass method only when we create subclass object is called method overriding. We have to follow some rules to do method overriding
1.Is a relationship is mandatory for two classes
2. Sub class s object is created.
3. both the methods follow same name and returntype. - 3 years agoHelpfull: Yes(0) No(0)
Java Other Question