Answers for "method overloading program in java"

0

method overloading in java

/*A class having multiple methods with
same name but different parameters 
is called Method Overloading*/

public class Names{
	static void name(String fname,String lname){
		System.out.println("My firstname is "+fname+" and lastname is "+lname);
	}
	static void name(String fname,String mname,String lname){
		
		System.out.println("My firstname name is "+fname+" and middlename is "+mname+" and lastname is "+lname);
	}
	public static void main(String[] args){
		Names.name("Khubaib","Ahmed");
		Names.name("Khubaib","Imtiaz","Ahmed");
	}
}
Posted by: Guest on August-25-2021
0

Method overloading in Java

public void Square ( int number ) 
{
 int square = number * number;
 System.out.printIn(“Method with Integer Argument Called:“+square);
 }
public void Square(double number)
 {
 double square = number * number; 
System.out.printIn(“Method with double Argument Called:“+square);
}
public void Square(long number)
 { 
long square = number * number;
System.out.printIn(“Method with long Argument Called:“+square);
}
Posted by: Guest on July-26-2021

Code answers related to "method overloading program in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language