Forum : method overload
Brief description  about Online courses   join in Online courses
View Priti m naik 's Profile

method overload

class overload extends over{


public static void main(String[] args)
{
over o=new over();

o.num(4,7);
o.num(20000000000.4,10000000002.4);
o.num(32.0,4.2);
}
}








public class over{


void num(int x,int y)

{
int sum=0;
sum=x y;
System.out.println("the sum is =" sum);

}


void num(double a,double b)
{
double sub=0;
sub=a-b;
System.out.println("the differnce is =" sub);

}


void num(float c,float d)
{
float mul=0;
mul=c*d;
System.out.println("the mul is =" mul);

}


}



its working perfectly..
for int and double..
float is not executing..whereas double is excecuting twice..

Asked by Priti m naik | Sep 30, 2010 |  Reply now
Replies (2)
View priti m naik 's Profile
thx i got it
Oct 2, 2010
View arun kumar das 's Profile
Please try initializing mul to 1 and try. Also, double check the operators.

Regards,
JT
Oct 1, 2010