Question: Which statement about the following classes is correct? A. Only Faucet is immutable. B. Only Spout is immutable. C. Both classes are immutable. D. Neither

Which statement about the following classes is correct? 

import java.util.*; final class Faucet { private final String water; private final

A. Only Faucet is immutable.

B. Only Spout is immutable.

C. Both classes are immutable.

D. Neither class is immutable.

E. None of the above as one of the classes does not compile.

import java.util.*; final class Faucet { private final String water; private final List pipes; public Faucet (String water, List pipes) { this.water water; this.pipes pipes; } public String getWater () { return water; } public List getPipes () { return pipes; } } public final class Spout { private final String well; private final List buckets; public Spout (String well, List buckets) { this.well = well; this.buckets = new ArrayList (buckets); } public String getWell() { return well; } } } public List getBuckets () { return new ArrayList (buckets);

Step by Step Solution

3.46 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The correct statement is D Neither class is immutable Explanation 1 In the Faucet class The class is ... 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!