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

About The Author
TekTips Videos

Number Of articles Posted
27
Number Of Messages Posted
0
Joined Date
04/02/2013
   
Author
Messages
Posted:
Post Your Comments
Name (Max 50 Chars)
Comments

 
TekTipsDownload
GateExam
Academic Projects
TekTipsExperts
Android