Recently MeroSpark is lunched with more features and services, now you can ask your question, sell your books, share your notes and many more. Visit now and create your account to take full advantage of MeroSpark.

Classes and Objects – Feature of Object Oriented Programming (OOP)

Download our Android App from Google Play Store and start reading Reference Notes Offline.

classes and objectClasses and Objects – Characteristics of Object Oriented Programming (OOP)
Object Oriented Programming(OOP)
Third Semester | Second year
BSc.CSIT | Tribhuvan University (TU)

Classes and objects
A class is a collection of similar entities which have same structure and exhibit same behavior. These are used to describe something in the real world like places, organizations, roles, things, occurrences etc. A class is said to describe the structure and behavior of these sets of entities called objects. As opposed to actual objects, the class gives a general description of these objects like a template, blueprint or a pattern; and contains the definitions of all the attributes and methods which will become the part of each object created from the class. Only after a class has been defined, specific instances of the class can be created and these instances are called the instances of that class. The process of creation of these instances as an object of the class is called instantiation. Table below cites certain examples of classes and their objects for your ready reference.

Table: Example of Classes and Corresponding Objects
Type Example of Class Example of Object
Organization University Department Computer Science
Occurrence Alarm Fire alarm
Role Teacher Manoj Kumar
Thing Car Maruti Wagon R

Figure below shows an example of a class having an identifier as ‘Teacher’, its structure defined by attributes ‘Name’ of type ‘String’ and ‘Age’ of type ‘Integer’ depending upon the particular context. The behavior of this class in a using abstraction is depicted by a single method ‘evaluate’. In this particular context, the programmer is required to focus only on name and age of the teachers as part of the structure of this class and in the evaluation method as part of behavior of this class.

In different contexts, there may be different sets of attributes and methods of interest for the programmer. An object (instances) created from this class is also shown in this figure having values of attributes ‘Name’ and ‘Age’, these values of attributes at any point of time also describe the state of this object. The behavior of an object is defined by the set of methods which can be applied on it.

class and corresponding object

(Visited 198 times, 1 visits today)

Posted By : Digvijay | Comment RSS | Category : Third Semester
Tag :

Post a Comment

Your email is never published nor shared. Required fields are marked *


Wordpress DMCA
Community | Toolbar | Android App | Founder/Developer : Hari Prasad Chaudhary | CSIT Portal Manager : Digvijay Chaudhary