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 do you sort arraylist in descending order?
What are the object and class classes used for?
How can you handle java exceptions?
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread
Which is easier netbeans or eclipse?
Under what conditions is an object’s finalize() method invoked by the garbage collector?
Is string is a data type?
What are synchronized methods ?
What is == mean?
What are the characteristics of java?
Does string is thread-safe in java?
How to disable caching on back button of the browser?
In java, what is the difference between method overloading and method overriding?
Is 0 true or false?
Is vector thread safe in java?