Browse papers
A

Section A: Long Answer Questions

Attempt all / any as specified.

4 questions
1long12 marks

Differentiate between procedural programming and object-oriented programming. Define a class and an object with suitable examples. Write a C++ program to create a class Distance having data members feet and inches. Use a parameterized constructor to initialize the data members and a member function display() to show the distance. Also create an array of three Distance objects and display them.

classes-and-objectsconstructors-and-destructors
2long12 marks

(a) Explain the different types of inheritance supported in C++ with suitable diagrams. What is the ambiguity problem in multiple inheritance and how is it resolved using virtual base classes? (b) Define a base class Shape with a virtual function area(). Derive classes Circle and Rectangle from it and override area() in each. Write a program that uses base-class pointers to compute and display the area of different shapes, demonstrating run-time polymorphism.

inheritancepolymorphismvirtual-functions
3long12 marks

What is operator overloading? Explain the rules and restrictions for overloading operators in C++. Write a C++ program to define a class Complex to represent complex numbers, and overload the + and * operators to add and multiply two complex numbers respectively. Also overload the insertion operator (<<) using a friend function to display a complex number.

operator-overloadingclasses-and-objects
4long12 marks

(a) What are templates? Differentiate between function templates and class templates with examples. Write a function template to find the maximum of two values of any data type. (b) Explain exception handling in C++ using try, catch and throw keywords. Write a program that throws and handles an exception when an attempt is made to divide a number by zero.

templatesexception-handling
B

Section B: Short Answer Questions

Attempt all / any as specified.

8 questions
5short6 marks

What is a copy constructor? Explain when it is invoked. Write a C++ program to demonstrate the use of a copy constructor and explain the difference between a shallow copy and a deep copy.

constructors-and-destructors
6short6 marks

What are static data members and static member functions? Explain their characteristics. Write a program using a static data member to count the number of objects created from a class.

classes-and-objects
7short6 marks

What is a pure virtual function? Explain the concept of an abstract class with a suitable example. Why can an object of an abstract class not be created?

polymorphismvirtual-functions
8short6 marks

Explain the classes used for file handling in C++. Write a C++ program to write a list of student records (roll number and name) to a file and then read and display the records from the file.

file-streams
9short6 marks

Explain the order in which constructors and destructors are called in a derived class under single inheritance. Illustrate your answer with a suitable C++ program that includes constructors and destructors in both base and derived classes.

inheritanceconstructors-and-destructors
10short6 marks

Write short notes on any TWO of the following:

(a) this pointer (b) Function overloading vs operator overloading (c) Rethrowing an exception (d) Inline functions

exception-handlingtemplates
11short6 marks

What is a friend function? Explain its merits and demerits. Write a C++ program to find the sum of private data members of two different classes using a single friend function.

classes-and-objectsconstructors-and-destructors
12short6 marks

Differentiate between compile-time polymorphism and run-time polymorphism with examples. Explain how function overloading and virtual functions support these two forms of polymorphism in C++.

polymorphismoperator-overloading