Programming Tutorials

Comment on Tutorial - Method Overloading sample in Java By Ganesh Iyer



Comment Added by : Subhojit Das

Comment Added at : 2014-10-09 07:31:20

Comment on Tutorial : Method Overloading sample in Java By Ganesh Iyer
//Program of Method Overloading with Runtime Values

import java.util.Scanner;


class cal
{
void add(int a,int b)
{
System.out.print("Addition of First 2No.s is : " +(a+b));
}

void add(int a,int b,int c)
{
System.out.print("Addition of Three No.s is : " +(a+b+c));
}

}

class mthdovrng
{
public static void main (String args[])
{
int a,b,c;
Scanner input=new Scanner(System.in);
System.out.print("Enter First No. : ");
a=input.nextInt();
System.out.print("Enter Second No. : ");
b=input.nextInt();
System.out.print("Enter Third No. : ");
c=input.nextInt();
cal ob=new cal();
ob.add(a,b);
ob.add(a,b,c);
}
}


View Tutorial