What are Objects in Object Oriented Programming aka OOP?

This could be best way to answer what are Objects in Java, this is more than enough for a beginner level engineer, keep note of following information

Objects are instances of class, class defines blue prints and objects are things which are created based upon that blueprint. 

Object is also known as instance in Java, e.g. when we say an instance of String class, we actually mean an object of String class.

Object has state and behaviour.

State: State is represented using instance variable and static variable.

Behaviour: And behaviours are implemented using methods in Java.

The things which differentiate two objects of same class are their states e.g. if we take two instances of String class 'A' & 'B' their contents are different which is nothing but their state.

There are several ways to create objects in Java, .e.g., Serialization. Cloning, Reflection, etc.

But the most common and easy way to create objects in Java is by using new() keyword.

When we create an object of any class in Java, its constructor gets called, which initializes object with its default or initial state.

Comments

Popular posts from this blog

Priority Scheduling Algorithm Java Program.

Implement UNIX system calls like ps, fork, join, exec family, and wait for process management (use shell script/ Java/ C programming).

Implement a class CppArray which is identical to a one-dimensional C++ array (i.e., the index set is a set of consecutive integers starting at 0) except for the following : 1. It performs range checking. 2.It allows one to be assigned to another array through the use of assignment operator. 3.It supports a function that returns the size of the array.