Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | IT Developer <?php echo $page_title; ?>
IT Developer

Operators in Java

Chapter 4

Operators in Java

Class 10 - Logix Kips ICSE Computer Applications with BlueJ


Share with a Friend

Multiple Choice Questions


Question 1

If a = 8 and b = 4, the value of a %= b is ...........

  1. 2
  2. 0
  3. 4
  4. 8

Explanation

    a %= b
⇒ a = a % b
⇒ a = 8 % 4     [Putting values of a & b]
⇒ a = 0    

% is modulo operator that returns the remainder of the division operation. Dividing 8 by 4 gives 2 as quotient and 0 as remainder so the final answer is 0.

Question 2

An operator taking only single operand for its operation is called ...........

  1. A unary operator
  2. A binary operator
  3. A ternary operator
  4. None of these

Question 3

Which one of the following is not a binary operator?

  1. AND
  2. %
  3. ==
  4. !

Explanation

! is the NOT operator that works on only one operand so it is a unary operator not a binary operator.

Question 4

Which one of the following is not a valid operator in Java?

  1. <=
  2. !==
  3. !=
  4. ==

Question 5

The statement i = i + 1 is equivalent to ...........

  1. i++
  2. i += 1
  3. ++i
  4. All of these

Explanation

All the 3 statements increment the value of i by 1.

Question 6

For x = 5, the statement sum = ++x + 8 evaluates to ...........

  1. sum = 12
  2. sum = 13
  3. sum = 14
  4. sum = 15

Explanation

    sum = ++x + 8
⇒ sum = 6 + 8
⇒ sum = 14

++x will first increment the value of x from 5 to 6 and then use this incremented value in the expression.

Question 7

Assuming x = 1 with the following code snippet:
    int y = --x;
Which one of the following is true?

  1. x=1, y=1
  2. x=0, y=0
  3. x=1, y=0
  4. x=0, y=1

Explanation

--x will first decrement the value of x from 1 to 0 and then assign the decremented value to y so both x and y will be 0.

Question 8

The statement (1>0) && (1<0) evaluates to ...........

  1. 0
  2. 1
  3. false
  4. true

Explanation

1>0 is true and 1<0 is false so the condition becomes true && false. As && return true only when both of its operands are true so the answer is false.

Question 9

The statement (1>0) || (1<0) evaluates to ...........

  1. 0
  2. 1
  3. false
  4. true

Explanation

1>0 is true and 1<0 is false so the condition becomes true || false. As || return true if one or both of its operands are true so the answer is true.

Question 10

The statement (1==1)? 1: 0 evaluates to ...........

  1. 0
  2. 1
  3. false
  4. true

Explanation

1==1 is true so the expression just after the question mark (which in this case is 1) is returned.

Question 11

The expression 17 % 4 gives the output ...........

  1. 4
  2. 3
  3. 2
  4. 1

Explanation

% is modulus operator that returns the remainder of the division operation. Dividing 17 by 4 gives 4 as quotient and 1 as remainder so the final answer is 1.

Question 12

Consider the following code snippet:

float x = 8.25F;

int y;

y = (int) x;

What are the values of x and y?

  1. x= 8.25, y = 8
  2. x = 8.0, y = 8.0
  3. x = 8, y = 8.25
  4. x = 8, y = 8

Explanation

When float value is casted to an int, the digits after the decimal sign are discarded so y is assigned a value of 8.

Question 13

The expression 13 / 3 gives the output ...........

  1. 4
  2. 3
  3. 0
  4. 1

Explanation

When both operands of division operator (/) are integers then integer division takes place discarding the digits after the decimal sign.

Question 14

The statement System.out.println("six " + 3 + 3); gives the output ...........

  1. six 33
  2. six 6
  3. 33 six
  4. 6 six

Explanation

First "six " + 3 is evaluated. As one operand of addition operator (+) is string and other int so int is converted to string and concatenation is performed resulting in "six 3". Next, "six 3" + 3 is evaluated and similarly the result is six 33.

Question 15

The expression 4 + 8 % 2 gives the output ...........

  1. 6
  2. 8
  3. 4
  4. None of these

Explanation

    4 + 8 % 2
⇒ 4 + 0
⇒ 4

Due to operator precedence 8 % 2 is evaluated first. Its result is 0 so final result is 4.

Question 16

Implicit type conversion is also known as ...........

  1. Automatic type conversion
  2. Type promotion
  3. Widening conversion
  4. All of these