7. Given the following code, which statement is correct? Please select "A, B, C, D, or E" as correct option.Â
class Sample
{
int add(int x, int y) { return x+y;} // form 1
String add(String x, String y) { return (x+y)+""; } // form 2
double add(int x, int y, int z) { return x+y+z; } // form 3
void add(int x) { System.out.print(x); } // form 4
}
A. form 1 has a conflict with form 2 because parameters in form 2 are different from
parameters in form 1.
B. form 1 has a conflict with form 3 because the number of parameters in form 3 is not equal
to that of form 1.
C. form 2 is the one that will cause conflicts with others because String is not a primitive data
type.
D. form 4 is the one that will cause conflicts because it is the void type.
E. There is no conflict among these four forms.
Answer:
E. There is no conflict among these four forms.
Comments
Leave a comment