๐ŸŽ“

OOP2 Midterm Exam Prep

Object Oriented Programming 2 โ€” MSC1051
INHA University in Tashkent ยท Spring 2025
โœ… 50 MCQ ๐Ÿ–ฅ๏ธ 30 Output ๐Ÿ’ป 5 Tasks โšก C++ OOP
๐ŸŽ“ Created by Bekhruz  ยท  Good luck on your midterm! You've got this! ๐Ÿ’ช
๐Ÿ“‹ Exam Overview
MIDTERM EXAMINATION SPRING 2025 โ€” 60 Minutes, Maximum Marks: 30
60
Minutes
30
Total Marks
3
Sections
7
Weeks Covered

Section A โ€” Multiple Choice [5 Marks]

10 questions ร— 0.5 marks each. Topics: Classes, constructors, static members, copy constructor, operator overloading, composition, inheritance, access modifiers, multiple inheritance.

Section B โ€” Write the OUTPUT [15 Marks]

10 code snippets. You must predict the exact output. Topics: dynamic memory, static members, getters/setters, operator overloading, friend functions, composition, inheritance order, destructors.

Section C โ€” Programming Task [10 Marks]

Write a complete C++ class with attributes, constructors, getters/setters, display function, and additional methods. Private attributes accessed only via getters/setters.

Syllabus: Weeks 1โ€“7

  • Wk 1: Classes, objects, private/public, member functions, getters/setters, UML
  • Wk 2: Constructors (default, parameterized, copy), destructors, memberwise assignment
  • Wk 3: Composition, friend functions, this pointer, new/delete, static members, const
  • Wk 5: Operator overloading, deep/shallow copy, type conversion
  • Wk 6: Inheritance (single, multiple, multilevel, hierarchical, hybrid)
  • Wk 7: Polymorphism, function overloading vs overriding, virtual functions, dynamic binding
โœ… 50 Multiple Choice Questions
Tap an option to instantly check your answer. Covers all 7 weeks of OOP2.
Score:0 / 0
0 of 50 answered
๐Ÿ–ฅ๏ธ 30 Output Prediction Questions
Read each code snippet, predict the output in your head, then tap "Reveal Answer" to check.
๐Ÿ’ป Coding Tasks
Attempt each task yourself first, then tap "Show Sample Solution" to compare.
๐Ÿ’ก Quick Reference & Tips
Key syntax, tables, and exam traps to remember.

Class Syntax

class MyClass {
private:
    int value;
public:
    MyClass(int v) : value(v) {}   // constructor init list
    ~MyClass() {}                      // destructor
    int getValue() const { return value; }
    void setValue(int v) { value = v; }
};

Constructor Order in Inheritance

// Base constructor runs FIRST, then Derived
class Derived : public Base {
public:
    Derived(int x) : Base(x) { ... }
};
// Destructor: Derived first, then Base (reverse order)

Operator Overloading

Complex operator+(const Complex& other) {
    return Complex(real + other.real, imag + other.imag);
}
// Cannot overload: :: . .* sizeof ?: 

Static Members

class Counter {
public:
    static int count;   // belongs to CLASS, not objects
    Counter() { count++; }
};
int Counter::count = 0;  // define outside class
// Access: Counter::count  (no object needed)

Virtual Functions & Polymorphism

class Animal {
public:
    virtual void sound() { cout << "..."; }
};
class Dog : public Animal {
public:
    void sound() override { cout << "Woof"; }
};
Animal* ptr = new Dog();
ptr->sound(); // prints "Woof" โ€” dynamic binding

Access Specifier Table

SpecifierSame ClassDerived ClassOutside
privateโœ…โŒโŒ
protectedโœ…โœ…โŒ
publicโœ…โœ…โœ…

Key Exam Traps

  • Default access in class = private; in struct = public
  • If you define ANY constructor, compiler no longer provides default
  • Copy constructor param must be by reference (not by value)
  • Static member must be defined outside the class
  • Destructor order is REVERSE of constructor order
  • :: operator cannot be overloaded
  • friend function is NOT a member of the class
  • this pointer is not available in static member functions