Object

Object
Objects are key to understanding object-oriented technology. Objects are the basic unit of object orientation with behavior, identity. These are part of the class but are not the same.

For Example: Car is an object. Its name is Mercedes, color is white etc. known as its state. It is used to drive, so driving is its behavior.

Object is an instance of a class. Class is a template or blueprint from which objects are created. So object is the instance(result) of a class.

Syntax
class ClassName()
{
//statement
}
class MainClassName
{
public static void main(String args[])
{
ClassName ObjectName = new ClassName();
}
}

What is difference between a class and an object?

A class is model for creating object and does not exist physically. An object is any thing that exists physically. Both the class and objects contain variables and methods.


Leave a Reply

Your email address will not be published. Required fields are marked *