A

Admin • 828.03K Points
Coach

Q. What is the output of the following code?

Code:
double x = 5;
double y = 3;
System.out.println(x / y);
  • (A) 1
  • (B) 1.67
  • (C) 2
  • (D) 1.5
  • Correct Answer - Option(B)
  • Views: 16
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
When dividing two doubles in Java, the result is a double. In this case, the division of 5.0 by 3.0 is equal to 1.6666666666666667, which is printed to the console.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.