How to implement function Overloading in Java

Rate this article
0 out of 5

In this video tutorial, we will show you how to implement Method Overloading in java. After watching the video, download and play around with the source code to reinforce what is learned in the tutorial.

 

Source Code
MethodOverloading

import java.io.*;
class Area
  double a,x;
  void calculate( )
  {
     a=4;
     x=a*a;
    System.out.println("Area of square="  +x);
 }
 void calculate(double r)
 {
   x=2*3.14*r;
   System.out.println("Area of circle="  +x);
 }
 void calculate(double p,double q)
 {
    x=p*q;
   System.out.println("Area of rectangle=" +x);
 }
}

class MethodOverloading
{
   public static void main(String args[])
   {
       Area objArea=new Area();
       objArea.calculate();
       objArea.calculate(6);
       objArea.calculate(5.2,3.4);
  }
}


Source Code

Joined Date : 04/02/2013
Articles
Posted
27
Messages
Posted
0


Click Here to See Full Profile
   
Author
Messages
Posted:
Post Your Comments
Name (Max 50 Chars)
Comments

 
TekTipsDownload
GateExam
Academic Projects
TekTipsExperts
Android