Menu
Question Index
...

What will be the output of the following program?

class Modulus
{
    public static void main(String s[])
    {
        int x = 42;
        double y = 42.25;

        System.out.println("x mod 10 = " + x % 10 );
        System.out.println("y mod 10 = " + y % 10 );
    }
}


x mod 10 = 2y mod 10 = 2.25
x mod 10 = 2
y mod 10 = 0
Program does not compile since we can find modulus only for integers.
x mod 10 = 2
y mod 10 = 2.25

Doubts

Problems

Topic: Modulus Operator In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App