- Class is the collection of similar type of objects which
have some common properties.
- Class is a concept which is implemented by object.
- Class is a blueprint of java program from which we create
object, then object is instance of class.
- We can also say that class is a collection of variables and methods.
Methods: Represent Property
- Any real world entity which have physical existence either
living or non living is called an object.
- It is a runtime memory area. Object goes to heap.
How to Create an Object?
- In Java object of any class is created using new keyword.
- new keyword reserve the memory for an object in heap and
generate an implicit reference id which is stored in a reference variable.
void get(String n1,int s1)
public static void
- In above example total three objects are created. Firstly an
object is created using new operator and its reference id is stored in
reference variable e1. Then using e1 we call get() and show() methods. After
that we are creating two anonymous objects. You can see that we are getting different
outputs in three objects.
- Anonymous object is an object without name.
- We can store one reference id into more than one reference
Example: Emp e1=new Emp();
If you find anything wrong or missing in above tutorial then please mention it in comment section.