UT Question Bank OOP-1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

UNIT-3: Inheritence

1. Describe use of protected access specifier used in the class.


2. Write a C++ program to implement inheritance shown in following figure:

Class : Teacher Class : Student


datamember : Name datamember : sname
empid rollno.

Class : Info

Accept and display data of one teacher and one student using object of class ‘Info’.

3. Write a C++ program to implement following inheritance.

Class : Employee
Data : empid
Member : empcode

Class : Programmer Class : Manager


Datamember : Skill Datamember : department

Accept and display data for one programmer and one manager. Make display function
virtual.

4. Write C++ program for following multilevel inheritance.


Class : Carmanufacturer
datamember : Name

Class : Carmodel
datamember : Model name,
Model no.

Class : Car
datamember : Car
no., colour
Accept and display data for one car with all details.

5. Write a program to implement multiple inheritance as shown in following Figure No.


1: (2 times)

Class : Subject 1 Class : Subject 2


data mem : m1 data mem : m2

Class : Result
data mem : Total

Fig. No. 1

Accept and display data for one object of class result.

6. State and describe visibility modes and its effects used in inheritance. (4 times)
7. Write a C++ program to implement following in heritance. Refer Figure No. 2.

Class : College
Student student id
Data mem :
College_code

Class : College Class : sports


Student student id data mem : grade
Data mem :
College_code

Class : Result

Fig. No. 2

Accept and display data for one object of class result (Hint : use virtual base class)

8. What is multilevel inheritance? Draw the diagram to show multilevel inheritance. using
classes with data member and member function.
9. Write a program to implement the following hierarchy using suitable member
functions. Refer Figure No. 3.
Class: Student

Data mem: roll_no,


name.

Class : Test Class: Sports

Data mem: mark1, Data mem: score


mark2

Class: Result

Data mem: total

10. Develop a c++ program for multilevel inheritance.


UNIT-4: Polymorphism

1. With suitable example, describe effect of ++ and – – operators used with pointer in
pointer arithmetic.
2. Describe the concept of virtual base class with suitable example. (2 times)
3. Write a C++ program to swap two integer numbers and swap two float numbers using
function overloading. (Hint : overload swap function)
4. Write a C++ program to overload binary operator ‘+’ to concatenate two strings. (3
times)
5. Give meaning of following statements: int * ptr, a = 5; ptr = & a ; cout << * ptr ; cout
<< (* ptr) + 1;
6. Differentiate between run time and compile time polymorphism. (3 times)
7. Write any four rules of operator overloading.
8. Write a program in C++ to overload unary ‘_’ operator to negate values of data
members of class. (2 times)
9. Explain virtual base class with suitable example.
10. Describe ‘this’ pointer with an example.
11. What are the rules for virtual function?
12. State the need of virtual function in C++.
13. Write a C++ program to overload add function to add two integer numbers and two
float numbers.
14. Define pointer operator and address operator with example.
15. Explain concept of pointer with example.
16. Develop a c++ program to perform arthmatic operation using pointer.
17. Develop a c++ program to implement virtual Base class.
UNIT-5: File Handling

1. Describe meaning of following: (2 times)


ios : : in (ii) ios : : out
2. Write a C++ program to count number of spaces present in contents of file / text file.
(2 times)
3. Write a C++ program to write ‘Welcome to poly’ in a file. Then read the data from file
and display it on screen.
4. Write a C++ program to append data from abc .txt to xyz .txt file.
5. Write a program to count the number of lines in file
6. Give syntax and use of fclose ( ) function.
7. Write a program that copies contents of one file into another file.
8. List c++ stream classes along with their function. (any two classes)
9. Explain ios :: app and ios :: in flags
10. Write a C++ program to copy the contents of a source file student 1.txt to a destination
file student 2.txt using file operations.
11. Explain file modes used to perform file operations
12. List all stream classes used in stream operation.
13. Develop c++ program to open and read content of file also write “object oriented”
string in file and close it.
14. Develop c++ program to check Detection of end of file.

You might also like