113k views
5 votes
Which method signature would not overload this method?

a)void add (double a, int b)
b)void add(int a, int b, int c)
c)void add(String a, String b)
d)void add(int a, int b)
e)int add (double a, double b)

User LifeQuery
by
7.4k points

2 Answers

0 votes

Final answer:

The method signature 'void add(int a, int b)' would not overload an existing method with the same signature, as it is identical and would cause a conflict.

Step-by-step explanation:

The question is asking which method signature would not overload an existing method. Overloading occurs when two methods have the same name but different parameter lists in the same scope. Each provided option (a, b, c, e) differs in parameter types or counts, so these would constitute valid overloads. Option d) void add(int a, int b) has the same signature as the existing method, assuming that the original method also has this signature. Consequently, it would not overload the method but instead conflict with it, as the signatures are identical.

User Prisoner ZERO
by
8.4k points
2 votes

Final Answer:

The method signature that would not overload the given method is: c) void add(String a, String b).

Step-by-step explanation:

Method overloading occurs when multiple methods within the same class have the same name but different parameter lists. In the given method, the original signature is void add(int a, int b). Overloading would involve creating new methods with different parameter lists.

Options (a), (b), and (e) represent potential overloads as they have different parameter types or counts. Option (c), however, has a different parameter type (String) but the same count (two parameters) as the original method. Therefore, it would not be considered an overload but a separate method with a distinct signature.

Option C is the answer.

User Chris Michael
by
7.7k points