In this page provide you software multiple choice question which help to many exam like Semester exam, Gate Exam, Railway , ISRO etc.
Java Operator MCQ SET-1
Q.1 Which of the following are arithmetic operators?
-
A)
+
-
B)
-
-
C)
/, %
-
D)
All of these
Discuss itExplanation
Arithmetic operators include addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
Q.2 Which of the following are unary operators?
-
A)
++
-
B)
--
-
C)
Both A & B
-
D)
None of these
Discuss itExplanation
Unary operators require only one operand. Increment (++) and decrement (--) are the most common examples.
Q.3 Which of the following are classified as Binary operators?
-
A)
+
-
B)
-
-
C)
< , >
-
D)
All of these
Discuss itExplanation
Binary operators require two operands to perform an action. This includes arithmetic, relational, and logical operators.
Q.4 A Unary operator operates on how many values?
-
A)
One
-
B)
Two
-
C)
Three
-
D)
All of these
Discuss itExplanation
The term 'Unary' is derived from the fact that these operators take exactly one operand.
Q.5 A Binary operator operates on how many values?
-
A)
One
-
B)
Two
-
C)
Three
-
D)
All of these
Discuss itExplanation
Binary operators require two operands (e.g., a + b) to perform their specific operation.
Q.6 A Ternary operator operates on how many values?
-
A)
One
-
B)
Two
-
C)
Three
-
D)
All of these
Discuss itExplanation
Java features one ternary operator (?:) which takes three operands: a condition, a result for true, and a result for false.
”Q.7
-
A)
”>>>”
-
B)
”>>”
-
D)
All of these
Q.9 Which of the following are Bitwise operators?
-
A)
&
-
B)
^
-
C)
|
-
D)
All of these
Discuss itExplanation
Bitwise operators perform operations on individual bits. These include AND (&), XOR (^), and OR (|).
Q.10 Which of the following are Logical operators?
-
A)
&&
-
B)
||
-
C)
Both A & B
-
D)
None of these
Discuss itExplanation
Logical AND (&&) and Logical OR (||) are used to combine multiple boolean expressions.
Q.11 Which symbol represents the Ternary operator?
-
A)
&&
-
B)
? :
-
C)
Both A & B
-
D)
None of these
Discuss itExplanation
The conditional operator (? 🙂 is the only ternary operator in Java, often used as a shorthand for if-else.
Q.12 Calculate the Bitwise AND for (1101) & (1100):
-
A)
1100
-
B)
1101
-
C)
0101
-
D)
None of these
Discuss itExplanation
Bitwise AND returns 1 only if both bits are 1. Comparing 1101 and 1100 results in 1100.
Q.13 Calculate the Bitwise OR for (1101) | (1100):
-
A)
1100
-
B)
1101
-
C)
0101
-
D)
None of these
Discuss itExplanation
Bitwise OR returns 1 if at least one of the bits is 1. Comparing 1101 and 1100 results in 1101.
Q.14 Calculate the result for Bitwise operation yielding (0011) from (1101) and (1100):
-
A)
1100
-
B)
1101
-
C)
0011
-
D)
None of these
Discuss itExplanation
Based on the specific logic provided, the result of this bit manipulation is 0011.
Q.15 Calculate the Bitwise XOR for (1101) ^ (1100):
-
A)
1100
-
B)
1101
-
C)
0001
-
D)
None of these
Discuss itExplanation
Bitwise XOR returns 1 only if the bits are different. 1101 XOR 1100 results in 0001.
Q.16 Which of the following is a Relational operator?
-
B)
>
-
C)
==
-
D)
All of these
Discuss itExplanation
Less than (<), greater than (>), and equal to (==) are all used to establish relationships between values.
Q.17 In the expression '++a', which operator is being used?
-
A)
Increment operator
-
B)
Pre-Increment operator
-
C)
Post-Increment operator
-
D)
All of these
Discuss itExplanation
'++a' is a Pre-Increment operator, meaning the value is increased before it is used in the expression.
Q.18 In the expression 'a++', which operator is being used?
-
A)
Increment operator
-
B)
Pre-Increment operator
-
C)
Post-Increment operator
-
D)
All of these
Discuss itExplanation
'a++' is a Post-Increment operator, meaning the current value is used first, and then it is increased.
Q.19 What is the output of the Pre-Increment operation for a=6, b=4 (assuming c = ++a * ++b)?
-
A)
35
-
B)
24
-
C)
15
-
D)
None of these
Discuss itExplanation
a becomes 7 and b becomes 5. Therefore, 7 * 5 = 35.
Q.20 What is the output of the Post-Increment operation for a=6, b=4 (assuming c = a++ * b++)?
-
A)
35
-
B)
24
-
C)
15
-
D)
None of these
Discuss itExplanation
The current values (6 and 4) are used for the calculation first. Therefore, 6 * 4 = 24.