QuestionQ119

Working with Java Data Types

Given this code fragment:

Question Image

Which three lines do not compile?

Choose three
  • A Line 7
  • B Line 8
  • C Line 9
  • D Line 10
  • E Line 11
  • F Line 12
Explanation

Java assignment contexts allow widening primitive conversions, including int to float, float to double, and int to double. They do not implicitly perform the narrowing conversions float to int or double to float; those require explicit casts. Thus lines 8, 9, and 11 fail to compile.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!