class Roo
{
float length ;
float breadth ;
Roo(float x, float y)
{
length=x;
breadth=y;
}
Roo(float x)
{
length=breadth=x;
}
double area()
{
return (length * breadth);
}
}
class saisar
{
public static void main(
String a[])
{
double s;
Roo obj = new Roo (4,2);
s=obj.area();
System.out.println(s);
Roo obj1 = new Roo (5);
s=obj1.area();
System.out.println(s);
}
}
Here for constructor overloading if i create 2 same
objects like
Roo obj = new Roo (4,2);
Roo obj = new Roo (5);
It is not accepting
but why the same is true for normal method overloading
i mean even i create same objects like this in method overloading it is accepting like
EXAMPLE
class e
{
float length ;
float breadth ;
double Roo(float x, float y)
{
length=x;
breadth=y;
return (0);
}
double Roo(float x)
{
length=breadth=x;
return 0;
}
double area()
{
return (length * breadth);
}
}
class saisars
{
public static void main(String a[])
{
double s;
e obj = new e ();
obj.Roo(4,5);
s=obj.area();
System.out.println(s);
obj.Roo(4);
s=obj.area();
System.out.println(s);
}
}
in this above program how can i access different method signatures with same object though data is different ? please post your comments