2076

CSC166 · TU past paper

Object Oriented Programming 2076 question paper

The complete TU 2076 exam paper for Object Oriented Programming (CSC166), all 12 questions with solved model answers written to the mark scheme.

Tap a question to open its answer.

  1. 110 marksTypes of inheritanceAnswer

    Write a program according to the specification given below:- Create a class Teacher with data members id & subject and member functions for reading and displaying data members.- Create another class Staff with data members id & position, and member functions for reading and displaying data members.- Derive a class Coordinator from Teacher and Staff and the class must have its own data member department and member functions for reading and displaying data members.- Create two object of Coordinator class and read and display their details.[10]

    This program demonstrates multiple inheritance in C++, where a derived class Coordinator inherits from two base classes Teacher and Staff. The derived class has its own data member department along with inherited members from both base c...

  2. 210 marksFundamental of operator overloadingAnswer

    Explain the concept of operator overloading? List the operators that cannot be overloaded. Write programs to add two object of distance class with data members feet and inch by using member function and friend function.[10]

    --- Operator overloading is a compile-time polymorphism feature in C++ that allows the programmer to redefine or extend the meaning of built-in operators (such as +, -, , ==, etc.) for user-defined data types (classes/objects). When an o...

  3. 310 marksPolymorphism and its rolesAnswer

    Explain types of polymorphism briefly. Write down roles of polymorphism. How can we achieve dynamic polymorphism briefly? Write down roles of polymorphism. How can we achieve dynamic polymorphism? Explain with example.[10]

    Polymorphism means "one name, many forms." It allows the same function or operator to behave differently depending on the context. There are two main types: --- - The function to be called is determined at compile time. - Also called sta...

  4. 45 marksFunctionsAnswer

    What is meant by return by reference? How can we return values by reference by using reference variable? Illustrate with example. [5]

    Return by reference means that a function returns a reference (alias) to a variable rather than returning a copy of its value. When a function returns by reference, the caller receives direct access to the original variable, and the retu...

  5. 55 marksInitialization of class objectsAnswer

    What is destructor? Write a program to show the destructor call such that it prints the message 'memory is released'. [5]

    A destructor is a special member function of a class that is automatically called when an object goes out of scope or is explicitly deleted. It is used to release memory and other resources that were allocated to the object during its li...

  6. 65 marksThis pointerAnswer

    What is this pointer? How can we use it for name conflict resolution? Illustrate the use of multiple catch statement with example. [5]

    --- The this pointer is an implicit (hidden) pointer available inside every non-static member function of a class. It automatically points to the object that invoked the member function. - Every object has access to its own address throu...

  7. 75 marksCharacteristics of object oriented languagAnswer

    How object oriented programming differs from object based programming language? Discuss benefits of OOP. [5]

    --- Object-Based Programming languages support objects and encapsulation but do not support inheritance and polymorphism. They are limited to using objects as data structures without the full power of OOP. Object-Oriented Programming lan...

  8. 85 marksDynamic Memory Allocation with new and delAnswer

    What is use of new and delete operators? Illustrate with example. What are advantages of new over malloc. [5]

    The new operator is used to dynamically allocate memory at runtime from the heap (free store). It allocates memory for a variable or object and returns a pointer to it. If allocation fails, it throws a badalloc exception. Syntax: The del...

  9. 95 marksExceptional HandlingAnswer

    How can define catch statement that can catch any type of exception? Illustrate the use of multiple catch statement with example. [5]

    To catch any type of exception regardless of its type, we use the ellipsis (...) inside the catch statement's parentheses. This acts as a catch-all handler and must be placed as the last catch block. Syntax: The catch(...) block will han...

  10. 105 marksFunction templatesAnswer

    What is meant by template? How can you define function template to return maximum of two integers, floats, or characters? Explain with example. [5]

    A template is a feature in C++ that allows writing generic programs. A template defines a blueprint for a function or class that can work with any data type. Instead of writing separate functions for each data type (int, float, char, etc...

  11. 115 marksRead/Write from FileAnswer

    Which function can be used for reading and writing object? Define briefly. Write a program that reads values of two objects of students class (assume data members are id, name, and level) and display the data in monitor. [5]

    In C++, the read() and write() member functions of file stream classes are used for reading and writing objects (binary data) to/from files or streams. Used to write an object (block of bytes) to a stream. Syntax: - (char ) casts the obj...

  12. 125 marksInput/Output Streams and ManipulatorsAnswer

    Write short notes on:- Cascading of IO operation - Pure Virtual Function [5]

    --- Cascading of I/O operations refers to the technique of chaining multiple input or output operations together in a single statement using the insertion operator (<<) or extraction operator (). This is possible because in C++, the oper...