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

AD-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
    aDescribe the various control statement with example.
    How to answer
    • Definition of control flow/statements in C++
    • Categorization: Decision making/Selection (if, if-else, switch)
    • Iteration/Looping statements (for, while, do-while)
    • Jump statements (break, continue, goto, return)
    • Brief code snippet/example for each category
  2. 7 Marks
    bDiscuss and compare run time and compile time polymorphism.
    How to answer
    • Definition of polymorphism
    • Compile-time polymorphism: Definition, mechanisms (function overloading, operator overloading), early/static binding
    • Run-time polymorphism: Definition, mechanisms (virtual functions, dynamic binding), late binding
    • Tabular comparison based on binding time, execution speed, flexibility, and implementation mechanisms
  3. 7 Marks
    aExplain object oriented programming languages with its features.
    How to answer
    • Definition and core philosophy of OOP
    • Key concepts and features: Objects and Classes
    • Encapsulation and Data Hiding
    • Abstraction
    • Inheritance
    • Polymorphism, Dynamic Binding, and Message Passing
  4. 7 Marks
    bWhat are Empty classes? Can instance empty class be created? Give reason.
    How to answer
    • Definition of an empty class (a class with no data members or member functions)
    • Affirmation that an instance of an empty class can indeed be created
    • Explanation of memory allocation: sizeof(EmptyClass) is typically 1 byte (non-zero)
    • Reason: Each object must have a unique memory address so that pointers to distinct objects are distinct
  5. 7 Marks
    aDiscuss the role of $\text{C}_{\text{out}}$ and $\text{C}_{\text{in}}$ in detail. Why they are used in C++ and from which class they belong to? Explain in detail.
    How to answer
    • Role of cout (standard output stream) with insertion operator `<<`
    • Role of cin (standard input stream) with extraction operator `>>`
    • Class hierarchy: `cin` is an object of `istream` class; `cout` is an object of `ostream` class; both declared in `<iostream>`
    • Advantages/reasons for use over C I/O (`printf`/`scanf`): type safety, extensibility to user-defined types
  6. 7 Marks
    bWhat is Operator overloading? Can friend function be used to overload the assignment operator (=).
    How to answer
    • Definition of operator overloading and its syntax
    • Rules for overloading operators
    • Direct answer regarding assignment operator: No, `=` cannot be overloaded using a friend function
    • Reason: The assignment operator (`=`) must be an explicit non-static member function of the class to avoid ambiguity and ensure correct object semantics
  7. 14 Marks
    Write short notes on (any two): i) Exception handling ii) New and delete iii) Polymorphism
    How to answer
    • i) Exception Handling: Mechanism to handle runtime errors; try, throw, and catch blocks; advantages over traditional error codes.
    • ii) New and Delete: Dynamic memory allocation/deallocation operators in C++; syntax, memory leak prevention, comparison with malloc/free.
    • iii) Polymorphism: 'Many forms' concept; types (compile-time vs run-time); benefits in code reusability and extensibility.
  8. 7 Marks
    aWrite a program in C++ which demonstrate the use of Inheritance.
    How to answer
    • Define a base class (e.g., `Vehicle` or `Person`) with data members and methods
    • Define a derived class (e.g., `Car` or `Student`) inheriting publicly from the base class
    • Implement `main()` function demonstrating creation of derived class object and calling inherited methods
    • Brief explanation of the output
  9. 7 Marks
    bExplain pointer and function pointer.
    How to answer
    • Definition of pointer: Variable storing the memory address of another variable; syntax and usage
    • Definition of function pointer: Pointer that points to the address of executable code of a function
    • Syntax for declaring, assigning, and invoking via a function pointer
    • Use cases of function pointers (e.g., callback functions, event handling)
  10. 7 Marks
    aWhat are the advantages and limitation of using default arguments in a function? Write a program which defines a function with three default arguments and call the function in four different ways.
    How to answer
    • Advantages of default arguments (flexibility, simplified calling syntax, backwards compatibility)
    • Limitations/rules (must be assigned from right to left, cannot re-specify in definition if declared in prototype, potential ambiguity with overloading)
    • C++ program with a function e.g. `void display(int a=1, int b=2, int c=3)`
    • Four function calls: `display()`, `display(10)`, `display(10, 20)`, `display(10, 20, 30)` in `main()`
  11. 7 Marks
    bHow inherited method is different from redefined method?
    How to answer
    • Definition of inherited method (method acquired directly from base class without alteration)
    • Definition of redefined method (method in derived class with same signature/name providing a new implementation, hiding the base version)
    • Key differences: behavior, memory resolution, requirement of `virtual` keyword for polymorphic behavior
    • Brief code example showing both
  12. 7 Marks
    aDesign a class called as FATHER and MOTHER as base classes and class CHILD which is derived from both FATHER and MOTHER. FATHER has qualities $Q$, $Q_2$ and $Q_3$ and MOTHER has qualities $Q_1$, $Q_2$ and $Q_4$. Write a C++ program to display the qualities of CHILD due to inheritance.
    How to answer
    • Define class `FATHER` with member data/display methods for qualities $Q$, $Q_2$, $Q_3$
    • Define class `MOTHER` with member data/display methods for qualities $Q_1$, $Q_2$, $Q_4$
    • Derive class `CHILD` using multiple inheritance (`class CHILD : public FATHER, public MOTHER`)
    • Handle the ambiguity for the common quality $Q_2$ using scope resolution (e.g., `FATHER::Q_2` or `MOTHER::Q_2`)
    • `main()` function to instantiate `CHILD` and invoke display functions
  13. 7 Marks
    bWhat are the various stream classes and stream error? Explain them in brief. What are input and output streams? Give examples.
    How to answer
    • Overview of C++ stream class hierarchy (`ios`, `istream`, `ostream`, `iostream`, `ifstream`, `ofstream`)
    • Stream error state flags: `goodbit`, `eofbit`, `failbit`, `badbit`, and functions to check them (`good()`, `eof()`, `fail()`, `bad()`, `clear()`)
    • Explanation of Input streams (data flowing into program from source) and Output streams (data flowing out to destination)
    • Code examples using `cin`, `cout`, or file streams
  14. 7 Marks
    aWhat are the access modifiers? How many types of access modifiers are available in C++? Explain each of them and their role in implementing the data hiding in object oriented programming.
    How to answer
    • Definition of access specifiers/modifiers
    • Three types in C++: `private`, `protected`, `public`
    • Detailed explanation of visibility and accessibility for each modifier within class, derived class, and outside the class
    • Role in data hiding: Restricting direct access to sensitive data members and allowing controlled access via public getters/setters
  15. 7 Marks
    bExplain in detail about exception and how they handled? Define function template and class template.
    How to answer
    • Definition of exception and exception handling flow (try, throw, catch mechanism)
    • Syntax and code structure of structured exception handling
    • Definition of Function Template with syntax and example
    • Definition of Class Template with syntax and example
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