Question: QUESTION 5 (a) True or false: instances of the String class in Java are mutable? Explain your answer (2 marks) (b) Explain why immutable classes

QUESTION 5 (a) True or false: instances of the String class in Java are mutable? Explain your answer (2 marks) (b) Explain why immutable classes are used. (2 marks) (c) Modify the immutable class Dog, listed below, so that it becomes a mutable class. public class Dog{ private final String breed; private final String name; private final int age; public Dog(String b, String n, int a){ breed = b; name = n; age = a; } public String breed({return breed;} public String name({return name;} public int age({return age;} } (6 marks)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
