Cognizant Tech Solutions Interview Question
171 Interview Reviews |
Back to all Cognizant Tech Solutions Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Web Developer at Cognizant Tech Solutions:
1 what are immutable class in java ? how you make immutable claas/
See more for this Cognizant Tech Solutions Web Developer Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (1)
Members can
answer or comment on this question
–
Join Now (It's Free) or
Sign In
0 of 0 people found this helpful
by Interview Candidate:
2)The Properties of the class should be private and should not have any setter methods
The above mentioned are bare minimum conditions that needs to be satisfied to make the object immutable
class ImmutableCart
{
private final List items;
public ImmutableCart(List items)
{
this.items = Collections.unmodifiableList(new ArrayList(items));
}
public List getItems()
{
return items;
}
public int total()
{ /* return sum of the prices */ }
}