Overloading and Overriding - Coddicted

Overloading and Overriding

 S.No.    Overloaded Methods  Overridden Methods
 1.  Arguments  Must Change  Must not change
 2.  Return Type  Can change  Can’t change except for covariant returns
 3.  Exceptions  Can change  Can reduce or eliminate. Must not throw new or broader checked exception
 4.  Access Modifiers  Can change  Must not make more restrictive (can be less restrictive)
 5.  Invocation Reference type determines which overloaded version is selected. Happens at compile time. Object type determines which method is selected. Happens at runtime.

Will it be called overriding if I do not change the parameters or return type, instead throw a different exception in the method signature?

Yes it will be called overriding, however it must not throw new or broader checked exception.

Back To Top
Rate this post

Leave a Reply