You are on page 1of 3

Dayananda Sagar College of Engineering

Department of Computer Science & Engineering


Question Bank
10CS36: Object Oriented Programming in C++
UNIT 3
1. Write short notes
a) copy constructor
b) Parameterized constructor

10M

c) pointer to objects
2. What is friend function and explain why it is needed with an example program. 10M
3. Demonstrate with a program how to pass an object as argument and How are dynamic
objects created with an example 10M
4. What is operator overloading? How is operator overloading achieved? Show with an
example by overloading + + 10M
5. Explain the syntax for overloading operators using.
i) Member function
ii) Friend function
10M
6. Design, develop, and execute a program in C++ to create a class called STRING and
implement the following operations. Display the results after every operation by
overloading the operator <<
.i. STRING s1 = VTU
ii. STRING s2 = BELGAUM
iii. STIRNG s3 = s1 + s2; (Use copy constructor)
10M
7. Design, develop, and execute a program in C++ to create a class called STACK using an
array of integers and to implement the following operations by overloading the operators +
and - :
i. s1=s1 + element; where s1 is an object of the class STACK and element is an integer to
be pushed on to top of the stack.
ii. s1=s1- ; where s1 is an object of the class STACK and operator pops off the top
element.Handle the STACK Empty and STACK Full conditions. Also display the contents
of the stack after each operation, by overloading the operator <<.
10M
8. Design, develop, and execute a program in C++ to create a class called OCTAL, which
has the characteristics of an octal number Implement the following operations by writing an
appropriate constructor and an overloaded operator +.

OCTAL h = x ; where x is an integer


int y = h + k ; where h is an OCTAL object and k is an integer.
Display the OCTAL result by overloading the operator <<. Also display the values of h and
y.
10M
9. Demonstrate with a program how to pass an object as argument and also return an object.
Write a Program to find transpose of a given matrix.
10M
10. with an example, explain when to use member function and when to use friend function
as an operator function to overload binary operator.
10M
11. What is friend function, explain its merits & Write a program to swap 2 numbers using
friend as a bridge.
10M
12. What are constructors and destructors & explain how these functions are executed. With
an example explain copy Constructor in detail.
10M
13. Write a C++ program to overload the following operators
a. [ ] b. << c. +=

10M

UNIT - 4
1. Demonstrate how a member function declared in base class be redefined in derived class.

Write a C++ program to create a base class Shape. Use this class to store two double type
values that could be used to compute the area of figures. Derive two specific classes called
Triangle & Rectangle from the base Shape. Add to the base class, member function
get_data( ) to initialize base class data members and another member function display_area( )
to compute & display the area of figures
10M
2. What is Inheritance. Explain the types of inheritance with an example 10M
3. Differentiate between private members and protected members. Write a C++ program to illustrate

protected members in the base class & explain when we use protected visibility specifier to a class.
10M
4. . Explain the visibility of the base class members for the access specifiers: private, protected and

public while creating derived classes. 10M

5. An electricity board charges the following rates to domestic users to discourage large consumption of energy
: For the first 100 units 50 P per unit, Beyond 300 units 60 P per unit, If the total cost is more than
Rs.250.00 then an additional surcharge of 15% is added on the difference. Define a class Electricity in which
the function Bill computes the cost. Define a derived class More_Electricity and override Bill to add the
surcharge.
10M

6. Write a C++ program for Payroll management system where,

-10MEMPLOYEE
char emp_no
char emp_name
char
emp_designation
char emp_type
read_empdetails( )

SALARY : EMPLOYEE
basic_pay
allowance: 120% of basic_pay
IT: 30%
Netsal

DISPLAY: SALARY
display_Empdetails( )

get_saldetails( )
calculate_netsal( )

Note:1. Use Inheritance


2. Netsal= Basic_pay+Allowance-IT
7. With an example program explain the role of multiple base class inheritance. 10M
8. Write a note on this pointer with an example.

05M

9. Differentiate between a pointer variable and reference variable. 05M


10.

You might also like