Java | Operators | Question 3
class Test { public static void main(String args[]) { System.out.println(10 + 20 + "GeeksQuiz"); System.out.println("GeeksQuiz" + 10 + 20); } } |
chevron_right
filter_none
(A)
30GeeksQuiz GeeksQuiz30
(B)
1020GeeksQuiz GeeksQuiz1020
(C)
30GeeksQuiz GeeksQuiz1020
(D)
1020GeeksQuiz GeeksQuiz30
Answer: (C)
Explanation: In the given expressions 10 + 20 + “GeeksQuiz” and “GeeksQuiz” + 10 + 20 , there are two + operators, so associativity comes to the picture. The + operator is left to right. So the first expression is evaluated as (10 + 20) + “GeeksQuiz” and second expression is evaluated as (“GeeksQuiz” + 10) + 20 .
Quiz of this Question
Recommended Posts:
- Java | Operators | Question 7
- Java | Operators | Question 6
- Java | Operators | Question 5
- Java | Operators | Question 4
- Java | Operators | Question 9
- Java | Operators | Question 1
- Java | Operators | Question 8
- Java | Operators | Question 2
- Operators in Java
- Bitwise operators in Java
- Bitwise right shift operators in Java
- Compound assignment operators in Java
- Operators in C | Set 2 (Relational and Logical Operators)
- C | Operators | Question 11
- C | Operators | Question 12



