Java MCQ: What is the result of 10 + 20 + “30” in Java?
a) 1030
b) 30
c) 102030
d) 3030
Answer:
d) 3030
Explanation:
In Java, the expression 10 + 20 + "30" results in "3030". This is because Java evaluates the expression from left to right. Initially, it adds 10 and 20, resulting in 30. Then, it encounters the string "30", and the integer 30 is converted to a string and concatenated with "30", resulting in "3030". This behavior highlights how Java handles string concatenation with arithmetic operations.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html