Wednesday, May 25, 2011

OOPS Concept-Object

Object:

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()
{
        System.out.println("java");
}
public static void main(String arg[])
{
Sam s=new Sam(); //Here is the Object
}
}
}

No comments: