✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
What changes would need to be made to make the following immutable object pattern correct?(Choose all that apply.)
import java.util.List;
public class Duck {
private String name;
private List<Duck> ducklings;
public Duck(String name, List<Duck> ducklings) {
this.name = name;
this.ducklings = new ArrayList<Duck>(ducklings);
}
public String getName() { return name; }
public List<Duck> getDucklings() { return ducklings; }
public String hasDucklings(Predicate<Duck> p) {
return p.test(this) ? "Quack Quack": "";
}
}