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


Please Help Members By Posting Answers For Below Questions

explain the concept of virtual method invocation in polymorphism in detail?

1717


Why we go for collections in java?

547


What's the difference between int and integer in java?

531


What are the benefits of immutable objects?

535


what do you understand by the term string with respect to java?

529






Can final class have constructor?

500


What is methodological theory?

525


What is the difference between sop and work instruction?

480


Compare Mutex and Semaphore in java.

559


explain multi-threading in java?

555


What is the difference between the final method and abstract method?

540


How to compare two strings in java program?

669


Does hashset allow duplicates in java?

580


What does bitwise or mean?

566


Can we execute a program without main() method?

532