nerdexam
Oracle

1Z0-803 · Question #101

Which code fragment cause a compilation error?

The correct answer is D. double y1 = 203.22;. Exception in thread "main" java.lang.Error: Unresolved compilation problem: Type mismatch: cannot convert from double to float

Working with Java Data Types

Question

Which code fragment cause a compilation error?

Options

  • Afloat flt = 100F;
  • Bfloat flt = (float) 1_11.00;
  • Cfloat flt = 100;
  • Ddouble y1 = 203.22;
  • Eint y2 = 100;

How the community answered

(24 responses)
  • A
    4% (1)
  • D
    96% (23)

Explanation

Exception in thread "main" java.lang.Error: Unresolved compilation problem: Type mismatch: cannot convert from double to float

Topics

#primitive types#float#double#literals

Community Discussion

No community discussion yet for this question.

Full 1Z0-803 Practice