Question: You have created an array using val. Can you change the value of any element of the array?and why or why not?
- Yes, the reference to the array is immutable, so the location that the array points to is immutable. The values in the array are mutable.
- The 0th element is immutable and cannot be modified. All other elements can be modified.
- Yes, val does not make arrays immutable.
- No, val makes the array and values of the array immutable.
Answer: The correct answer of the above question is Option A:Yes, the reference to the array is immutable, so the location that the array points to is immutable. The values in the array are mutable.