Question: What does the following output? A. [a, lamb, had, Mary, little] B. [a] C. [a, a] D. The code does not compile. E. The code

What does the following output? 

18: List list List.of( 19: "Mary", "had", "a", "little", "lamb"); 20: Set

A. [a, lamb, had, Mary, little]

B. [a]

C. [a, a]

D. The code does not compile.

E. The code throws an exception at runtime.

18: List list List.of( 19: "Mary", "had", "a", "little", "lamb"); 20: Set set = new HashSet (list); 21: set.addAll(list); 22: for (String sheep : set) if (sheep.length() > 1) set.remove(sheep); 23: 24: 25: System.out.println(set); =

Step by Step Solution

3.54 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code snippet provided in the image is trying to create a List of Strings convert it into a Set a... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Oracle Questions!