Browse papers
A

Section A: Long Answer Questions

Attempt all / any as specified.

4 questions
1long12 marks

What is the basic difference between procedure-oriented programming and object-oriented programming? Explain the concepts of data abstraction and encapsulation with a suitable example. Write a C++ class Distance having data members feet and inches, with member functions to read data, display data, and add two distances; demonstrate its use in main().

classes-and-objectsconstructors
2long12 marks

(a) Define inheritance and explain its types with diagrams. What is the order of execution of constructors and destructors in multilevel inheritance? (b) What is a virtual function? Explain how runtime polymorphism is achieved in C++ using base-class pointers and virtual functions, with a program example involving a base class Shape and derived classes Circle and Rectangle.

inheritancepolymorphismvirtual-functions
3long12 marks

(a) What are the rules and restrictions for operator overloading in C++? Which operators cannot be overloaded? (b) Write a class Complex to represent complex numbers. Overload the + and * operators using member functions and overload the << operator using a friend function so that complex objects can be added, multiplied, and printed directly.

operator-overloadingconstructors
4long14 marks

(a) What is a template? 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) What is the Standard Template Library (STL)? Briefly explain containers, iterators, and algorithms, and write a program using vector to store and display a list of integers in sorted order.

templatesstlexception-handling
B

Section B: Short Answer Questions

Attempt all / any as specified.

8 questions
5short6 marks

Differentiate between a constructor and a destructor. Explain copy constructor and parameterized constructor with a suitable code example each.

constructorsdestructors
6short6 marks

Differentiate between compile-time polymorphism and run-time polymorphism. Explain function overloading with a program example.

polymorphismfunction-overloading
7short6 marks

Explain the visibility of base-class members in public, private, and protected inheritance. Illustrate with a table showing how the access of members changes in the derived class.

inheritanceaccess-specifiers
8short6 marks

What is exception handling? Explain the use of try, catch, and throw keywords with a program that handles a division-by-zero exception.

exception-handling
9short6 marks

Write a C++ program that creates a text file, writes student records (name and marks) into it, and then reads the records back from the file to display them on screen using ifstream and ofstream.

file-iostreams
10short6 marks

What is a pure virtual function? Explain abstract classes and their use in C++ with an example. Why can an object of an abstract class not be created?

virtual-functionsabstract-class
11short6 marks

What is a friend function? Explain its characteristics and write a program in which a friend function accesses the private members of two different classes to compute their sum.

classes-and-objectsfriend-function
12short4 marks

Explain stream class hierarchy in C++. What are formatted and unformatted I/O operations? Briefly describe any three I/O manipulators with examples.

streamsmanipulators