QuestionQ21

Working with Selected Classes from the Java API

Given:

Question Image

What is the output?

  • A A B C D
  • B A C D
  • C A C D D
  • D A B C C
  • E A B D C
Explanation

Java String values are immutable. Each assigned concat call extends ta, but the unassigned replace("B", "C") result is discarded, so B remains unchanged. The printed value is A B C D.

Community Discussion

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