Skip to content
IT-304 · Object Oriented Programming & Methodology/Unsolved PYQ Paper

IT-304 Object Oriented Programming and Methodology - Dec 2023 Question Paper

Under each question, How to answer lists the points an answer should cover, outlined by CampusPrep from the syllabus. Check the details against your textbook.

  1. 7 Marks
    aWhat are the different features of Object Oriented programming? How C++ is different for C language?
    How to answer
    • List key OOP features: Abstraction, Encapsulation, Inheritance, Polymorphism, Class & Object
    • Briefly describe each feature
    • Compare C and C++: procedural vs object-oriented, bottom-up vs top-down approach, support for classes, function overloading, namespaces, memory management (malloc/free vs new/delete)
  2. 7 Marks
    bExplain with examples of different types of inheritance. Why multiple inheritance can induce complexity in the program?
    How to answer
    • Define inheritance and its primary advantages
    • Explain types of inheritance: Single, Multiple, Multilevel, Hierarchical, Hybrid with syntax/examples
    • Explain the Diamond problem (ambiguity) in multiple inheritance
    • Describe how virtual base classes resolve multiple inheritance ambiguity in C++
  3. 7 Marks
    aExplain the purpose of the constructor in C++. Demonstrate calling one constructor from another in the case of constructor overloading.
    How to answer
    • Define constructor and state its purpose (automatic initialization of data members on object creation)
    • Explain constructor overloading (multiple constructors with different parameter signatures)
    • Demonstrate constructor delegation (C++11 target constructor syntax `ClassName(...) : ClassName(...)`) with a complete code snippet
    • Explain the execution flow when delegating
  4. 7 Marks
    bExplain operator overloading using some unary operator. Also, discuss pros and cons of it.
    How to answer
    • Define operator overloading and its purpose
    • Explain overloading of a unary operator (e.g., ++ or -) with syntax and code snippet
    • Contrast member function vs friend function implementation
    • List pros: intuitive syntax, code readability, seamless user-defined types integration
    • List cons: potential misuse leading to confusing code, performance overhead, inability to define new operators
  5. 7 Marks
    aExplain any two ways through which we can give input in C++ program.
    How to answer
    • Identify two methods: e.g., standard input using `cin >>` and string line input using `getline(cin, str)` or `cin.getline()` (or command-line arguments `argc`/`argv`)
    • Provide syntax and a small code example for each method
    • Discuss limitations or handling of whitespace/delimiters for both
  6. 7 Marks
    bHow structures are different from class? Illustrate it with a program.
    How to answer
    • Highlight primary difference: default access specifier is public in `struct` and private in `class`
    • Mention default inheritance: public for `struct` and private for `class`
    • Provide a C++ program showing error or behavior when accessing members declared without access specifier in both `struct` and `class`
  7. 7 Marks
    aCompare structure with class with an example.
    How to answer
    • Tabular comparison between structure and class
    • Explain default public vs default private member access
    • Provide a simple code example contrasting instantiation and member access
  8. 7 Marks
    bExplain the concept of new and delete in memory management concept.
    How to answer
    • Define dynamic memory allocation in C++
    • Explain `new` operator: syntax, allocating single variables and arrays, calling constructor
    • Explain `delete` and `delete[]` operators: syntax, releasing memory, calling destructor
    • Discuss advantages over C's `malloc` and `free`
  9. 14 Marks
    Differentiate among the following with an example:
    1. i)Abstract and non-abstract classes
    2. ii)Runtime and compile-time polymorphism
    How to answer
    • Part (i): Define abstract class (contains at least one pure virtual function, cannot instantiate directly) vs non-abstract/concrete class. Provide illustrative code example.
    • Part (ii): Define compile-time polymorphism (early/static binding, achieved via function/operator overloading) vs runtime polymorphism (late/dynamic binding, achieved via virtual functions). Provide code example demonstrating dynamic dispatch.
  10. 7 Marks
    aExplain different keywords used for handling exceptions at run time.
    How to answer
    • Explain exception handling concept in C++
    • Describe keyword `try`: encloses the code that might throw an exception
    • Describe keyword `throw`: used to signal the occurrence of an anomaly/exception
    • Describe keyword `catch`: block that handles the exception thrown by `try`
    • Provide syntax and a small code example showing try-throw-catch block
  11. 7 Marks
    bDiscuss following functions:
    1. i)Virtual functions
    2. ii)Pure functions
    3. iii)Friend functions
    4. iv)Static functions
    How to answer
    • i) Virtual functions: member functions in base class marked `virtual` enabling runtime polymorphism via vtable/vptr.
    • ii) Pure virtual functions: virtual function with no implementation in base class (`= 0`), making the class abstract.
    • iii) Friend functions: non-member functions granted access to private and protected members of a class using keyword `friend`.
    • iv) Static member functions: class-level functions that can access only static data members, callable using `ClassName::functionName()`.
  12. 7 Marks
    aWrite a programme in C++ that demonstrates how to use inline member functions and publish it? Discuss both the similarities and differences between macros and inline functions as well.
    How to answer
    • Write a C++ program defining an inline member function (either defined inside the class body or with `inline` keyword outside)
    • Explain how the compiler substitutes code at the call site
    • Similarities: both reduce function call overhead by code substitution
    • Differences: macros expanded by preprocessor without type checking; inline functions expanded by compiler with strict type and scope checking, safe evaluation of arguments
  13. 7 Marks
    bDiscuss how C++ deals with memory management? Show an example of clearing a memory used by an object.
    How to answer
    • Explain C++ memory architecture: stack (automatic), heap (dynamic), and global/static segments
    • Explain manual memory management using `new` and `delete` operators
    • Explain the role of destructors in releasing resources (RAII concept)
    • Provide a C++ program creating an object dynamically and deallocating it with `delete`, highlighting the destructor call
  14. 14 Marks
    Explain the following with an example:
    1. a)File I/O
    2. b)Debugging pointer
    How to answer
    • Part (a): Explain File I/O in C++ using `fstream` library (`ofstream`, `ifstream`), showing file open/read/write/close with code snippet.
    • Part (b): Explain debugging pointers: common pointer errors (dangling pointers, memory leaks, null pointer dereference, wild pointers) and techniques/best practices to debug and fix them (setting pointers to `nullptr`, assertions, smart pointers).
Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in