×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

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))
    }
}
  1. 54
  2. Error
  3. 119
  4. 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))
^

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.