MCQs > IT & Programming > Scala > Choose expression that shows the correct output?

Scala MCQs

For the code fragment below, Choose the expression that shows the correct output?

object Main extends App { val adder = new Adder(2) System.out.println(adder.apply(4)) var a = new Adder(4) System.out.println(a.applyObj()) } class Adder(x: Int) { var y = 5 def apply(y: Int) = x + y def applyObj() = x + y }

Answer

Correct Answer: 6 then 9

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