Monday, February 9, 2009



In object-oriented programming, a class is a programming language construct that is used as a blueprint to create objects. This blueprint includes attributes and methods that the created objects all share.

Usually, a class represents a person, place, or thing - it is an abstraction of a concept within a computer program. Fundamentally, it encapsulates the state and behavior of that which it conceptually represents. It encapsulates state through data placeholders called member variables; it encapsulates behavior through reusable code called methods.

More technically, a class is a cohesive package that consists of a particular kind of meta data. It describes the rules by which objects behave; these objects are referred to as instances of that class. A class has both an interface and a structure. The interface describes how the class and its instances can be interacted with via methods, while the structure describes how the data is partitioned into attributes within an instance. A class may also have a representation (meta object) at run time, which provides run time support for manipulating the class-related meta data. In object-oriented design, a class is the most specific type of an object in relation to a specific layer.

Programming languages that support classes all subtly differ in their support for various class-related features. Most support various forms of class inheritance. Many languages also support features providing encapsulation, such as access specifiers.

class Example:

Class java






In its simplest embodiment, an object is an allocated region of storage. Since programming languages use variables to access objects, the terms object and variable are often used interchangeably. However, until memory is allocated, an object does not exist.

Any language present objects and this should not be confounded with the most powerful concept of object-orientation.

In procedural programming, an object may contain data or instructions, but not both. (Instructions may take the form of a procedure or function.) In object oriented programming, an object may be associated with both the data and the instructions that operate on that data.

How an object is created depends on the language. In aprototype-based language (e.g.,JavaScript) an object can be created from nothing, or can be based on an existing object. In a class-based language (e.g- ,Java), an object is created as an instance (or instantiation) of a class. The class forms a specification for the object.

To give a real world analogy, a house is constructed according to a specification. Here, the specification is a blueprint that represents a class, and the constructed house represents the object.
Object example:
class Sam


int i=10;

void mone()




public static void main(String arg[])


Sam s=new Sam(); //Here is the Object





Post a Comment