Tuesday, April 20, 2010

Objects and Classes

Previous21222324252627282930Next

What is an Object?


Let’s spend some time in understanding what is a class, object. Class is a collection of objects which has properties and methods.


Classes are of two types.

1. Standard Class: which are loaded in the Library or which are predefined and we just need to call them and use them. We cannot make any changes to them.

2. User Defined Class: These are define d by the user for specific tasks.

Let us see what an Object contains.

1. Objects have properties and Methods.

2. An object is an instance of a Class.

3. Properties define characteristics of an Object.

4. Methods are the actions performed by the Objects.

Let’s take an example of a Class Room. Let’s say that we have two classes named Male and Female. All the individuals are Objects and they fall into either of the class. Now each of this Object (individual) has some properties and Methods.

Properties for the above object can be Name, Date of Birth, Height, Weight, Color and some properties are Read Only which cannot be changed while some others can be changed. For Example: Date of Birth cannot be changed while height and weight can be changed or even the name.

Methods for the above Object can be Sleeping, Eating, working, playing etc which are actions performed by the Object.


Previous21222324252627282930Next

No comments:

Post a Comment