Java function overloading and method overloading are same
Answers
━━━━━━━━━━━━━━━━━━━━━━━━━
━━━━━━━━━━━━━━━━━━━━━━━━━
Overloading
━━━━━━━━━━━━━━━━━━━━━━━━━
overloading is a condition in which the high current flows through the circuit and at the same time too many appliances are switched on then the total current drawn through the circuit may exceed its rated value.
and condition when the live wire comes in contact with the neutral wire due to which a high current flows in a circuit
━━━━━━━━━━━━━━━━━━━━━━━━━
━━━━━━━━━━━━━━━━━━━━━━━━━
Using overloading write a program to calculate and print the area of a square, rectangle and circle.
class AreaOverload
{
double a;
void area(int side)
{
a=side*side;
System.out.println("Area of a square is :"+a);
}
void area(int len, int br)
{
a=len*br;
System.out.println("Area of a Rectangle is :"+a);
}
void area(double r)
{
a=3.14*r*r;
System.out.println("Area of a circle is :"+a);
}
public static void main(String args[ ] )
{
AreaOverload ar=new AreaOverload();
ar.area(3);
ar.area(4,6);
ar.area(3.5);
}
}