BE Computer Engineering (Pokhara University) Object Oriented Programming in C++ (PU, CMP 162) Question Paper 2079
This is the official BE Computer Engineering (Pokhara University) Object Oriented Programming in C++ (PU, CMP 162) question paper for 2079, as set in the regular annual examination. It carries 100 full marks and a time allowance of 180 minutes, across 12 questions. On Kekkei you can attempt this Object Oriented Programming in C++ (PU, CMP 162) past paper online with a timer, get instant AI feedback and step-by-step solutions, and track the topics where you lose marks — completely free. Whether you are revising for your BE Computer Engineering (Pokhara University) Object Oriented Programming in C++ (PU, CMP 162) exam or solving previous years' question papers, this 2079 paper is a great way to practise under real exam conditions.
Section A: Long Answer Questions
Attempt all / any as specified.
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().
(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.
(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.
(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.
Section B: Short Answer Questions
Attempt all / any as specified.
Differentiate between a constructor and a destructor. Explain copy constructor and parameterized constructor with a suitable code example each.
Differentiate between compile-time polymorphism and run-time polymorphism. Explain function overloading with a program example.
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.
What is exception handling? Explain the use of try, catch, and throw keywords with a program that handles a division-by-zero exception.
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.
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?
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.
Explain stream class hierarchy in C++. What are formatted and unformatted I/O operations? Briefly describe any three I/O manipulators with examples.