ADDISS COLLEGE
NAME= Mikiyas Halegebreal Taye
DEPARTMENT= Civil Engineering
CODE= 060/2017
COURSE= Computer Programming
COURSE INSTRUCTOR= TBA
DATE OF SUBMISSION= April 06 /2026G.C
1. WHAT IS THE FULL FORM OF OOPS?
The full form of OOPS is Object-Oriented Programming System.
Object-Oriented Programming System is a programming methodology that
organizes software programs around objects, classes, and interactions between
objects rather than only using functions and procedures. The main idea behind OOPS
is to model a program in a way that resembles real-world systems. Before the
introduction of object-oriented programming, most programs were written using
procedural programming, where the focus was mainly on writing sequences of
instructions. However, as software systems became larger and more complex,
procedural programming became difficult to manage. OOPS was introduced to solve
these problems by organizing code into independent units called objects. In objectoriented programming, an object represents a real-world entity such as a student, a
bank account, a vehicle, or a building. Each object contains both data (attributes) and
operations (methods) that operate on that data. For example, consider a Bank
Account system. In OOPS, each bank account can be represented as an object that
contains:
Attributes:
account number
account holder name
account balance
Operations:
deposit money
withdraw money
check balance
By organizing programs in this way, OOPS provides several advantages:
• Better code organization
• Easier maintenance of large programs
• Reusability of code
• Increased program security
• Better modeling of real-world problems
The four fundamental principles of OOPS are:
1. Encapsulation
2. Abstraction
3. Inheritance
4. Polymorphism
Languages such as C++, Java, Python, and C# use object-oriented programming to
build complex software systems such as operating systems, engineering simulations,
and enterprise applications.
2. WHAT IS A CLASS?
A class can be described as a logical blueprint or design template used to create
objects in object-oriented programming. It defines the structure and behavior that
the objects created from it will possess.
A class usually contains two main components:
1. Data members (variables) – These represent the properties or characteristics
of an object.
2. Member functions (methods) – These represent the actions or behaviors that
the object can perform.
To understand the concept of a class more clearly, imagine the design of a house.
The architectural plan describes the number of rooms, windows, doors, and layout.
However, the plan itself is not a house. It only defines how a house should be
constructed. In programming, the class is similar to this architectural plan, and the
objects are the actual houses built from the plan.
Example:
Suppose we create a class called Student.
The class may define:
Attributes:
student ID
name
Functions:
register course
display information
calculate grade
Example in C++:
class Student {
public:
string name;
int age;
void displayInfo() {
cout << "Student Name: " << name;
}
};
Here, the class defines what a student object will contain and what it can do. Classes
help programmers build structured and reusable programs, especially when dealing
with large systems such as university management systems, banking applications, or
engineering databases. In civil engineering software, a class called "Building" could
be created. The class might contain attributes such as height, number of floors, and
material type. It may also include functions such as calculate Load or estimate Cost.
Each specific building project can then be represented as an object created from the
Building class.
3. WHAT IS AN OBJECT?
An object is a real instance created from a class. While a class defines the structure
of data and behavior, an object represents the actual entity that exists in memory
and performs operations. In simpler terms:
Class = Blueprint
Object = Actual product built using that blueprint
For example, if we define a class called Car, different cars such as:
Toyota Corolla
Hyundai Elantra
Honda Civic
can be considered objects of that class.
4. WHAT IS A FUNCTION IN C++?
A function in C++ is a reusable block of code designed to perform a specific task.
Instead of writing the same instructions multiple times, programmers define a
function once and then call it whenever needed. Functions play an important role in
programming because they help divide a large program into smaller manageable
parts. This approach is known as modular programming.
A function generally includes:
• Function name
• Return type
• Parameters (optional)
• Body of instructions
Example:
int multiply(int a, int b) {
return a * b;
}
In this example:
The function name is multiply
It receives two parameters: a and b
It returns the product of the two numbers
Functions can be classified into several types:
1. Functions with no parameters and no return value
2. Functions with parameters but no return value
3. Functions with parameters and return values
4. Recursive functions (functions that call themselves)
5. WHAT IS THE ROLE OF PROTECTED ACCESS
MODIFIER?
In object-oriented programming, access modifiers control how data members and
functions can be accessed from different parts of a program. The protected access
modifier allows class members to be accessed:
• within the same class
• within derived (child) classes through inheritance
However, protected members cannot be accessed directly by objects outside the
class hierarchy.
Example:
class Employee {
protected:
int salary;
};
If another class inherits from Employee, it can use the salary variable.
Example:
class Manager : public Employee {
public:
void setSalary(int s) {
salary = s;
}
};
In this example, the derived class Manager can access the protected variable salary.
The protected modifier is useful when programmers want to allow controlled
inheritance while maintaining data protection.
6. WHAT IS ENCAPSULATION?
Encapsulation refers to the technique of combining data and the methods that
operate on that data into a single unit, usually a class. The main purpose of
encapsulation is data protection and information hiding. Instead of allowing direct
access to variables, the program restricts access using functions. For example,
consider a bank account system. If the balance variable were public, any part of the
program could modify it incorrectly. Encapsulation prevents this by making the
variable private and controlling access through methods.
Example:
class BankAccount {
private:
double balance;
public:
void deposit(double amount) {
balance += amount;
}
double getBalance() {
return balance;
}
};
Encapsulation ensures that:
• data cannot be modified incorrectly
• the internal logic of a class remains hidden
• the system becomes more secure and maintainable
This principle is widely used in software systems such as banking applications,
medical databases, and financial systems where data security is critical.
7. What is Abstraction?
Abstraction is the concept of showing only the necessary information to the user
while hiding the complex implementation details. In programming, abstraction
allows developers to focus on what an object does rather than how it works
internally. A simple real-world example is a mobile phone. When you use a phone to
make a call, you simply press a button. You do not need to understand the complex
network communication, signal processing, or hardware operations happening inside
the device. Similarly, in programming, abstraction hides complexity and provides a
simplified interface.
Example:
class Vehicle {
public:
virtual void start() = 0;
};
Here, the class only defines the function start() without specifying how it works.
Different derived classes such as Car, Bus, or Motorcycle can implement the start
function differently.
Abstraction improves:
• program simplicity
• code readability
• system scalability
8. WHAT IS INHERITANCE?
Inheritance is an important concept in object-oriented programming that allows a
class to acquire properties and behaviors from another class. The class that provides
the properties is called the base class, while the class that inherits them is called the
derived class. For example, suppose we have a class called Person with attributes:
name
age
A new class called Student can inherit these attributes and add additional ones such
as:
student ID
department
Example:
class Person {
public:
string name;
};
class Student : public Person {
public:
int studentID;
};
In this example, the Student class automatically inherits the name attribute from the
Person class.
Inheritance promotes:
• code reuse
• hierarchical classification
• easier program extension
9. WHAT IS THE DIFFERENCE BETWEEN C++
AND JAVA?
Although C++ and Java are both object-oriented programming languages, they were
designed with different goals and system architectures in mind. One of the main
differences is platform dependency. C++ programs are compiled directly into
machine code and usually run on a specific operating system. Java programs are
compiled into byte code, which can run on any system that has the Java Virtual
Machine (JVM). This makes Java more portable. Another important difference is
memory management.
In C++, programmers must manually allocate and release memory using pointers and
commands such as new and delete. In Java, memory management is handled
automatically using a mechanism called garbage collection, which removes unused
objects from memory. C++ also supports pointer arithmetic, which allows direct
memory manipulation. Java intentionally removed pointers to increase security and
reduce programming errors. Furthermore, C++ supports multiple inheritances,
meaning a class can inherit from more than one parent class. Java does not allow
multiple inheritances with classes, although it provides similar functionality using
interfaces.
10. WHAT IS A BLOCK SCOPE VARIABLE IN
C++?
A block scope variable is a variable that is declared inside a specific block of code
and can only be accessed within that block.
A block is typically defined by a pair of curly braces { }.
Block scope is commonly found in:
• loops
• conditional statements
• functions
Example:
int main() {
for(int i = 0; i < 5; i++) {
int square = i * i;
cout << square << endl;
}
}
In this example:
The variable square is created inside the for loop block.
It exists only during each iteration of the loop.
It cannot be accessed outside the loop.
Block scope is important because it:
• prevents accidental modification of variables
• improves memory efficiency
• avoids naming conflicts in large programs
Modern C++ programming encourages the use of smaller scopes because it improves
code clarity and safety.
REFERENCES
1. Bjarne Stroustrup. The C++ Programming Language.
2. Herbert Schildt. C++: The Complete Reference.
3. Object-Oriented Programming concepts – programming textbooks and lecture
notes.
4. From internet resources like Chatgpt , Google , Wikipidia
THANK YOU!
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )