Operators Interview Questions

🟢 EASY LEVEL – Freshers / Screening Round
At this level, interviewers test your basic understanding of syntax and concepts.
1. What are operators in Java?
Operators are special symbols in Java used to perform operations on variables and values.
Example:
int c = a + b;
Here, + is an operator used for addition.
2. Types of Operators in Java
Java supports the following operator categories:
Arithmetic Operators
Unary Operators
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Ternary Operator
Understanding these categories is essential before moving to complex expressions.
3. Difference between = and ==
| Operator | Purpose |
= | Assigns a value |
== | Compares values |
Example:
int a = 10; // assignment
System.out.println(a == 10); // comparison → true
4. What is the use of % (modulus) operator?
The % operator returns the remainder after division.
Example:
10 % 3 = 1
This operator is commonly used to check even/odd numbers.
5. Difference between && and &
&& | & |
| Logical AND | Bitwise AND |
| Short-circuit | No short-circuit |
| Safer | Can cause exceptions |
This is a very common interview trap.
6. What is a unary operator?
Unary operators work on a single operand.
Examples:
++a, a++, --a, !true
7. Can we use + operator with Strings?
Yes. The + operator is used for String concatenation.
Example:
System.out.println("Java" + 8); // Java8
8. What is the ternary operator?
The ternary operator is a short-hand replacement for if-else.
Syntax:
condition ? value1 : value2;
💻 EASY LEVEL – Programming Examples
Arithmetic Operators
int a = 10, b = 3;
| Expression | Output | Reason |
| a + b | 13 | Addition |
| a - b | 7 | Subtraction |
| a * b | 30 | Multiplication |
| a / b | 3 | Integer division |
| a % b | 1 | Remainder |
Unary Operators
int x = 5;
System.out.println(++x); // 6
System.out.println(x++); // 6
System.out.println(x); // 7
Explanation:
++x→ increment first, then usex++→ use first, then increment
Relational Operators
System.out.println(10 > 20); // false
System.out.println(10 == 10); // true
System.out.println(10 != 5); // true
Ternary Operator
int max = (15 > 20) ? 15 : 20;
System.out.println(max); // 20
🟡 MEDIUM LEVEL – Interview Round
Here, interviewers test execution flow and operator behavior.
Key Theory Questions
&&vs||→ both are short-circuit operators==should not be used for Strings → useequals()Operator precedence →
*executes before+Ternary cannot fully replace
if-elseJava performs implicit type promotion
Medium-Level Programming Example
int a = 5;
int b = ++a + a++ + a;
Step-by-step execution:
++a→ 6a++→ 6 → a becomes 7a→ 7
Final Output:
a = 7
b = 19
🔴 HARD LEVEL – MNC Interviews
At this level, interviewers evaluate short-circuit logic, precedence and bitwise operations.
Short-Circuit Trap
b != 0 && a / b > 2
First condition is false
Second condition is not executed
No exception occurs
✔ Safe execution
Operator Precedence
10 + 5*2 - 3/3
Execution order:
= 10 + 10 - 1
= 19
Bitwise Shift
8 >> 1 = 4
8 << 2 = 32
⚫ VERY HARD LEVEL – FAANG Interviews
These questions test deep understanding of evaluation order.
Expression Evaluation
int a = 1;
a = a++ + ++a * a++;
Execution flow:
a++→ 1 → a=2++a→ 3a++→ 3 → a=4
Final Result:
a = 10
Logical vs Bitwise Trap
x != 0 & 10/x > 1
&evaluates both sidesDivision by zero occurs
❌ Program crashes with ArithmeticException
✅ Interviewer Final Note
If you can confidently solve and explain Very Hard operator questions, you are already operating at a senior Java developer mindset.