What is Object

1)Object is real world physical entity  i.e anything which is physically present can be considered as object. Example dog, human , laptop, mobile, watch, pen etc are objects.

2)Object is an instance of a class.click here to know what is class

3)Object has two things i.e state and behavior. , which we define in class.

State: State of object is nothing but the information about the object. Example: Mobile is a object and  Mobile name ,  Mobile color , Mobile price etc are the states of the Mobile. In java states of object we define in class using variables.

Behaviors: Behavior of object  is nothing but the functions of object. Example: calling, messaging etc are the behaviors of the Mobile. In java behavior of object we define in class using methods or functions.

4)Object is created using keyword called new.

There are two ways of object creation shown below.

5)when we create a object it gets created in heap memory. we don’t use object for accessing states and behaviors of object rather we use object reference to access states and behaviors of object which is shown in below example.

You may also like...

Leave a Reply