Introduction to object oriented
programming
1. What is a computer program?
A computer program is a set of instructions that a computer follows to perform a specific
task.
2. What is an algorithm?
An algorithm is a step-by-step method used to solve a problem or complete a task.
3. Building blocks of a program:
Variables – store data
Control structures – like if, loops
Functions/Methods – reusable blocks of code
Classes/Objects – used in OOP to group data and actions
4. Difference between POP and OOP:
POP: Focuses on functions.
OOP: Focuses on objects.
OOP models real-world behavior and offers better code reuse.
5. Real-world example of objects:
A car is an object. It has properties (color, speed) and actions (drive, brake). In OOP, objects
are like this – they hold data and methods.
6. What is a class?
A class is a blueprint for creating objects. It defines what properties and methods the object
will have.
7. Example of Object & Class:
Class: Car
Object: myCar created from class Car.
The class defines features; the object is the actual item using them.
8. What is programming paradigm?A programming paradigm is a method or style of
programming. It decides how code is written, structured, and organized. Examples include
POP (function-based) and OOP (object-based).
---
9. Preferred paradigm & reason:
OOP is preferred because it provides modularity, reusability, and models real-world systems
better.
10. Abstraction in daily life:
Using a phone is abstraction — we press buttons without knowing the internal wiring or code.
11. Hierarchical abstraction:
It means breaking a system into levels, from general to specific, like a company’s structure
from CEO to workers.
12. What is data abstraction?
It means hiding the complex details and showing only the essential features to the user.
13. Inheritance and code reuse:
Inheritance allows a new class to reuse features of an existing class, so we don't write the
same code again.
14. What is polymorphism?
Polymorphism means the same action behaves differently depending on the object. Example:
A print() method can print both text and numbers.
15. Two types of polymorphism:
Compile-time (Method Overloading)
Run-time (Method Overriding)
16. Example of polymorphism:
A person can be a student, friend, or player in different situations — same person, different
roles.
17. Encapsulation & modularity:
Encapsulation means keeping data and methods together in a class and hiding details.
Example: A mobile phone hides its internal hardware, giving only simple buttons to use.