Consider the following method...
public int set (int a, int b, float c) { ...}
Which of the following methods correctly overload the above method?
Select 2 options
A. public int set (int a, float b, int c){ return (int)(a + b + c); } B. public int set (int a, float b, int c){ return this (a, c, b); } C. public int set (int x, int y, float z){ return x+y; /*from w w w . j a va 2s . c om*/ } D. public float set (int a, int b, float c){ return c*a; } E. public float set (int a){ return a; }
Correct Options are : A E
A method is said to be overloaded when the other method's name is same and parameters are different.
Option 2 is not valid Because of the line: return this (a, c, b);
This is the syntax of calling a constructor and not a method.
It should have been: return
this.set (a, c, b);