Question 1: What is Object-Oriented Programming (OOP)?

BASICS

Object-Oriented Programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code: data in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods).

Key Concepts:

Question 2: Explain the Core Features of OOP

FREQUENTLY ASKED
Feature Description
Encapsulation Wrapping data and functions together into a single unit (class). Keeps data safe from outside interference and misuse.
Inheritance Reusing properties and behaviors of a parent class in a child class. Promotes code reusability.
Polymorphism Ability of a single function, object, or operator to behave differently depending on the context (e.g., Method Overloading).
Abstraction Hiding internal complex implementation details and showing only the essential features of the object to the user.

Important Note 💡

Ensure you can provide a real-world example for each feature (e.g., Encapsulation = Capsule/Pill, Inheritance = Parent/Child, Polymorphism = A person acting as an employee, father, and customer).

Question 3: Differentiate between POP and OOP

Procedure Oriented Programming (POP) focuses on functions, while Object-Oriented Programming (OOP) focuses on data.

POP (Procedure Oriented) OOP (Object-Oriented)
Divided into smaller parts called functions. Divided into smaller parts called objects.
Follows Top-Down approach. Follows Bottom-Up approach.
Data moves freely around the system. Data is hidden and cannot be accessed by external functions.
Does not have access specifiers. Has access specifiers like Public, Private, Protected.

Question 4: What is a UML Use Case Diagram?

HIGH PRIORITY

A Use Case Diagram represents the dynamic behavior of a system. It shows the interaction between the user (Actor) and the system (Use Cases).

+--------------------------------+
|           ATM SYSTEM           |
|                                |
| Customer ---> ( Withdraw Cash) |
| Customer ---> ( Check Balance) |
| Customer ---> ( Deposit Money) |
+--------------------------------+

Question 5: What is a UML Activity Diagram?

An Activity Diagram represents the workflow and execution process of a system. It models the logic from activity to activity, functioning similarly to a complex flowchart.

  [ Start ]
      |
      v
( Insert Card )
      |
      v
( Enter PIN ) ---> [ Invalid? ] ---> ( Reject & Eject )
      |
   [ Valid? ]
      |
      v
( Select Account )
      |
      v
  [ Finish ]

Question 6: What is a UML Class Diagram?

A Class Diagram maps out the static structure of a system by detailing its classes, attributes, operations, and the relationships among objects.

+------------------+
|     Student      |  <-- Class Name
+------------------+
| - name : string  |  <-- Attributes (Private)
| - id : int       |
+------------------+
| + study() : void |  <-- Methods (Public)
| + exams() : void |
+------------------+

Visibility Marks: + Public, - Private, # Protected.

Question 7: Explain the Basic Structure of a C++ Program

A standard C++ program includes header files, namespace declarations, and a main function where execution begins.

#include <iostream>
using namespace std;

int main() {
    cout << "Hello, Object-Oriented World!" << endl;
    return 0;
}

Question 8: Control Structures in C++

Control structures dictate the flow of the program logic. They are divided into decision-making and looping structures.

Question 9: Core C++ Practical Programs

PRACTICAL EXAM

For the practical portion of the exam, you must be comfortable writing these standard logic algorithms in C++:

1. Prime Number Identification

#include <iostream>
using namespace std;

int main() {
    int n, i, flag = 0;
    cout << "Enter a positive integer: ";
    cin >> n;
    if (n == 0 || n == 1) flag = 1;
    for (i = 2; i <= n / 2; ++i) {
        if (n % i == 0) {
            flag = 1;
            break;
        }
    }
    if (flag == 0)
        cout << n << " is a prime number.";
    else
        cout << n << " is not a prime number.";
    return 0;
}

2. Fibonacci Sequence Generator

#include <iostream>
using namespace std;

int main() {
    int n, t1 = 0, t2 = 1, nextTerm = 0;
    cout << "Enter the number of terms: ";
    cin >> n;
    cout << "Fibonacci Series: ";
    for (int i = 1; i <= n; ++i) {
        if(i == 1) { cout << t1 << " "; continue; }
        if(i == 2) { cout << t2 << " "; continue; }
        nextTerm = t1 + t2;
        t1 = t2;
        t2 = nextTerm;
        cout << nextTerm << " ";
    }
    return 0;
}

3. Armstrong Number Validation

#include <iostream>
using namespace std;

int main() {
    int num, originalNum, remainder, result = 0;
    cout << "Enter a three-digit integer: ";
    cin >> num;
    originalNum = num;
    while (originalNum != 0) {
        remainder = originalNum % 10;
        result += remainder * remainder * remainder;
        originalNum /= 10;
    }
    if (result == num)
        cout << num << " is an Armstrong number.";
    else
        cout << num << " is not an Armstrong number.";
    return 0;
}

Night Before Exam Tips 🌙

  • Revise the exact definitions of the 4 OOP features.
  • Practice writing the Prime and Armstrong logic programs on paper.
  • Practice drawing one complete Use Case Diagram for a standard system (like an ATM or Library Management).
  • Practice drawing one Class Diagram with proper visibility symbols (+, -, #).
  • Double-check your UML symbols (Arrows, Actors, Diamonds).
← Previous Unit Back to C++ Course Next Unit →