Cpp qb u 1 and 2

C ++
1. Define Object Oriented Programming (OOP).
Object Oriented Programming is an approach that provides a way of modularizing
programs by creating partitioned memory area for both data and functions that can be used
as templates for creating copies of such modules on demand.
2. List out the basic concepts of Object Oriented Programming.
• Objects
• Classes
• Data Abstraction and Encapsulation
• Inheritance
• Polymorphism
• Dynamic Binding
• Message Passing
3. Define Objects.
Objects are the basic run time entities in an object oriented system. They are instance of a
class. They may represent a person, a place etc that a program has to handle. They may
also represent user-defined data. They contain both data and code.
4. Define Class.
Class is a collection of objects of similar data types. Class is a user-defined data type. The
entire set of data and code of an object can be made a user defined type through a class.
5. Define Encapsulation and Data Hiding.
The wrapping up of data and functions into a single unit is known as data encapsulation.
Here the data is not accessible to the outside world. The insulation of data from direct
access by the program is called data hiding or information hiding.
6. Define Data Abstraction.
Abstraction refers to the act of representing the essential features without including the
background details or explanations.
7. Define data members and member functions.
The attributes in the objects are known as data members because they hold the information.
The functions that operate on these data are known as methods or member functions.
8. State Inheritance.
Inheritance is the process by which objects of one class acquire the properties of objects of
another class. It supports the concept of hierarchical classification and provides the idea of
reusability. The class which is inherited is known as the base or super class and class which
is newly derived is known as the derived or sub class.
9. State Polymorphism.
Polymorphism is an important concept of OOPs. Polymorphism means one name, multiple
forms. It is the ability of a function or operator to take more than one form at different
10. List and define the two types of Polymorphism.
• Operator Overloading – The process of making an operator to exhibit different
behaviors at different instances.
• Function Overloading – Using a single function name to perform different types of
tasks. The same function name can be used to handle different number and different types
of arguments.
11. State Dynamic Binding.
Binding refers to the linking of procedure call to the code to be executed in response to
the call. Dynamic Binding or Late Binding means that the code associated with a given
procedure call is known only at the run-time.
12. Define Message Passing.
Objects communicate between each other by sending and receiving information known as
messages. A message to an object is a request for execution of a procedure. Message
passing involves specifying the name of the object, the name of the function and the
information to be sent.
13. List out some of the benefits of OOP.(any 2 which u remember)
• Eliminate redundant code
• Saves development time and leads to higher productivity
• Helps to build secure programs
• Easy to partition work
• Small programs can be easily upgraded to large programs
• Software complexity can easily be managed
14. Define C++.
C++ is an object oriented programming language developed by Bjarne Stroustrup. It is a
super set of C. Initially it was known as “C with Classes”. It is a versatile language for
handling large programs.
15. What are the input and output operators used in C++?
The identifier cin is used for input operation. The input operator used is >>, which is known
as the extraction or get from operator. The syntax is, cin >> n1; The identifier cout is used
for output operation. The input operator used is
// main() is where program execution begins.
int main() {
cout is needed.
● The line using namespace std; tells the compiler to use the std namespace. Namespaces are a
relatively recent addition to C++.
● The next line ‘// main() is where program execution begins.’ is a single-line comment available
in C++. Single-line comments begin with // and stop at the end of the line.
● The line int main() is the main function where program execution begins.
● The next line cout ,>=,!=
Logical Operators
&&, ||,!
Bitwise Operators
Bitwise operator works on bits and perform bit-by-bit operation. &, |, and ^
Assignment Operators
There are following assignment operators supported by C++ language −
Misc Operators
Scope resolution
sizeof, ? :,
member access operator
→, .*pointer operator
24. Explain control structures in c++?
1. loops : for, while, do while
2. conditional / decision making statements : if, if else, nested if, switch
3. Branching statements : break, goto, continue
C++ programming language provides the following type of loops to handle
looping requirements.
Loop Type & Description
while loop
Repeats a statement or group of statements while a given
condition is true. It tests the condition before executing the
loop body.
for loop
Execute a sequence of statements multiple times and
abbreviates the code that manages the loop variable.
do…while loop
Like a ‘while’ statement, except that it tests the condition at
the end of the loop body.
nested loops
You can use one or more loop inside any another ‘while’,
‘for’ or ‘do..while’ loop.
Loop Control Statements
Loop control statements change execution from its normal sequence. When
execution leaves a scope, all automatic objects that were created in that
scope are destroyed.
C++ supports the following control statements.
Control Statement & Description
break statement
Terminates the loop or switch statement and transfers
execution to the statement immediately following the loop
or switch.
continue statement
Causes the loop to skip the remainder of its body and
immediately retest its condition prior to reiterating.
goto statement
Transfers control to the labeled statement. Though it is not
advised to use goto statement in your program.
The Infinite Loop
A loop becomes infinite loop if a condition never becomes false. The for loop
is traditionally used for this purpose. Since none of the three expressions that
form the ‘for’ loop are required, you can make an endless loop by leaving the
conditional expression empty.
using namespace std;
int main () {
for( ; ; ) {
printf(“This loop will run forever.\n”);
return 0;
When the conditional expression is absent, it is assumed to be true. You may
have an initialization and increment expression, but C++ programmers more
commonly use the ‘for (;;)’ construct to signify an infinite loop.
C++ programming language provides following types of decision making
Statement & Description
if statement
An ‘if’ statement consists of a boolean expression followed
by one or more statements.
if…else statement
An ‘if’ statement can be followed by an optional ‘else’
statement, which executes when the boolean expression is
switch statement
A ‘switch’ statement allows a variable to be tested for
equality against a list of values.
nested if statements
You can use one ‘if’ or ‘else if’ statement inside another ‘if’
or ‘else if’ statement(s).
nested switch statements
You can use one ‘switch’ statement inside another ‘switch’
25. Explain Operator overloading in c++?
Operator Overloading in C++
You can redefine or overload most of the built-in operators available in C++.
Thus, a programmer can use operators with user-defined types as well.
Overloaded operators are functions with special names: the keyword
“operator” followed by the symbol for the operator being defined. Like any
other function, an overloaded operator has a return type and a parameter
Box operator+(const Box&);
declares the addition operator that can be used to add two Box objects and
returns final Box object. Most overloaded operators may be defined as ordinary nonmember functions or as class member functions. In case we define above function as
non-member function of a class then we would have to pass two arguments for each
operand as follows −
Box operator+(const Box&, const Box&);
Following is the example to show the concept of operator over loading using
a member function. Here an object is passed as an argument whose
properties will be accessed using this object, the object which will call this
operator can be accessed using this operator as explained below −
using namespace std;
class Box {
double getVolume(void) {
return length * breadth * height;
void setLength( double len ) {
length = len;
void setBreadth( double bre ) {
breadth = bre;
void setHeight( double hei ) {
height = hei;
// Overload + operator to add two Box objects.
Box operator+(const Box& b) {
Box box;
box.length = this->length + b.length;
box.breadth = this->breadth + b.breadth;
box.height = this->height + b.height;
return box;
double length;
// Length of a box
double breadth;
// Breadth of a box
double height;
// Height of a box
// Main function for the program
int main() {
Box Box1;
// Declare Box1 of type Box
Box Box2;
// Declare Box2 of type Box
Box Box3;
// Declare Box3 of type Box
double volume = 0.0;
// Store the volume of a box here
// box 1 specification
// box 2 specification
// volume of box 1
volume = Box1.getVolume();

new []
delete []
Following is the list of operators, which can not be overloaded −
String1 + string2=”welcome” which is not a built in but overloaded operation.

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with StudyAcademia.com
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Customer reviews in total
Current satisfaction rate
3 pages
Average paper length
Customers referred by a friend
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat