Object oriented programming

Object oriented programming


Q:-1.Distinguish between the following:

a: Classes and Objects

Classes:-Classes are the way to bind the data and its associated functions together. They allowed the data to be hidden, if necessary from external use. When defining a class, we are creating a new abstract data type that can be treated like any other built in data type.

Class has two parts:-

1. Class declaration:-It describes the type and scope of its members.

2. Class function:-It describes how a class functions are implemented.

Objects:-Objects are instances of classes. In C++ class variables are known as objects.

Ex:- Class item


Item x;

Here x is variable and it is a type of item, therefore x is called an object of type item.

b: abstraction and encapsulations

Abstraction:-It refers to putting together essential features without including background details.

Encapsulations:-The binding of data and functions together into a single class type variable is referred to as encapsulation.

2: Explain

a :Message passing:-It involves specifying the name of the object, the name of the function and the information to be sent.

b :Dynamic binding:-It means that the code associated with a given procedure is not known until the time of the call at run time .

c :Overloading:-It means assigning different meanings to an operation depending on the context. C++ permits overloading of operators, thus allowing us to assign multiple meanings to operators.

d :-Object based languages:-It is the style of programming that primarily supports encapsulation and object identity languages that support programming with objects are said to be object based programming languages.

e :-Object oriented languages:-OOP incorporates all of object based programming features along with two additional features namely, inheritance and dynamic binding. OOP can together be characterized by the following statement:-

object based features + inheritance + dynamic binding.

Languages that support these features include C ++ small talk, object Pascal, java. There are a large number of object-based and object oriented programming languages.

Q:-3.What is meant by interface of a class and implementation of a class?

Ans:-interface of a class means the overview of the programme that how we make class, and how projects related with this and how we use these things in the main functions of the programme.

Implementation of a class means how to access the data member through data function of the class.it is done with the help of creation of objects.

Q:-4.Differentiate between classes and structures with appropriate examples?

Ans:- A class can represent data elements as well as their associated functions that manipulate them whereas a structure can only represent the data elements. It has no control over the associated functions of data.

Ex:-The following examples creates a structure for student record:-

Struct sturec


int rollno;

char name[20];

int class;

float marks;

char grade;


sturec new stu;

the above declaration declares a structure named sturec with structure elements rollno,class,marks and grade. The last line creates a structure object named new stu of sturec.

Example of class:-

Class item


Int number;

Float cost;


Void getdata(int a,float b);

Void putdata(void);


Part :- B





Class bank



char name[20];

int acc;

char type[10];

float bal;


void initialize( );

void deposit( );

void withdraw( );

void details( );


void initialize ( )


cout<<”enter the name of the account holder”;


cout<<”\n enter the account number”;


cout<<”\n enter the accont type”;


cout<<”\n enter the balance”;



void deposit( )


cout<<”\n enter the amount to be deposited”;

cin >> bal;


void withdraw( )


cout<<”enter the amount to be withdraw”;

float w;



cout<<”\n insufficient balance”;




cout<<”\n transaction successful”;



void details( )


cout<<”\n name:”<<name;

cout<<”\n acc no:”<<acc;

cout<<”\n acc type:”<<type;

cout<<”\n available balance:”<<bal;


void main( )


bank b;

b.initialise( );

b.deposit( );

b.withdraw( );

b.details( );

getch( );


Q:-6define instantiation of a class. Is it possible to assign data from one object of a class to another object of same class? Explain with examples.


instantiation of a class means to start or to initialize the class.yes it is possible to assign data from one object to another object of same class.


Class abc


int a,b;


abc( ) { }

void getdata( )




Void add( )





void main( )


abc x;

x.getdata( )

x.add( );

getch( );


Q:-7.Give the classification of various access specifiers. How are they different from each other?


there are mmainly two type of access specifiers



The class members that have been declared as private can be accessed only from within the class. On the other hand, public members can be accessed from outside the class also.

Please be aware that the free essay that you were just reading was not written by us. This essay, and all of the others available to view on the website, were provided to us by students in exchange for services that we offer. This relationship helps our students to get an even better deal while also contributing to the biggest free essay resource in the UK!