What is object in Scala? Is it a singleton object or instance of a class?



What is object in Scala? Is it a singleton object or instance of a class?..

Answer / Punkhuri Singh

'Object' in Scala refers to a singleton object, which is instantiated only once per JVM. It serves as a container for methods and fields (properties) that are shared among all instances of the class. An object acts like a pseudo-class (syntactically, it is not a class) but has a primary constructor without parameters.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Scala Interview Questions

Explain streams in scala?

1 Answers  


what are the features of scala?

1 Answers  


What is call-by-name? Does Scala and Java support call-by-name? What is the difference between call-by-value and call-by-name function parameters?

1 Answers  


What is string in scala?

1 Answers  


What is a higher-order function in scala?

1 Answers  


Difference between Array and List in Scala?

1 Answers  


Why do we need app in scala?

1 Answers  


What is apply method in Scala? What is unapply method in Scala? What is the difference between apply and unapply methods in Scala?

1 Answers  


What are higher-order functions?

1 Answers  


Difference between Scala’s Int and Java’s java.lang.Integer? What is the relationship between Int and RichInt in Scala?

1 Answers  


What are case classes in scala?

1 Answers  


What is a closure in Scala?

1 Answers  


Categories