Overloading Methods - Java
Overloading refers one name with multiple forms by showing the difference in the arguments list. this is also called method overloaind or static polymorphism or compiletime polymorphism or early binding. the function selection involves the following steps.
- it will check the exact matching
- when an exact matching is not found it will check the integral pramotions.
- if either of them fails it will check the internal conversitions.
- if all of them failed it will check the userdefined conversions.
WRITE A PROGRAM ON OVER LOADING FUNCTIONS WITH TYPE CONVERSION.
class Abc
{
public void get(int x,int y)
{
System.out.println(x+y);
}
public void get(double x,double y)
{
System.out.println(x*y);
}
public void get(int x)
{
System.out.println(x);
}
}
class Sample
{
public static void main(String args[])
{
int a=10;
Abc k=new Abc();
k.get(a,20);
double p=20.4;
double q=10.1;
k.get(p,q);
k.get(a);
}
}
For
More Explanation
&
Online Classes
More Explanation
&
Online Classes
Contact Us:
+919885348743
+919885348743