Java OCA OCP Practice Question 1732

Question

Which of the following expressions will be evaluated using floating-point arithmetic?.

Select the three correct answers.

  • (a) 2.0 * 3.0
  • (b) 2 * 3
  • (c) 2/3 + 5/7
  • (d) 2.4 + 1.6
  • (e) 0x10 * 1L * 300.0


(a), (d), and (e)

Note

A binary expression with any floating-point operand will be evaluated using floating-point arithmetic.

Expressions such as 2/3, where both operands are integers, will use integer arithmetic and evaluate to an integer value.

In (e), the result of (0x10 * 1L) is promoted to a floating-point value.




PreviousNext

Related