Correct Answer : D
Two variables x
of type int
and 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.