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.

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
Online Classes

Contact Us: 9885348743