MCQs > IT & Programming > Scala > Choose the correct statement which solves the error?

Scala MCQs

Using the following code fragment, Choose the correct statement which solves the error?

class A(n: Int) { var value = n } class B(n: Int) { val value = new A(n) } object Test { class A(n: Int) { var value = n } class B(n: Int) { val value = new A(n) } object Main extends App { val x = new B(5) x.value = 6 } When complied produces the following error Main.scala:7: error: reassignment to val x.value = 6 ^

Answer

Correct Answer: x.value.value = 6

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Scala Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Scala Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it