Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

a. Define the following terms.

i. Class
A class is a blueprint or template for creating objects that defines the
properties and behaviors of those objects

ii. Object
An object is an instance of a class that has its own state and behavior. It
represents a unique entity that can interact with other objects and the
system as a whole.

iii. Encapsulation
Encapsulation is a mechanism in object-oriented programming that
bundles data and functions together into a single unit called a class.

iv. Inheritance
Inheritance is a mechanism in object-oriented programming that allows a
new class to be based on an existing class

v. Polymorphism
Polymorphism is a concept in object-oriented programming that allows
objects of different classes to be treated as if they were objects of the
same class. It enables objects to take on multiple forms or behaviors
depending on the context in which they are used.

b. OOP technology has gained importance in almost all areas of computing including real-time.
State five examples of applications developed using C++

a) GUI Based Applications. ...


b) Web Browsers. ...
c) Embedded Systems. ...
d) Banking Applications. ..
e) Operating Systems. C++ is a fast and strongly-typed programming language
which makes it an ideal choice for developing operating systems.

.
c. Write a program in C++ to print a welcome text in a separate line

#include<iostream>
Using namespace std;
Int main() {
Cout<< "Welcome to my program! "<<endl;
Return 0;
}

d. Explain various data types supported by all programming languages


 

Character
Integer
String
Boolean.
Floating-point

e. Write a C++ program to print your name five times using while loops
#include <iostream>
Using namespace std;
int main() {
int i =0;
while(i<5){
cout<<”Your Name””<<endl;
i++;
}
Return 0;
}

f. Differentiate between single-line comments and multi-line comments and give example
of each in your code
Single-line comments start with // and extend to the end of the line. They are
often used to explain the purpose or behavior of a single line of code. Here's an
example of a single-line comment in C++:
int Age = 5; // Initialize Age to 5
Multi-line comments start with /* and end with */. They can span multiple lines
and are often used to provide more detailed explanations or to temporarily
disable blocks of code. Here's an example of a multi-line comment in C++:
/*
This is a multi-line comment that spans
multiple lines and provides detailed
explanation of the code or its behavior.
*/

You might also like