Object
Object: is a bundle of related variables and functions (also known methods).
Objects share two characteristics: They have State and Behavior.
State: State is a well defined condition of an item. A state captures the relevant aspects of an object
Behavior: Behavior is the observable effects of an operation or event,
Examples:
eg 1:
Object: House
State: Current Location, Color, Area of House etc
Behavior: Close/Open main door.
eg 2:
Object: – Car
State: Color, Make
Behavior: Climb Uphill, Accelerate, SlowDown etc
Note: Everything a software object knows (State) and can do (Behavior) is represented by variables and methods (functions) in the object respectively.
Characteristics of Objects:
Abstraction
Encapsulation
Message passing
Message passing
A single object by itself may not be very useful. An application contains many objects. One object interacts with another object by invoking methods (or functions) on that object. Through the interaction of objects, programmers achieve a higher order of functionality which has complex behavior.
One object invoking methods on another object is known as Message passing.
It is also referred to as Method Invocation.
Class
A class is a prototype that defines the variables and the methods common to all objects of a certain kind. Member Functions operate upon the member variables of the class. An Object is created when a class in instantiated.
How to create an Object?
An object is created when a class is instantiated
Declaring an Object of class :
ClassName Objectname;
Object definition is done by calling the class constructor
Object: is a bundle of related variables and functions (also known methods).
Objects share two characteristics: They have State and Behavior.
State: State is a well defined condition of an item. A state captures the relevant aspects of an object
Behavior: Behavior is the observable effects of an operation or event,
Examples:
eg 1:
Object: House
State: Current Location, Color, Area of House etc
Behavior: Close/Open main door.
eg 2:
Object: – Car
State: Color, Make
Behavior: Climb Uphill, Accelerate, SlowDown etc
Note: Everything a software object knows (State) and can do (Behavior) is represented by variables and methods (functions) in the object respectively.
Characteristics of Objects:
Abstraction
Encapsulation
Message passing
Message passing
A single object by itself may not be very useful. An application contains many objects. One object interacts with another object by invoking methods (or functions) on that object. Through the interaction of objects, programmers achieve a higher order of functionality which has complex behavior.
One object invoking methods on another object is known as Message passing.
It is also referred to as Method Invocation.
Class
A class is a prototype that defines the variables and the methods common to all objects of a certain kind. Member Functions operate upon the member variables of the class. An Object is created when a class in instantiated.
How to create an Object?
An object is created when a class is instantiated
Declaring an Object of class :
ClassName Objectname;
Object definition is done by calling the class constructor
No comments:
Post a Comment