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 feature allows you to concatenate strings in Java?

  1. '+' operator

  2. concat() method

  3. Both '+' operator and concat() method

  4. join() method

The correct answer is: Both '+' operator and concat() method

Concatenation is the process of joining two or more strings together. In Java, this can be done using either the '+' operator or the concat() method. The '+' operator is commonly used for simple string concatenation, while the concat() method is more useful for more complex concatenation operations. The join() method is not used for string concatenation in Java, as it is typically used for joining elements of a list or array. Therefore, the correct answer is both the '+' operator and the concat() method.