QuestionQ162

Working with Selected Classes from the Java API

Consider the following:

Question Image

What is the output?

  • A Compilation fails.
  • B 11
  • C 8
  • D 9
  • E 10
Explanation

String.trim() removes whitespace only from the beginning and end of a string. The internal spaces remain, so "Java SE 8 1" has a length of 11 characters.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!