What is the difference between 'val' and 'lazy val' in Scala? What is Eager Evaluation? What is Lazy Evaluation?



What is the difference between 'val' and 'lazy val' in Scala? What is Eager Eval..

Answer / Amit Singh Bisht

In Scala, 'val' is a value that is initialized when it is defined. This process is known as Eager Evaluation. On the other hand, 'lazy val' initializes the value only when it is first accessed or needed. This is called Lazy Evaluation.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Scala Interview Questions

Explain how to create arrays?

1 Answers  


What do you understand by an implicit parameter in scala ?

1 Answers  


What is pattern matching?

1 Answers  


What do you mean by “type inference” in scala?

1 Answers  


What do you mean by ofdim in scala?

1 Answers  


What is option/some/none design pattern in scala?

1 Answers  


What is exception handling in scala?

1 Answers  


What is file handling in scala?

1 Answers  


Is scala worth learning?

1 Answers  


What is the function parameter with a default value in scala?

1 Answers  


What is the queue in the scala collection?

1 Answers  


What is list in scala collection?

1 Answers  


Categories