Method overloading program in java

Write a program in java to demonstrate the Method Overloading

 
public class MethodOver 
{
 void test()
 {
  System.out.println("No parameter");
 }
 void test(int a)
 {
  System.out.println("A="+a);
 }
 void test(int a,int b)
 {
  System.out.println("A="+a+" B="+b);
 }
 void test(double s)
 {
  System.out.println("S="+s);
 }
 public static void main(String[] args) 
        {
  MethodOver o=new MethodOver();
  o.test();
  o.test(10);
  o.test(10,20);
  o.test(10.203);
 }
}

Output

0 comments:

Post a Comment