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 final keyword denotes in java?
What is predicate in java?
What is the largest long allowed by java?
Why is boolean important?
What is byte code and why is it important to java’s use for internet programming?
Give few difference between constructor and method?
Write a program to print 15 random numbers using foreach of java 8?
What is constant in programming?
Can we call thread start () twice?
Name few java.lang classes introduced with java 8 ?
what is the constructor and how many types of constructors are used in java?
What does bitwise or mean?
What is the parse method in java?
What is OOP Language?
Is java a super set of javascript?