Program:
class Area
{
int a,b;
void area(int a)
{
double A=3.14*a*a;
System.out.print("\n\tArea of circle="+A);
}
void area(int a,int b)
{
double B=a*b;
System.out.print("\n\tArea of Rectangle="+B);
}
}
class methodoverload
{
public static void main(String args[])
{
Area A1=new Area();
A1.area(10);
A1.area(5,10);
}
}
Output:
nn@linuxmint ~ $ javac methodoverload.java
nn@linuxmint ~ $ java methodoverload
Area of circle=314.0
Area of Rectangle=50.0
nn@linuxmint ~ $
class Area
{
int a,b;
void area(int a)
{
double A=3.14*a*a;
System.out.print("\n\tArea of circle="+A);
}
void area(int a,int b)
{
double B=a*b;
System.out.print("\n\tArea of Rectangle="+B);
}
}
class methodoverload
{
public static void main(String args[])
{
Area A1=new Area();
A1.area(10);
A1.area(5,10);
}
}
Output:
nn@linuxmint ~ $ javac methodoverload.java
nn@linuxmint ~ $ java methodoverload
Area of circle=314.0
Area of Rectangle=50.0
nn@linuxmint ~ $
Method Overloading in Java
ReplyDeleteThanks for this post
I am DR. GURUJI NAVGRAHA from India a spell caster that has been successfully providing results to my clients for over many years. I use nothing but 100% safe and ancient Indian spiritual methods,I will reunite your ex partner back to you, stop an impending divorce or break-up, and bring back the passion, love, lust, communication and commitment between broken lovers. Don't live in a life unfilled without the one you truly desire. Let me show you the real results you've been searching for,My Powerful Indian
ReplyDeleteSpiritual Spell are :
wedding ritual, healing ritual,Divorce stop ritual,separation ritual,love ritual,protection ritual,self-confidence ritual,child ritual,success ritual,Return Lover ritual,restore passion ritual Save Marriage Spells,Prevent Divorce Spells,Cheating ritual Remove Ex ritual,Business increase,Money
ritual,Famous ritual,Indian Spiritual Healing center is the answer
Email: casterspell481@gmail.com
Whatsap: +919108256518
DR. GURUJI NAVGRAHA