Home / CSE MCQs / JAVA MCQs :: Discussion

Discussion :: JAVA MCQs

  1. What is the output of this program?
    class Modulus {
    public static void main(String args[]) 
    {    
    double a = 25.64;
    int  b = 25;
    a = a % 10;
    b = b % 10;
    System.out.println(a + " "  + b);
    }
  2. A.

    5.640000000000001 5

    B.

    5.640000000000001 5.0

    C.

    5 5

    D.

    5 5.640000000000001

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    Modulus operator returns the remainder of a division operation on the operand. a = a % 10 returns 25.64 % 10 i:e 5.640000000000001. Similarly b = b % 10 returns 5.


Be The First To Comment