Java SE 8 Programmer I — Question 198

Which two code fragments cause compilation errors? (Choose two.)

Answer options

Correct answer: A, C

Explanation

Option A causes a compilation error because it attempts to assign a double to a float variable without explicit casting, which is not allowed. Option C is incorrect because 'Float' should be 'float' in Java, leading to a compilation error. The other options are valid and do not produce compilation errors.