Q:

How does the Singleton Object differ from a instance of class

I am learning scala. I have one basic question.
My question is not about class. It is about objects.
I would like to understand how scala's class instance differs from java class instance.
I have the below code in scala
class Employee(var id:Int,var name:String)
{

    def show()
    {
      println("Id : " +id)
      println("Name :"+name)
    }

}

 object obj1
 {
     def main(args: Array[String])
     {
         val emp1 = new Employee(100,"Surender")
         emp1.show
     }
 }

I want to know what is obj1?  Can we say obj1 is the instance of class Employee or object of class Employee.
Similarly How does Obj1 differ from emp1?

A:

object is a shorthand for defining a type and instantiating it in a single declaration. The type of obj1 is obj1.type (you can see this by entering :t obj1 into the REPL).

Can we say obj1 is the instance of class Employee or object of class Employee.

No, there is no relationship between Employee and obj1.

How does Obj1 differ from emp1?

They're totally different things. A more apt question would be "what does obj1 have in common with emp1?", to which the answer is merely that they share the common ancestor java.lang.Object, as all references do.

