What restrictions are placed on method overloading and
method overriding?
Answer Posted / aks
The rules for overriding a method are as follows:
¡ The argument list must exactly match that of the
overridden method.
¡ The return type must exactly match that of the
overridden method.
¡ The access level must not be more restrictive than that
of the overridden method.
¡ The access level can be less restrictive than that of
the overridden method.
¡ The overriding method must not throw new or broader
checked exceptions
The rules for overloading a method are as follows:
¡ Overloaded methods must change the argument list.
¡ Overloaded methods can change the return type.
¡ Overloaded methods can change the access modifier.
¡ Overloaded methods can declare new or broader checked
exceptions.
¡ A method can be overloaded in the same class or in a
subclass.
| Is This Answer Correct ? | 20 Yes | 2 No |
Post New Answer View All Answers
What is the use of conditional statement?
What is a copy constructor in java?
Can we clone singleton object in java?
Explain with example the concept of constant variable in java.
What's the difference between an abstract class and interface in java?
What is the use of arraylist in java?
How do you convert an int to a string in java?
What is logical variable?
What variables are stored in stack?
What is a parameter used for?
What is the synonym of framework?
What is an example of declaration?
What is a bubble sort in java?
What is difference between this and super keyword?
What are the types of casting?