Consider the following definitions:
void a (Object o, long x, long y) // defn 1
void a (String s, int x, long y) // defn 2
void m (Object o, int x, long y) // defn 3
void a (String s, long I, int y) / defn 4
and suppose you have the following variable declarations:
Object u;
int a;
long b;
For each of the following calls, determine which definitions would match a particular call; also decide whether the call is legal, and if so, which of the preceding definitions is selected:
m (v ,a ,b);
m (v, a, a);
m (v, b, a);
m (v ,b ,b);
m (o, b, b);
m (0, a, a);
All the calls below are calls to the method "m" - hence this definition 3. If we assume that "v" is an object, "a" is an int, "b" is a long, then the first two calls are correct. Otherwise, all calls are invalid.
Comments
Leave a comment