What is a class, an object and an instance in Java?
Class is Data Type,You use this type to create object.
Instance is Logical but object is Physical means occupies some memory.
We can create an instance for abstract class as well as for interface, but we cannot create an
object for those.
Object is instance of class and instance means representative of class i.e object.
Instance refers to Reference of an object.
Object is actually pointing to memory address of that instance.
You can’t pass instance over the layers but you can pass the object over the layers
You can’t store an instance but you can store an object
A single object can have more than one instance.
Instance will have the both class definition and the object definition where as in object it will have only the object definition.
Syntax of Object:
Classname var=new Classname();
But for instance creation it returns only a pointer refering to an object, syntax is :
Classname varname;