logo

Crowdly

Browser

Add to Chrome

What changes would need to be made to make the following immutable object patter...

✅ 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": "";

}

}

0%
0%
0%
100%
0%
0%
0%
More questions like this

Want instant access to all verified answers on dl.nure.ua?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome