I came across this question:
==========================================================
class B {
static int m1(byte b) {;
return b; // 1
}
static int m2(char c) {;
return c; // 2
}
static int m3(short s) {
return s; // 3
}
static int m4(long l) {
return l; // 4
}
static int m5(float f) {
return f; // 5
}
public static void main(
String[] args) {
byte b = 1;
char c = 'c'-'a';
short s = 3;
long l = 4L;
float f = 5.0f;
System.out.print(""+m1(b)+m2(c)+m3(s)+m4(l)+m5(f));
}
}
What is the result of attempting to compile and run the program?
a. Prints: 12345
b. Prints: 12345.0
c. Prints: 15
d. Prints: 15.0
e. Compiler Error at 1.
f. Compiler Error at 2.
g. Compiler Error at 3.
h. Compiler Error at 4.
i. Compiler Error at 5.
j. Runtime Error
k. None of the Above
==========================================================
Why the answer is h and i since all the type of argument match the method parameters ?
Rgds,
Dominic