What is the output of the following code?
class Test {
static int square(int x) {
return x * x;
}
public static void main(String[] args) {
System.out.println(square(2.5));
}
}
The method square
expects an int
argument, but 2.5
is a double
. Java does not perform implicit narrowing conversions.
The method square
expects an int
argument, but 2.5
is a double
. Java does not perform implicit narrowing conversions.