English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Explain how methods with multiple parameters are declared. Describe two examples of Java-based applications that might use methods that have two or more parameters. Provide detail about where those applications would be used.

2007-08-09 11:42:01 · 3 answers · asked by kahmellion 2 in Computers & Internet Programming & Design

3 answers

The multiple parameters are listed in order in the method declaration.

For example, in the Math class, the method to compute one number raised to another number's power:

public static double pow(double a, double b)

That's one example of an application where two or more parameters are required. Another example is the static method on Integer which can parse numbers in multiple bases (for example, binary, hex, etc.) which takes the String to parse, and the radix (base):

public static int parseInt(String s, int radix)

2007-08-09 11:45:42 · answer #1 · answered by McFate 7 · 1 0

// handling methods with 2 parameters
class HandlingParameters {

void test(int a, int b) {
System.out.println("a and b: " + a + " " + b);
}

}
class MultiplParametes {
public static void main(String args[]) {
HandlingParameters ob = new HandlingParameters();
double result;
// call all versions of test()
ob.test();

//call multiple parameters
ob.test(10, 20);

}
}

====================
inside class HandlingParameters method test recives two arguments int a and int b from object 'ob'.test . This is v.simple example.

2007-08-09 21:53:03 · answer #2 · answered by angel04 3 · 2 0

dhvrm has forgotten a number of his geometry. you may calculate each and every thing a pair of triangle given 3 values in the event that they're: sss ; all 3 aspects aaa ; all 3 angles sas ; 2 aspects and the perspective between them asa ; 2 angles and the element between them inspite of the shown fact that, his answer continues to be somewhat valid. permit's say you desire a thank you to get the gross pay for somebody who works h hours at w salary: double grossPay( double h, double w ){ return h*w; }

2016-11-11 21:37:43 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers