In Object Oriented Programming (OOP) languages like small talk, C++, and Java, attempts are made to break a problem into some components called objects. They are the basic elements of the Object Oriented system and they are also known as the entities of the OOP. The set of related objects may exchange data and information and they may interact with each other.
What is an Object in Java?
Object is a unique entity, which contains data and functions (characteristics and behavior) together in an Object Oriented Programming (OOP) language.
Let us consider the real world objects, which are visible to us. Any object in the real world can possess the following characteristics:
- It is visible.
- It can be defined and described easily.
- It can be put into thought and action.
You can observe that anything fulfilling the above-mentioned criteria have a unique identity, definite shape (state), or characteristics and behaviors.
Characteristics of Object in Java
- State: represents the data (value) of an object.
- Behavior: represents the behavior (functionality) of an object such as deposit, withdrawal, etc.
- Identity: An object identity is typically implemented via a unique ID. The value of the ID is not visible to the external user. However, it is used internally by the JVM to identify each object uniquely.
Definitions of Object in Java
- An object is a real-world entity.
- An object is a runtime entity.
- The object is an entity that has a state and behavior.
- The object is an instance of a class.
How to create an Object in Java?
To create objects, you use the new keyword, there are some steps to create objects, which are given below.
- First of all, write the name of the class for which you want to create an object.
- Write the name of the object after the name of the class, keeping in mind that the name of the object should be unique.
- After this apply the equals (=) operator
- After this apply a new operator
- After the new operator, write the name of the class back and put brackets in front of it, and put a semicolon.
In this post, you learned what is Objects, how to create objects. I hope, you must have liked this Blog Object in Java in Hindi. If you want to ask any question related to this post or want to give any suggestions, then definitely tell by commenting, and I will definitely reply to it.