Skip to content
CS-305 · Object Oriented Programming & Methodology/Unsolved PYQ Paper

CS-305 Object Oriented Programming and Methodology - Nov 2022 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 is Object Oriented Programming? Write merits and demerits of OOPs and also write applications of object-oriented programming.
    How to answer
    • Definition of Object-Oriented Programming (OOP) and its core paradigm.
    • Key merits: reusability, modularity, data security/hiding, ease of maintenance.
    • Key demerits: steep learning curve, larger program size, potentially slower execution.
    • Major real-world applications: GUI development, simulation and modeling, database systems, gaming engines.
  2. 7 Marks
    bWhat are the different kinds of relationship among classes? Explain.
    How to answer
    • List various relationships: Association, Aggregation, Composition, Inheritance (Generalization), and Dependency.
    • Explain 'is-a' relationship (Inheritance) with a brief code/class diagram example.
    • Explain 'has-a' relationships (Aggregation vs. Composition with whole-part lifecycle).
    • Explain 'uses-a' relationship (Dependency) and general Association.
  3. 7 Marks
    aWhat do you mean by the term class and object? What is the relation and difference between these two? Write an example (syntax) to define a class in C++. Explain state, behavior, and identity of object in brief.
    How to answer
    • Define class (blueprint/user-defined data type) and object (instance of a class).
    • Compare class vs. object (logical vs. physical entity, memory allocation).
    • Provide standard C++ syntax/code example for declaring a class and creating an object.
    • Explain the three object characteristics: State (attributes/values), Behavior (methods/operations), Identity (unique memory address/identifier).
  4. 7 Marks
    bDiscuss construction and destruction of an object. Write a program to explain it.
    How to answer
    • Explain object lifecycle: construction allocates memory and initializes members; destruction frees resources when object goes out of scope.
    • Role of constructor and destructor functions in object lifecycle.
    • Write a complete C++ program containing a class with a constructor and destructor with print statements.
    • State the expected output showing the reverse order of destruction for local objects.
  5. 7 Marks
    aExplain the concept of association an aggregation in object-oriented approach. What is and Abstract class? Why Abstract classes are used?
    How to answer
    • Define Association (relationship between independent objects) and Aggregation (weak 'has-a' whole-part relationship where parts can exist independently).
    • Define Abstract Class (a class with at least one pure virtual function that cannot be instantiated).
    • Explain purpose of Abstract Classes: provides a common base interface, enforces implementation guidelines on derived classes, supports runtime polymorphism.
  6. 7 Marks
    bWhat are the access modifiers? How many types of access modifiers are available in C++? Explain each one in detail and their role in implementing the data hiding in object-oriented programming.
    How to answer
    • Definition of access modifiers (specifiers).
    • List the three types available in C++: public, private, protected.
    • Explain the accessibility rules for each specifier (within class, derived class, outside class).
    • Discuss how private specifiers enable data hiding and encapsulation by preventing direct external access to sensitive class attributes.
  7. 7 Marks
    aExplain the role of constructor and destructor in a class. What are the different types of constructors in C++? Write the appropriate syntax for the copy constructor and parameterized constructors.
    How to answer
    • Role of constructor (initialization upon creation) and destructor (cleanup/resource deallocation upon destruction).
    • Types of constructors: Default, Parameterized, Copy (and dynamic/move constructors).
    • Syntax and example of parameterized constructor: `ClassName(type arg1, ...);`.
    • Syntax and example of copy constructor: `ClassName(const ClassName &obj);`.
  8. 7 Marks
    bExplain method overloading and method overriding with example.
    How to answer
    • Define method overloading: functions in the same scope with same name but different signatures (compile-time polymorphism).
    • Provide code example of method overloading.
    • Define method overriding: derived class redefines a base class virtual function with identical signature (runtime polymorphism).
    • Provide code example of method overriding using base pointer and derived object.
  9. 7 Marks
    aWhat is Operator overloading? Design a Distance class with data members for distance in meters, centimeters, and millimeters. Write a program to overload addition and subtraction operators respectively in a class Distance.
    How to answer
    • Define operator overloading: giving special meaning to an existing C++ operator when applied to user-defined data types.
    • Class Distance declaration with member variables: `meters`, `centimeters`, `millimeters`.
    • Implementation of `operator+` handling unit conversions/carries.
    • Implementation of `operator-` handling unit borrowing/conversions.
    • `main()` driver code demonstrating adding and subtracting two Distance objects and printing the result.
  10. 7 Marks
    bWhat is String? Explain functions of strings with suitable examples.
    How to answer
    • Definition of String: sequence of characters terminated by null character in C-style, or `std::string` class object in C++ standard library.
    • List and explain common string functions/methods: `length()`/`size()`, `append()`/concatenation, `substr()`, `find()`, `compare()`, or C-string functions (`strlen`, `strcpy`, `strcat`, `strcmp`).
    • Provide code snippets demonstrating the usage of these functions.
  11. 7 Marks
    aWhen does ambiguity arise in multiple inheritance? How can one resolve it? Develop a program in C++ to create a derived class having the following items: name, age, rollno, marks, empcode and designation. Design a base class student having data members as rollno, marks and another base class is employee having data members as empcode and designation. These both base classes are inherited from a single base class person with data members name and age. The program should carry out the required input() and output() member function for all.
    How to answer
    • Explain the Diamond Problem ambiguity in multiple inheritance (multiple paths to common ancestor duplicate data members).
    • Explain resolution using virtual base classes (`virtual public Person`) and scope resolution operator (`::`).
    • Define class `Person` with `name`, `age`.
    • Define classes `Student` and `Employee` virtually inheriting from `Person`.
    • Define derived class (e.g., `WorkingStudent`) inheriting both, implementing `input()` and `output()` methods.
    • `main()` driver creating object, taking inputs, and displaying complete information.
  12. 7 Marks
    bExplain the concept of interfaces and abstract class in detail.
    How to answer
    • Define Abstract Class: a class containing at least one pure virtual function, can have concrete methods and instance variables.
    • Define Interface in C++ context: pure abstract class containing only pure virtual functions and no member data/implementation.
    • Key differences: method implementation support, data fields, partial vs complete abstraction.
    • Illustrative C++ syntax/code for both concepts.
  13. 7 Marks
    aExplain exception handling and multithreading.
    How to answer
    • Define Exception Handling: mechanism to handle runtime errors gracefully.
    • Explain `try`, `catch`, and `throw` blocks with a short code snippet.
    • Define Multithreading: concurrent execution of two or more parts of a program to maximize CPU utilization.
    • Explain thread lifecycle, benefits, and standard C++ `<thread>` usage.
  14. 7 Marks
    bDefine polymorphism and its types. How compile time polymorphism is different from run time polymorphism.
    How to answer
    • Define Polymorphism ('many forms'): the ability of a message or function to be displayed or executed in more than one form.
    • List types: Compile-time (Static) vs Run-time (Dynamic).
    • Tabular comparison: Early binding vs Late binding, function/operator overloading vs virtual functions, performance vs flexibility.
    • Brief code example showing both kinds.
  15. 14 Marks
    Write short note on (any two):
    1. i)Virtual function
    2. ii)File Handling
    3. iii)Data collection
    How to answer
    • i) Virtual function: member function in base class declared with 'virtual', overridden in derived class, enables runtime dynamic dispatch via vtable/vptr.
    • ii) File Handling: stream classes (`ifstream`, `ofstream`, `fstream`), file modes, opening/reading/writing/closing files.
    • iii) Data collection: concepts of gathering data in systems, or Standard Template Library (STL) collection containers (vector, list, map).
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