Given the code fragment:
What is the result?
A. An exception is thrown at runtime
B. Compilation fails
C. 13480.0
D. 13480 02
Given the code fragment:
What is the result?
A. An exception is thrown at runtime
B. Compilation fails
C. 13480.0
D. 13480 02
13480.0
-int + float converts the int to a float. Then a float is returned
-SIDE NOTE: the underscore can only be between two digits
C:
# javac Test26.java
# java Test26
13480.0
————
(12345.01 >=12345.00) ?! yes, then var1 = 12456 and var2 = var1+ 1024, which is 13480
public class Test {
public static void main(String args[]) {
float var1=(12_345.01 >= 123_45.00)?12_456:124_56.02f;
float var2=var1+1024;
System.out.println(var2);
}
}
correct answer is c
The correct ans is:D
Answer is C
D