Wednesday 28 August 2013

Method Overloading

A class contains multiple method of same name but different parameters known as method overloading.
the signature of method should be different.
we can do this by changing the number of arguments and datatypes.
we consider only signature not the return type and access level. no use of return type and access level of methods  in method overloading.

Example:-

method have same name but different arguments.

Example 2;-


when we call test() ,it calls test with no arguments and when we call test(10) ,it calls test(int i) method with arguments this is known as method overloading...

Example 2-for different arguments.


first we pass double value , it calls test(double j)
we pass int value, it calls test(int i)


No comments :

Post a Comment