answersLogoWhite

0

Multiple methods with the same name is called method overloading. The way to do this is to have the different methods accept different parameters.

Examples: Adding two values and returning the result. Let's use different methods for adding various numeric primitives.

public static int add(int a, int b) {

return a + b;

}

public static short add(short a, short b) {

return a + b;

}

public static long add(long a, long b) {

return a + b;

}

public static float add(float a, float b) {

return a + b;

}

public static double add(double a, double b) {

return a + b;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Are true false and null Java keywords?

True and false are literals(special built-in value) in java and cannot be used as keywords.


The methods cannot have the same name in java true or false?

False. Methods in a class can have the same name as long as they have a different signature. You cannot duplicate method code inside a class but you can always have methods that have the same name but a different signature. Ex: Here I have created two methods in a class that have the same name "sum" but have a different argument types, and return types and hence perfectly allowable in a java class. Public class PolymorphismExample { public int sum(int a, int b){ return a + b; } public double sum (double a, double b){ return a + b; } }


Mixtures cannot be separated true or false?

False. Mixtures can be separated using various methods such as filtration, distillation, chromatography, and evaporation.


The name of a Java program file must match the name of the class with the extension java A True B False?

True


In Java method usually hold the properties of an object. True or False?

true


Why is the statement 'This sentence is false' so confusing?

In the logical sense, sentences must be either true or false and not both. "This sentence is false" cannot be true because that would mean that it is false, and it cannot be both. It also cannot be false because that would mean that it is true, and it cannot be both. Therefore, if it is true or false, then it is both true and false. Therefore it is either neither true nor false or both true and false; therefore, in the logical sense, it is not a sentence. However, it says it is a sentence; therefore, it is lying; therefore, it is false.


Is it true or false that a computer cannot disobey programming instructions?

false


Is it true or false that scientific methods have two basic types?

true


Is odd numbers cannot be composite true or false?

False


caves cannot form underwater only on land true or false?

true


A theorem is proved using a geometric proof true or faulse?

Neither true nor false. Some theorems can be proven using geometric arguments and methods, others cannot.


True or false- The volume of a gas cannot be measured?

false