QuestionQ54

Working with Java Data Types

Given this code fragment:

Question Image

What is the resulting value?

  • A Compilation fails.
  • B 0
  • C 1
  • D An ArithmeticException is thrown.
  • E 1.1
  • F 0.0
Explanation

Math.round rounds the approximately 33.333 double value to 33. The character 'a' has integer value 97, which is not equal to hexadecimal 0xA (10), so the conditional divisor is 3. Because 10f makes the divisions floating-point operations, the computed float value is approximately 1.1.

Learn more

Community Discussion

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