jump to navigation

Method Overloading, Overriding July 27, 2005

Posted by Coolguy in J2SE.

Method Overloading:
A Method having same name but different number or type of parameters or return types.Method overloading is one of the ways that java implements polymorphism. When an overloaded method is called, java uses the type and/or number of arguments to decide which version of the overloaded method to actually call. Overloaded methods may or may not have different return types

Method Overriding:
A Method haveing the same signature as another method.In a class hierarchy, when a method in a subclass has the same name and type signature as a method in its superclass, then the method in the subclass is said to override the method in the superclass.

In order for any particular method to override another correctly :
a. The return type, method name, type and order of arguments must be identical to those of a method in a parent class.
b. The accessibility must not be more restrictive than original method.



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: