What will be the output of the following program?
Correct Answer : D
x of type
y of type
double are declared and initialised. The first display statement prints
x % 10 i.e.,
42 % 10 = 2.
The second display statement prints
y % 10 i.e.,
42.25 % 10 = 2.25.
Note: The modulus operator gives the remainder. That is when
a % b is used it gives the remainder when
a is divided by
b. Floating point modulus is allowed in Java.
Topic: Modulus Operator In Java