- Home
- Chapter 1 - Object Oriented Programming Concepts
- Object Oriented Programming Concepts
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 2 - Introduction to Java
- Introduction to Java
- Multiple Choice Questions
- Assignment Questions
- Chapter 3 - Values and Data Types
- Values and Data Types
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 4 - Operators in Java
- Operators in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 5 - User-Defined Methods
- User-Defined Methods
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 6 - Input in Java
- Input in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 7 - Mathematical Library Methods
- Mathematical Library Methods
- Multiple Choice Questions
- Assignment Questions
- Chapter 8 - Conditional Constructs in Java
- Conditional Constructs in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 9 - Iterative Constructs in Java
- Iterative Constructs in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions and Programs
- Chapter 10 - Nested for loops
- Nested for loops
- Assignment Questions and Programs
- Chapter 11 - Constructors
- Constructors
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 12 - Library Classes
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 13 - Encapsulation and Inheritance
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 14 - Arrays
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 15 - String Handling
- Library Classes
- Multiple Choice Questions
- Assignment Questions
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 ...........
- 2
- 0 ✔
- 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 ...........
- A unary operator ✔
- A binary operator
- A ternary operator
- None of these
Question 3
Which one of the following is not a binary operator?
- AND
- %
- ==
- ! ✔
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?
- <=
- !== ✔
- !=
- ==
Question 5
The statement i = i + 1 is equivalent to ...........
- i++
- i += 1
- ++i
- 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 ...........
- sum = 12
- sum = 13
- sum = 14 ✔
- 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?
- x=1, y=1
- x=0, y=0 ✔
- x=1, y=0
- 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 ...........
- 0
- 1
- false ✔
- 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 ...........
- 0
- 1
- false
- 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 ...........
- 0
- 1 ✔
- false
- 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 ...........
- 4
- 3
- 2
- 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?
- x= 8.25, y = 8 ✔
- x = 8.0, y = 8.0
- x = 8, y = 8.25
- 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 ...........
- 4 ✔
- 3
- 0
- 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 ...........
- six 33 ✔
- six 6
- 33 six
- 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 ...........
- 6
- 8
- 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 ...........
- Automatic type conversion
- Type promotion
- Widening conversion
- All of these ✔
