QuestionQ27

Working with Selected Classes from the Java API

Given the following code fragment:

Question Image

What is the output?

  • A [JavaForum, ExpertForum]
  • B [JavaGroup, ExpertGroup]
  • C [JavaForumGroup, ExpertForumGroup]
  • D [JavaGroup, TechGroup ExpertGroup]
Explanation

String.concat returns a new string and does not alter the existing list element. The result produced during forEach is discarded, whereas List.replaceAll replaces every element with the result of its operator. The list therefore contains JavaGroup and ExpertGroup.

Learn more

Community Discussion

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