Expressions and Assignment Statements

AP Computer Science A· difficulty 4/5

double d = 5.0 / 0;
System.out.println(d);

What is printed?

  • A

    Infinity

    check_circle
  • B

    0.0

  • C

    Error

  • D

    NaN

Explanation

Division of a non-zero double by zero produces positive Infinity (no exception is thrown for floating-point division by zero).

Want 10 more like this — adaptive to your weak spots?

Related questions