Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 5 subjective questions Dynamic Memory Management and Polymorphism

CSE202 — Object Oriented Programming 20 questions with model answers. Write yours first, then compare.

Read the notes Practice MCQs
  1. Question 1 of 20

    Define dynamic memory allocation. Explain the use of the new and delete operators in C++ with an example.

  2. Question 2 of 20

    Describe how arrays are dynamically allocated and deallocated in C++. Why must delete[] be used instead of delete for a dynamically allocated array?

  3. Question 3 of 20

    What is a dynamic constructor? Explain how a constructor can allocate memory dynamically, with a suitable C++ example.

  4. Question 4 of 20

    Explain allocation failure in C++. Compare the throwing and non-throwing forms of the new operator.

  5. Question 5 of 20

    Define a memory leak. Discuss its causes, effects, detection, and prevention in object-oriented C++ programs.

  6. Question 6 of 20

    Distinguish between compile-time polymorphism and run-time polymorphism in C++.

  7. Question 7 of 20

    Explain how function overloading and operator overloading implement compile-time polymorphism. State the important restrictions on overloading.

  8. Question 8 of 20

    What is a virtual function? Explain how virtual functions support run-time polymorphism in C++.

  9. Question 9 of 20

    Compare early binding and late binding. Illustrate both forms using C++ member-function calls.

  10. Question 10 of 20

    Why should a polymorphic base class have a virtual destructor? Explain the consequences of deleting a derived object through a base-class pointer when the base destructor is not virtual.

  11. Question 11 of 20

    Define a pure virtual function and an abstract class. Explain their syntax, purpose, and important properties.

  12. Question 12 of 20

    Differentiate between abstract classes and concrete classes. Give a suitable example showing how a concrete class completes an abstract interface.

  13. Question 13 of 20

    What is a self-referential class? Explain its structure, applications, and limitations with an example.

  14. Question 14 of 20

    Describe how dynamic memory management is used to create and destroy a singly linked list based on a self-referential class.

  15. Question 15 of 20

    Analyze the output and binding behavior of the following program. What changes if display() is not declared virtual?

    C++
    class Base {
    public:
        virtual void display() { cout << "Base"; }
    };
    
    class Derived : public Base {
    public:
        void display() override { cout << "Derived"; }
    };
    
    int main() {
        Derived object;
        Base* pointer = &object;
        pointer->display();
    }
  16. Question 16 of 20

    Explain function overriding in a polymorphic hierarchy. Discuss the roles of matching signatures, virtual, override, and final.

  17. Question 17 of 20

    A class owns a dynamically allocated array. Explain the problems caused by compiler-generated copying and describe how deep copying and proper resource management solve them.

  18. Question 18 of 20

    Design an abstract Shape hierarchy containing Circle and Rectangle. Demonstrate pure virtual functions, run-time polymorphism, and safe destruction.

  19. Question 19 of 20

    Explain dangling pointers, wild pointers, and double deletion. How can these dynamic-memory errors be avoided?

  20. Question 20 of 20

    Develop and explain a polymorphic employee-management design that dynamically stores different employee types. Your answer should address abstract classes, virtual functions, dynamic allocation, virtual destructors, allocation safety, and memory-leak prevention.

That's unit 5

Long answers stick best when they're tested again soon. Run the MCQs on this unit, then come back to the questions you found hardest.