The output of the following block of code will be | Scala Question 12

83. The output of the following block of code will be -

object myObject {

    var multiplier = 5;
    
    def main(args: Array[String]) {
        println(calculator(45));
    }
    
    val calculator = (i:Int) => i * multiplier;
}
  1. 45
  2. 5
  3. Error
  4. 225

Answer: D) 225

Explanation:

The calculator method is a closure.

Comments and Discussions!

Load comments ↻






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