Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

Classes and Objects

Posted By: Bohdana Nonob     Category: Java     Views: 4398

This article explains about classes and objects in java.

The need to understand necessity of class and objects is  classes and objects forms the building blocks of any java program.

What is an Object?

An object is nothing but a region of storage that defines state and behavior. Storage can be either memory or disk and state is a set of variables and the values they contain. Behavior is a set of methods and the logic they implement. 

Thus, an object is a combination of data and code that acts upon it.

What is Class?

A class is a template from which objects are created. It means objects are instances of a class and the mechanism to create a new object is called instantiation.

Example of Class and Object

For an example consider an account class.  A separate account object represents an account holder's details. Its state includes variables such as account holder name, Total amount etc.... The behavior of a class account is defined by methods withdraw amount, deposit amount, get balance etc...

Member of a class

There are two ways that an item can be a member of a class.

1) Static member
2) Instance member

Static member is defined for the class itself and exists independently of any object of that class. 
Instance member is defined for objects of the class, thus it is bound to an instance of its class.  

Didn't find what you were looking for? Find more on Classes and Objects Or get search suggestion and latest updates.

Bohdana Nonob
Bohdana Nonob author of Classes and Objects is from Moscow, Russia.
View All Articles

Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

No Comment Found, Be the First to post comment!