Programming Concepts & OOP - Complete Guide
Last Updated: August 19, 2026 | Marks Weightage: ~15 Marks | BPSC CS Teacher
Master Programming Concepts and Object-Oriented Programming with this comprehensive guide for the BPSC Computer Science Teacher exam.
1. Problem Solving - Algorithms & Flowcharts
📝 Algorithm
Step-by-step procedure to solve a problem
- Input → Process → Output
- Example: Algorithm to add two numbers
📊 Flowchart
Visual representation of an algorithm
- Oval: Start/End
- Rectangle: Process
- Diamond: Decision
- Parallelogram: Input/Output
2. Data Types & Variables
📊 Primitive
- int (integer)
- float (decimal)
- char (character)
- bool (boolean)
📊 Derived
- Array
- Pointer
- Structure
- Union
📊 User-defined
- Class
- Enum
- Typedef
3. Control Structures
⚡ Decision Making
- if: if (condition) { }
- if-else: if (condition) { } else { }
- switch: switch(variable) { case: }
- Ternary: condition ? true : false
🔄 Loops
- for: for(init; condition; increment) { }
- while: while(condition) { }
- do-while: do { } while(condition);
- break: Exit loop
- continue: Skip iteration
4. Functions
- Definition: return_type function_name(parameters) { body }
- Call by Value: Passes copy of data
- Call by Reference: Passes address (modifies original)
- Recursion: Function calls itself
5. Arrays & Strings
📊 Arrays
- 1D: int arr[5] = {1,2,3,4,5};
- 2D: int arr[3][4]; (3 rows, 4 columns)
- Indexing: Starts from 0
📝 Strings
- C: char str[] = "Hello"; (Null-terminated)
- C++: string str = "Hello"; (STL string)
- String functions: strlen(), strcpy(), strcat()
6. Pointers
Pointer: Variable that stores memory address
- Declaration: int *ptr;
- Address of: &var
- Dereference: *ptr (value at address)
- NULL Pointer: int *ptr = NULL;
7. Object-Oriented Programming (OOP) Principles
🔒 Encapsulation
Hiding internal details. Data is private, accessed via public methods.
🔄 Inheritance
Creating new classes from existing ones. Code reusability.
🎯 Polymorphism
Many forms. Function overloading, operator overloading, virtual functions.
📐 Abstraction
Showing only essential features. Abstract classes and interfaces.
8. Classes & Objects
🏷️ Class
class Student {
private:
string name;
int rollNo;
public:
// Constructor
Student(string n, int r) { name = n; rollNo = r; }
// Method
void display() { cout << name << " " << rollNo; }
};
🏷️ Object
Student s1("John", 101); // Object created
s1.display(); // Calling method
9. Exception Handling
Handling runtime errors gracefully.
- try: Contains code that might throw exception
- catch: Handles the exception
- throw: Throws an exception
try {
int age = -5;
if (age < 0) throw "Invalid age!";
}
catch (const char* msg) {
cout << msg;
}
10. Frequently Asked Questions
❓ What is the difference between Call by Value and Call by Reference?
Call by Value passes a copy; Call by Reference passes the actual address, allowing modifications.
❓ What are the 4 pillars of OOP?
Encapsulation, Inheritance, Polymorphism, Abstraction
❓ What is the difference between an Array and a Linked List?
Array has fixed size, contiguous memory. Linked List is dynamic, non-contiguous.
❓ What is a Constructor?
A special method called when an object is created. It initializes the object.