Important questions of C++ for board exams for Tribhuvan University, Pokhara University and Purbanchal University.







pdf format:-
{chapterwise questions }


Chapter 1

 i) Differentitae between OOP and POP. 

 ii) Prons and Cons of POP and OOP.

 iii) OOP as a new programming paradigm. Explain. 

iv) Software development process is not linear.Justify 

v) Justify the statement Computation as Simulation. 

vi) What are the different types of classes ? Explain.

 vii) Explain the main features of OOP. 

viii) How can you achieve abstraction in OOP? Explain with suitable examples.

 ix) In what ways does OOP help in coping with programming complexity? 

x) Explain the notion ‘Everything is an object’ in OOP. 

Chapter 2 

1 ) Define all these terms with the help of program.

 i) Class ii.Agent iii.Properties iv.State v.Methods vi.Behaviour vii.Responsibility viii.Messages 

2) Explain data hiding and encapuslation ? Explain different access specifier used in C++. 

3) What is data hiding ? How can you achieve data hiding in C++ ? Explain with suitable program. 

4) Differentiate between class and structure. Explain them with example. 

5) Why class is more preffered over structure ? Explain 

6) Explain different types of functions used in C++ with suitable program. 

7) Difference between pointer variable and reference variable.

 8) Friend function violates encapsulation. Explain with suitable program. 

9) What is the purpose of using default arguments? Explain with examples. 

\10) When do we use inline function ? Explain with suitable program. 

11) List out the properties of static data member and static functions.

 12) Pros and Cons of I) Friend Function II) Inline funcitonIII) Static Function 

13) Explain friend class with suitable program. 

Chapter 3

 I) Explain constructor with its properties. 

II) Explain different types of constructors .

 III) Explain two different way of creating constructor .(Hint Assignment Constructor and Initialized Constructor)

 IV) Differentiate between static memory allocation and dynamic memory allocation. 

V) Explain DMA process in C++. What is the purpose of new and delete operator ? 

VI) What are the advantages and disadvantages of DMA ?

 VII) Which one is more flexible Static MA or Dynamic MA ? Explain. 

VIII) Explain destructor with its properties ? 

\IX) Difference between constructor and destructor.

 X) Can constructor and destructor be overloaded ? Explain with suitable program. 

XI) Explain message passing formalism with suitable program.

 XII) Explain memory map and memory recovery.

 XIII) Explain dynamic constructor with suitable example. 

XIV) Show different ways of using copy constructor with suitable progam. 

XV) Can we have more than one destructor in a program? Explain.

 Chapter 4 

I) What is inheritance ? List out different types of inheritance and explain all of them with a suitable progam.

 II) Inheritance is one of the important features of OOP . Justify

. III) Why multiple inheritance is dangerous ? Explain with suitable example.

 IV) Explain why and when to use inheritance.

 V) What do you mean by visibility mode ? Explain different visibility modes used in C++ with syntax and suitable program. 

VI) What do you mean by virtual base class ? At which condition it has to be implemented ? Explain with suitable example.

VII) Write syntax for all types of inheritance. 

VIII) What is composition ? List out the conditions that need to be satisified for composition. 

IX) Write short notes on Software Reusability in C++. 

X) If you are asked to perform a mock test of real world object Car .Which software reusability technique will you follow and why? 

XI) Difference between is-a rule and has-a rule with suitable example. 

XII) Pros and Cons of all types of inheritance

 XIII) Explain subclass, subtype, principle of substitutablity,generalization ,specialiazation. 

XIV) Merits and demerits of Inheritance and Composition 

XV) Explain ambiguity that occurs in multiple inheritance.

 XVI) Is it mandatory to create constructor in derived class if base class contains constructor ? Explain. 

XVII) Base class constructor won’t get inherited in derived class. Support your answer with suitable example.

 XVIII) What is diamond problem in inheritance ? Explain how virtual inheritance solve the problem of diamond problem. 

XIX) ‘Ambiguity is a necessary evil’, explain by example how it can be effectively solved in complex programming. Necessary evil - something unpleasant that must be accepted in order to achieve a particular result 

Chapter 5 

I) Differentiate between compile time polymorphism and runtime polymorphism.

 II) Explain function overloading with example.

 III) Why do we need to overload the operator ?List out the rules that need to be followed during operator overloading. 

IV) Explain different types of operator overloading with suitable program. 

V) Explain this pointer and object pointer with suitable program. 

VI) Explain the need of virtual functions and pure virtual functions with suitable programs. 

VII) Difference between function overloading and function overriding. 

VIII) What is abstract class ? Explain with suitable program. 

IX) Difference between virtual function and pure virtual function.

X) Explain different type of type conversion technique with syntax and suitable program.

 XI) How can you achieve compile time and runtime polymorphism. Explain with examples. 

XII) Can we create object from the class which have pure virtual function ? Explain. 

XIII) When base class and derived class have same function name what will happen when derived class object call that function ? Explain with suitable example. 

XIV) What are the rules for virtual functions ? 

XV) What is the purpose of virtual destructor ? Explain with suitable example.

 XVI) Explain pure polymorphism.

 Chapter 6

 I) What is template and template programming ? List out merits and demerits of template programming. 

II) What is generic programming ? Explain

 III) Explain function template and class template with syntax and suitable program 

IV) Explain STL and its components with suitable program.

 V) Explain exception handling technique with syntax and suitable program. 

VI) How can you use multiple catch statement in exception handling ? Explain with suitable program.

 VII) How can you use nested try catch block in the program? Explain with suitable program. 

VIII) What are the operations that can be performed in Stack ? Explain with suitable program. 

IX) What are the advantages of using exception handling ?\

 Chapter 7

 I) Responsiblity implies non-interference. Explain 

II) Reusablity implies non-interference. Explain 

III) Difference between A) Programming in large and programming in small B) Interface and ImplementationC) Cohesion and Coupling IV) Define software components. Explain different aspects of software component. V) Explain CRC cards and sequence diagram with suitable example.

 VI) What are the rules that need to be followed while naming the components. 

VII) Explain implementation and integration of components. 

VIII) Explain Responsibility Driven Design. 

IX) Explain role of behaviours in OOP. 

X) How can you design and represent components ? 

Programs 

1) Create a class named Simple_Interest which have a data member principle,rate and time. It should have member function getdata() to retrieved data from user,calculateinterest() to calculate interest and display() to display the interest of customers along with principle,rate and time. A) WAP to calculate simple interest of one customer. B) WAP to calculate simple interest of 20 customers. C) Find the customer with high interest and low interest. D) WAP keeping rate 8% as default argument. E) Write same program using constructor for both single customer and 20 customers 

2) WAP to sort n numbers in ascending order and descending order using DMA. 


3) Create a class named Complex which have a data member real and imaginary. You program should have default and parameterized constructor to initialize data member. WAP overloading A) unary operator ‘++’ where real and imaginary data member will be incremented B) Binary operator ‘+’ operator to add two complex number C) Relational ‘>’ operator to compare absolute value of two complex number.

 4) Create a class named Time which have a data member hours , minutes and seconds. Data member are initialized using default and parameterized constructor. WAP overloading ‘+’ and ‘-’ operator to find the sum and difference of two time interval.

5) WAPtoconvert polarformtorectangularformbywriting conversion functionin destinationclass. 

6) WAP to create a class Triangle which have base and height as a private data member. It should have a constructor to initialize the value of the data member and member function area and perimeter to display the area and perimeter of the triangle. 

7) WAP to find the sum of two complex number using friend function.

 8) WAP to swap two variables of two classes using friend function.

 9) WAP to demonstrate template functions with two arguments

 10) WAP overloading ‘+’ operator to concatenate two strings 

 12) Write a progam with class Fibo to realize following code snippet Fibo f=1; for(i=1;i<=10;i++) { ++f; f.display(); } (Hint: Overload ++ operator and conversion technique)

 13) Write a function template to calculate the average and multiplication of numbers

14) Create a class time a constructor having hour,minute and second as an arguments is use to take two time data from user. The add function that takes twoclass objects an arguments adds them respectively then display aggregate result. (Apply 60 second = 1 minutes and 60 minutes= 1 hour) 

15) Create a class Person with data member Name,age,address and citizenship number. Write a constructor to initialize the value of a person. Asssign citizenship number if the age of the person is greater than 16 otherwise assign value zero to citizenship number. Also create a function to display the values. 

16) Create a class called Mountain with data members name,height,location, a constructor that initializes the members to the values passed to it as parameters, a function called CmpHeight() to compare two objects and DisplayInf() to display the information of Mountain. In main, create two objects of the class mountain and print the information of the mountain which has greatest height. 

17) Write a program using template to add two integers; two floats and one integer and one float numbers respectively. Display the final result in float. 

18) Create classes called class1 and class2 with each of having one private member. Add member function to set a value (say setvalue) on each class. Add one more function max() that is friendly to both classes max() function should compare two private member of two classes and show maximum among them. Create one-one object of each class then set a value on them. Display the maximum number among them. 

19) Write a program to read a height of a person in feet and inches and convert it into meter using user defined to class type conversion method. 1 meter= 3.28084 feet , 1 feet= 12 inch

 20) Create a template function to swap two values. 

21) Create a template class to swap two values. 

22) Create a class called Employee with data member Code,Name,Address, Salary. Create a constructor to initialize the member of the class. Also create another constructor so that we can create an object from another object. Define member function display() to display to the information of that class. 

23) Create a class Person with data members Name,Age and Address. Create another class Teacher with data members Qualification and Department. Also create another class Student with data member Program and Semester. Both class are inherited from the class Person.

24) Create a base class Shape which have pure virtual function area() and derived class Rectangle,Triangle and Square which override the area() function . Assume all the necessary data members and functions for the derived class and use constructor to initialize that data member .Inside main, create a pointer of baseclass and object of derived class.Calculate the area of derived class with the help of baseclass pointer. 

25) WAP to sort 5 integer numbers using STL container vector.

 26) WAPtoconvertrectangularformtopolarformbywriting conversion functionin destinationclassusing template.

\ 27) The class Record derives information from both Account and Admin.Every class has atleast one constructor which uses base class constructor. Create a member function display() in each to display the information.

Comments