mohan babu mohan babu - 1 year ago 106
Scala Question

What is the significance of "Object" Keyword in Scala?

I am a novice in Scala. I am trying to code in Scala, Below is the syntax of how a program starts:

Object demo

//do your stuff..............


What is the Significance of that?? Is it like mother of all the classes defined???

Any help would be helpful.

Answer Source

class is a definition, a description. It defines a type in terms of methods and composition of other types.

An object is a singleton -- an instance of a class which is guaranteed to be unique. For every object in the code, an anonymous class is created, which nherits from whatever classes you declared object to implement. This class cannot be seen from Scala source code -- though you can get at it through reflection.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download