Object in java


Object

Object is a unique entity, which contains data and functions (characteristics and  behaviour) together in an object oriented programming (oop) Language.They are the basic elements of Object Oriented system and they are also known as the entities of the OOP. The set of related objects may exchange data and information. They may interact with each other.

Any object in the  real world can possess the following characteristics:

1. It is visible.

2. It can be defined and described easily.

3. It can be put into thought and action.

 

You can observe that any thing fulfilling above-mentioned criteria has unique identity,

definite shape (State) or characteristics and behaviours. For example consider an object

table:

It has the following characteristics:

1 It has four legs.

2 It has a plain top.

It has the following behaviours:

1. It is used to keep glasses etc.

2. It is used to keep books etc.

For example, we can consider potato as an object, which possesses some characteristics and   behaviours.

The characteristics could be explained as:

l. It is brown in colour.

2. It is special/oval in shape.

The behaviours could be explained as:

1. It is used to make vegetables.

2 .It is used to make chips.

Instance of a class

An object of the class is called instance of the class. In any language, where each object is created from a class, an object is called an instance of the class. Each object the same class would have the same data type defined with the class name.

Creating object of the class:

An object is creating from the class. The new keyword is used to create the object of a class in Java. New  keyword allocating dynamic memory of an object. There are three steps to create an object from class.

  1. Declaration:  It is uses class as data type along with an object.
  2. Instantiation: The new keyword is used for allocating an object in the memory.
  3. Initialization: It is used for calling a constructor to initialize attributes of the object.

Syntax:

Abc        a1 =       new                   Abc( );

Class     object       new

operator          constructor

Comments are closed.