Menu
Topics Index
...
`

Modulus Operator


If you need explanation Read this topic

If you need Answer Take test on this topic

Modulus Operator
What is the output of the following program?
public class GuessOutput {
    public static void main(String[] args) {
        int a = 56;
        int b = -8;
        int c = a % b;
        int d = b % a;
        System.out.println(c + ", " + d);
    }
}

A. -7, -8
B. -0, -8
C. -0, 8
D. 0, -8
E. 0, 8
Topic: Modulus Operator In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

answer is d since numerator sign is only considered not denominator

Posted by Shashanka Mogaliraju    2013-08-23 04:05:39


ans is D.

Posted by Sagar Kamble    2013-08-23 07:43:04


E

Posted by Meena Priyadarshini    2013-08-23 12:42:20


ans is d since 0 not an integer to be negative or positive and -8 since the fraction becomes negative

Posted by Shiva Goud    2013-08-23 13:04:53


d

Posted by Sadhana Dasari    2013-08-23 14:28:54


E

Posted by Deepika Vellapalem    2013-08-23 14:43:44


answer is d : since 0 not an integer to be negative or positive and -8 since the fraction becomes negative

Posted by Deepika Vellapalem    2013-08-23 14:44:31


Congratulations Shashanka Mogaliraju. You are this dose winner. Please send us your mobile details in a private message and we will process the recharge asap.

Posted by Merit Campus    2013-08-24 05:44:35


© meritcampus 2019

All Rights Reserved.

Open In App