K. K.
Wagh Institute of Engineering Education & Research, Nashik
Department of Information Technology
2300118F: Object Oriented Programming - Question Bank
Class: [Link] (H)
Unit-I Fundamentals of OOP
Sr. No. Question
1. What is inline function? What are their advantages?
What do you mean by constructor and destructor? Write appropriate C++ program which uses
2.
copy constructor.
What is Friend Function? Explain with suitable sample code in C++. What are the merits and
3.
demerits of using friend function?
4. Explain how to access the data members of one class using friend function of another class.
5. List and explain various features of OOP.
6. What is static function?
7. Compare Procedure oriented programming Vs Object oriented programming.
Define inline function. Write a C++program for finding the area of a triangle using inline
8.
functions.
9. Write a program in C++ to use scope resolution operator.
Write a C++ program to calculate the area and circumference of circle using member function
10.
outside the class.
Write a C++ program to create a database of class Cricket with data members Player name,
11. Team Name and Average .Create a default constructor and parameterised constructor and
destructor.
Write correct code for given C++ code: 1)cout<<"X="x; 2)cin>>Y;X; 3)cout<<\
12.
n<<"Name"<<name; 4)// cout<< "Hello"; */ 5)cin>>"Enter value of X">>X;
What is use of inline keyword in C++? Write an inline function cube to find cube of given
13.
integer value.
Create a class time with hours and minutes as data members. Write function gettime and
showtime to take input and show output respectively. Write a function addtime to add time in
14.
hours and minutes for two different objects of time class. Find addition of two time values by
calling all functions from main.
Write a class complex for addition of complex numbers with real and imaginary data
15. members. Write default and parameterized constructors. Write function to add two complex
numbers. Find addition of two complex numbers by using constructors and add function.
16. What is data hiding in a class? Explain with suitable sample code in C++ and diagram.
17. What is class and object? Explain in detail with a sample code in C++. How are they created?
18. Write short note on access specifiers with sample code in C++ for each.
19. What are rules to write contractors and destructors in C++.
20. What is data member and member functions. List down types of member functions
21. What is abstraction and how abstraction is implemented in C++.
22. C++ Program to enter student details by Passing parameters to constructor.
Write a C++ Program to display Information of 2 employees. Declare the class of employee.
23.
Create an array of class objects. Read and display the content of array
24. What is the significance of static data and member functions in C++?
1
K. K. Wagh Institute of Engineering Education & Research, Nashik
Department of Information Technology
2300118F: Object Oriented Programming - Question Bank
Class: [Link] (H)
25. State the use of static data member of a class.
26. Explain the static variable in C++ with help of sample code.
27. Write a C++ program to calculate sum of distance and display the result using friend function.
28. Enlist elements of OOP. Explain any three.
29. Explain how constructor is differing from function with the help of example.
30. How is a member function of a class defined?
31. How does a C++ structure differ from a C++ class?
32. Explain Copy Constructor with the help of sample code in C++.
33. Explain abstract data type with suitable sample code in C++.
34. Define terms: encapsulation, abstraction, polymorphism, binding
Write a C++ program to Write a program in C++ to create a database of a student's
information system containing the following information: Name, Roll number, Class.
35.
Construct the database with suitable member functions. Make use of constructor, default
constructor, copy constructor, destructor, count number of students using static variable.
36. Write a program to find out the square and cube of a number using friend function.
Unit-II Inheritance
Sr. No. Question
1. What is the class hierarchy in inheritance? Explain.
2. What is ambiguity problem in inheritance and how is it resolved?
Imagine a publishing company that markets both book and audiocassette versions of its works.
Create a class publication that stores the title (a string) and price (type float) of a publication.
From this class derive two classes: book, which adds a page count (type int), and tape, which
3. adds a playing time in minutes (type float). Each of these three classes should have a getdata()
function to get its data from the user at the keyboard, and a putdata() function to display its
data. Write a main() program to test the book and tape classes by creating instances of them,
asking the user to fill in data with getdata(), and then displaying the data with putdata().
4. Explain nesting of classes with help of sample code in C++.
5. Explain friend class with help of sample code in C++.
6. Explain hierarchical inheritance with sample code in C++.
7. Explain virtual base class & virtual function with a suitable sample code in C++?
8. What does inheritance mean in C++? Explain Multilevel Inheritance with example.
9. Explain abstract class concept along with sample code in C++.
Write a program to implement multilevel inheritance. Create a class student to store roll
10. number .create another class test derived from student to store marks obtained in two subjects
and create a class result derived from test class containing the total marks obtained in the test.
Write a C++ program to create a class “Area” and derive a class named “Square” . Calculate
11.
the area of square using suitable member functions and display the area.
2
K. K. Wagh Institute of Engineering Education & Research, Nashik
Department of Information Technology
2300118F: Object Oriented Programming - Question Bank
Class: [Link] (H)
12. What are different types of inheritance in C++, explain with suitable diagrams.
Write academic and sports classes with marks as data member for each class. Write a
13. marksheet as derived class from both sports and academic. Find addition of marks of academic
and sports using object of derived class.
14. What is purpose of virtual keyword in inheritance? Explain with suitable example.
Write a parent and a child classes. Write parameterized constructors in both classes. Create an
15.
object of child class using parameterized constructor of child and base class in main.
16. What is meant by initialization list? Explain with suitable sample code in C++.
17. What is the hierarchy of calling constructors in derived class in different types of inheritances
18. Explain multiple inheritance with example.
19. Explain nested class with the help of example.
20. Write a C++ Program to find Area of Rectangle using inheritance.
21. Demonstrate hybrid inheritance with the help of suitable example.
Write a C++ program demonstrating use of the pure virtual function with the use of
22.
base and derived classes.
23. Define inheritance. Explain multiple inheritance with example.
A boy has his money deposited Rs.1000, Rs.1500 and Rs.2000 in banks-Bank A, Bank B and
Bank C respectively. We have to print the money deposited by him in a particular bank.
Create a class 'Bank' with a function 'getBalance' which returns 0. Make its three subclasses
24.
named 'BankA', 'BankB' and 'BankC' with a function with the same name 'getBalance' which
returns the amount deposited in that particular bank. Call the function 'getBalance' by the
object of each of the three banks.
Write a C++ program to make a class named Fruit with a data member to calculate the number
of fruits in a basket. Create two other class named Apples and Mangoes to calculate the
25.
number of apples and mangoes in the basket. Print the number of fruits of each type and the
total number of fruits in the basket. Use static variables.
Create a class 'Degree' having a function 'getDegree' that prints "I got a degree". It has two
subclasses namely 'Undergraduate' and 'Postgraduate' each having a function with the same
26.
name that prints "I am an Undergraduate" and "I am a Postgraduate" respectively. Call the
function by creating an object of each of the three classes.
We want to calculate the total marks of each student of a class in Physics, Chemistry and
Mathematics and the average marks of the class. The number of students in the class is entered
by the user. Create a class named Marks with data members for roll number, name and marks.
27.
Create three other classes inheriting the Marks class, namely Physics, Chemistry and
Mathematics, which are used to define marks in individual subject of each student. Roll
number of each student will be generated automatically.
How do the properties of the following derived classes differ?
28.
i) class D1:private B{........}; ii) class D2:public B{..........}; iii) class D2:protected B{..........};
29. What does inheritance mean in C++? Explain its types.
Write a C++ program to create a base class Person (name and phone number).
30.
Derive Academic Performance (Degree, percentage) class from Person class.
3
K. K. Wagh Institute of Engineering Education & Research, Nashik
Department of Information Technology
2300118F: Object Oriented Programming - Question Bank
Class: [Link] (H)
Display Biodata of the person.
31. Describe the syntax of multiple inheritance. When do we use such an inheritance ?