Oracle Certified Associate Java Se 8 Programmer · Free Practice Question Easy
Question 6
Which of the following declarations are valid ?
-
A
int i = 10.5; -
B
float f =(float) 10.5; -
C
double d = 10.5; -
D
float f = 10.5;
Reveal correct answers
Correct answers: B, C
Explanation
Every floating point literal is by default of double type. Hence we cannot assign to int and float variables directly.Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
You must be logged in to post a comment.
