Hey,
Scala executes a val when we define it, but executes a lazy val only when we access it the first time. We declare it using the keyword lazy:
scala> lazy val x=7
x: Int = <lazy>
scala> lazy val x=2+3
x: Int = <lazy>
Where eager evaluation is at compile-time, lazy evaluation is at run-time.
Hope this helps!
If you want to know more about Apache Spark Scala, It's highly recommended to go for Spark certification course today.
Thanks!!