P

Pushkar • 380 Points
Valuable

Q. What is the output of the following code?

Code:
int x = 5;
int y = 3;
System.out.println(x % y);
  • (A) 1
  • (B) 1.67
  • (C) 1.5
  • (D) 2
  • Correct Answer - Option(D)
  • Views: 119
  • Filed under category JAVA

Explanation by: Pushkar
The modulus operator (%) returns the remainder of integer division. In this case, 5 divided by 3 has a remainder of 2, 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.


Question analytics