Java SE 7 Programmer I — Question 11

Which code fragment cause a compilation error?

Answer options

Correct answer: B

Explanation

Option B causes a compilation error because the underscore in the number 1_11.00 is not valid syntax for a float literal. The other options are syntactically correct; A defines a variable with an incorrect type name, C assigns an integer to a float without casting, D has a typo in 'floatflt' but does not cause a compilation error.