An immutable list containing mutable lamps

A lighting application executes this Scala 3 code. The head operation accesses the first element, and the :+ operation produces a list with an appended element. Which statements are true after all statements execute? Select every true statement.


scala
class Lamp(var hours: Int)

val original = List(new Lamp(6), new Lamp(3))
val expanded = original :+ new Lamp(2)
original.head.hours = 8
Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Arrays of Objects Questions: