195k views
2 votes
Fill in the parameters in the second method header for the overloaded method "printAge()." The number, type, and order of the method parameters are indicated in the method call from "main()". For example, if the input is "40 Amir," then the output is: "Vicente is 32 years old; Amir is 40 years old."

a) printAge(int age, String name)
b) printAge(String name, int age)
c) printAge(int years, String person)
d) printAge(String person, int years)

1 Answer

3 votes

Final answer:

The correct overloaded method signature that matches the provided input '40 Amir' is 'a) printAge(int age, String name),' as it aligns with the integer and string parameters in the correct order.

Step-by-step explanation:

To determine which method signature matches with the method call from 'main()', you need to look at the input given. Since the input provided was "40 Amir," we can infer that the first parameter is an integer representing the age, and the second parameter is a string representing the name. Hence, the correct method header that will match this method call would be:

a) printAge(int age, String name)

When the method is called with these parameters, like printAge(40, "Amir"), it will correctly adhere to the format expressed in the output example given, "Amir is 40 years old." The other options do not match the required order and type of parameters as they are called in 'main()'.

User Altab Hossen
by
8.4k points