Saturday, December 24, 2011

What is the Difference between a Class and an Object in java?

Object: It is a basic run time entity. (or) Object is an instance of a class.  Object consists of state and related behavior.An object stores its state in fields (variables in some programming languages) and exposes its behavior through methods (functions in some programming languages).

Class: Collection of objects under one roof is generally treated as a class. (or) It is a blueprint for an object.