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 destroy method?
Why do we need wrapper class?
Explain static nested classes ?
How do you escape in java?
How do you override a private method in java?
What is flush buffer?
What is heterogeneous in java?
What is the difference between hashmap and hashtable? What is an interface?
What is the use of System class?
What do you know about the garbate collector?
What things should be kept in mind while creating your own exceptions in java?
Why collection is called framework in java?
What are singleton services?
What method is used to specify a container's layout in java programming?
what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????