Consider the following method header. Which of the following is the method signature?
public static int combine(String s, int n)
combineint combine(String, int)combine(String s, int n)combine(String, int)combine(String, int).
Explanation
A method header carries more than the signature. The signature keeps only the method name and the parameter types in order, and it drops the access modifier, static, the return type, and the parameter names.
- A is not correct: the method name alone leaves out the ordered list of parameter types, which is the other half of a signature.
- B is not correct: the return type
intbelongs to the method header, and the return type is never part of a method signature. - C is not correct: parameter names such as
sandnare not part of a signature, which lists only the parameter types.