Sunday 24 March 2013

A Java Program which show the use of Methods Overloading. //DemoStrate Method OverLoading....


class OverLoadDemo
{
void test()
{
System.out.println("No Parameters");
}
//OverLoad Test for One Integer Parameters.....
void test(int a)
{
System.out.println("a:"+a);
}
//Overload test for two Integer Parameters.....
void test(int a,int b)
{
System.out.println(" a :" +a+ " b :"+b);
}
//OverLoad test for a Double Parameters.....
double test(double a)
{
System.out.println("Double a:"+a);
return a*a;
}
}
class OverLoad
{
public static void main(String args[])
{
OverLoadDemo ob=new OverLoadDemo();
double result;
//Call all Versions of test()......
ob.test();
ob.test(10);

ob.test(10,20);
result=ob.test(123.2);
System.out.println("Result of ob.test(123.2): "+result);
}
}

No comments:

Post a Comment

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...