Home »
MCQs »
Scala MCQs
The correct output of the following code is | Scala Question 3
40. The correct output of the following code is -
object myObject {
def main(args: Array[String]) {
var _value1 = 54
var 3value_2 = 65
println("The sum of two values is " + (_value1 + value_2))
}
}
- 54
- Error
- 119
- 65
Answer: B) Error
Explanation:
The second variable is 3value_2 which is not an valid identifier and in the expression, we are using value_2 which is not defined in the above code.
Output:
jdoodle.scala:4: error: invalid literal number
var 3value_2 = 65
^
jdoodle.scala:6: error: '=' expected.
println("The sum of two values is " + (_value1 + value_2))
^