Determine output:
public class Test {
static void test(float x){
System.out.print("float");
}
static void test(double x){
System.out.print("double");
}
public static void main(String[] args){
test(99.9);
}
}
public class Test {
static void test(float x){
System.out.print("float");
}
static void test(double x){
System.out.print("double");
}
public static void main(String[] args){
test(99.9);
}
}A. float
B. double
C. Compilation Error
D. Exception is thrown at runtime
Answer: Option B
Solution (By Examveda Team)
floating-point numbers are by default of type double.
99.9 is a double not a float.
To print "float" cast 99.9 to (float)
Join The Discussion
Comments (1)
Related Questions on Data Types and Variables
Which of the following is not a valid identifier for a Java variable?
A. my_var
B. _myVar
C. 3rdVar
D. $var

Please explain this solution