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
How many digits is int32?
How many bytes is a string java?
What is the difference between length and length () in java?
Should a main method be compulsorily declared in all java classes?
How do you start a thread?
What is difference between this and super keyword?
Which sorting algorithm is best in java?
Can the garbage collection be forced by any means?
Is simpledateformat safe to use in the multithreaded program?
How many static init can you have?
What is difference between call by value and call by reference?
Why string is a class?
What is a numeric string?
How do you add an element to an arraylist in java?
What is the range of the short type?