info@meritcampus.com    +91-85006-22255
...
`

### Session 21 Test has these questions

Arithmetic Operators Increment Decrement Compound Assignment Output

What will be the output of the following program?
`class Addition{    public static void main(String s[])    {        int a = 4;        a++;        a += a;        --a;        a = 7 + a;        a *= a;        a -= 3;        System.out.println(" a = " + a );    }}`
 A. Program does not compile B. a = 255 C. a = 253 D. a = 286

Increment Decrement Operators Output

What will be the output of the following program?
`class Operators1 {    public static void main(String[] args)     {        int a = 34;        int b = 21;        int c = a++ + ++b;        int d = --a + --b + c--;        int e = a + +b + +c + d--;        int f = -a + b-- + -c - d++;        int sum = a + b + c + d + e + f;        System.out.println("sum = " + sum);    }}`
 A. sum = 265 B. sum = 263 C. sum = 264 D. Compilation Error

Increment Operators Output

What will be the output of the following program?
`class IncDec{    public static void main(String s[])    {                int a = 1;        int b = 2;        int c;        int d;        c = ++b;        d = a++;        c++;        System.out.println("a = " + a);        System.out.print("b = " + b);        System.out.println("c = " + c);        System.out.print("d = " + d);    }}`
 A. a = 2b = 3c = 4d = 1 B. a = 2b = 3c = 4d = 1 C. Program does not compile. D. a = 1b = 2c = 4d = 2

Modulus Operator Output

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 );    }}`
 A. x mod 10 = 2y mod 10 = 2.25 B. x mod 10 = 2y mod 10 = 0 C. Program does not compile since we can find modulus only for integers. D. x mod 10 = 2y mod 10 = 2.25