R

Ram Sharma • 3.40K Points
Extraordinary

Q. What will be the output of the following code?

Code:
int a = 10, b = 5;
System.out.println(a / b);
  • (A) 2
  • (B) 0.5
  • (C) 5
  • (D) 15
  • Correct Answer - Option(C)
  • Views: 15
  • Filed under category Java
  • Hashtags:

Explanation by: Ram Sharma

`a / b` with both operands as integers results in integer division: 10 / 5 = 2.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.