Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


Which operation can be used for both string concatenation and arithmetic addition in Java?

  1. +

  2. *

  3. -

  4. +=

The correct answer is: +

In Java, the + operator can be used for both string concatenation and arithmetic addition. This operator is most commonly associated with addition, but it can also be used to concatenate strings. The * and - operators are used for multiplication and subtraction, respectively. The += operator is a compound assignment operator, which combines addition and assignment. It is not used for string concatenation. Therefore, the correct answer would be A.