OBJECT ORIENTED PROGRAMMING
Suman Saikan
Lecturer
Dept. of CSE
Dhaka International University
1
Sunday, June 25, 2023
DEFINITION OF OBJECT ORIENTED PROGRAMMING
Object-Oriented Programming or OOPs refers to
languages that use objects in programming. Object-
oriented programming aims to implement real-world
entities like inheritance, hiding, polymorphism, etc
in programming. The main aim of OOP is to bind
together the data and the functions that operate on
them so that no other part of the code can access
this data except that function.
2
WHAT ARE THE CONCEPTS OF OOP
 Class
 Objects
 Data Abstraction
 Encapsulation
 Inheritance
 Polymorphism
 Dynamic Binding
 Message Passing
Main Features of OOP
3
COMPARE BETWEEN ABSTRACTION AND ENCAPSULATION
4
DISTINGUISH BETWEEN STRUCTURE PROGRAMMING AND
OBJECT ORIENTED PROGRAMMING
5
DESCRIBE DIFFERENT KINDS OF LOOP WITH EXAMPLE
 Loops in programming are used to repeat a block of
code until the specified condition is met. A loop
statement allows programmers to execute a
statement or group of statements multiple times
without repetition of code.
6
For Loop
for loop in C programming is a repetition control
structure that allows programmers to write a loop
that will be executed a specific number of times.
for loop enables programmers to perform n
number of steps together in a single line.
Syntax:
for (initialize expression; test expression; increment)
{
// // body of for loop // ;
}
7
While Loop
While loop does not depend upon the number of
iterations. In for loop the number of iterations was
previously known to us but in the While loop, the
execution is terminated on the basis of the test
condition. If the test condition will become false then it
will break from the while loop else body will be
executed.
Syntax:
initialization_expression;
while (test_expression)
{
// body of the while loop update_expression;
}
8
do-while Loop
The do-while loop is similar to a while loop but the only difference lies in the do-
while loop test condition which is tested at the end of the body. In the do-while
loop, the loop body will execute at least once irrespective of the test condition.
Syntax:
initialization_expression;
do {
// body of do-while loop update_expression;
} while (test_expression);
9
ILLUSTRATE RECURSION IN STRUCTURE PROGRAMMING
Recursion is the technique of making a function call itself. This
technique provides a way to break complicated problems
down into simple problems which are easier to solve.
10
DIFFERENCE BETWEEN METHOD OVERLOADING AND
METHOD OVERRIDING
11
WRITE A C++ PROGRAM TO CALCULATE FACTORIAL OF
ANY INTEGER
12
DISTINGUISH BETWEEN POST INCREMENT AND
PRE INCREMENT
13
FIND ERROR AND SOLVE IT IN C++
Problem:
 #include <Iostream>
 int main()
 {
 int a=2;
 if(A>1)

 Cout<<"a is greater than 1")
 return 0;
 }
Solution:
 #include <iostream>
 int main()
 {
 int a=2;
 if(a>1)

 cout<<("a is greater than 1");
 return 0;
 }
14
EXPLAIN THE OUTPUT OF THIS C++ PROGRAM:
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i < 10; i++)
{
if (i == 4) {
continue;
}
cout << i << "n";
}
return 0;
} 15
WRITE THE OUTPUT OF THIS FOLLOWING CODE
#include<iostream>
using namespace std;
void main()
{
int y=10;
if(y++>9 && y++!=10 && y++>11)
cout<<y<<endl;
else
cout<<y<< endl;
}
16
17

Question Pattern in Object Oriented Programming

  • 1.
    OBJECT ORIENTED PROGRAMMING SumanSaikan Lecturer Dept. of CSE Dhaka International University 1 Sunday, June 25, 2023
  • 2.
    DEFINITION OF OBJECTORIENTED PROGRAMMING Object-Oriented Programming or OOPs refers to languages that use objects in programming. Object- oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism, etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function. 2
  • 3.
    WHAT ARE THECONCEPTS OF OOP  Class  Objects  Data Abstraction  Encapsulation  Inheritance  Polymorphism  Dynamic Binding  Message Passing Main Features of OOP 3
  • 4.
    COMPARE BETWEEN ABSTRACTIONAND ENCAPSULATION 4
  • 5.
    DISTINGUISH BETWEEN STRUCTUREPROGRAMMING AND OBJECT ORIENTED PROGRAMMING 5
  • 6.
    DESCRIBE DIFFERENT KINDSOF LOOP WITH EXAMPLE  Loops in programming are used to repeat a block of code until the specified condition is met. A loop statement allows programmers to execute a statement or group of statements multiple times without repetition of code. 6
  • 7.
    For Loop for loopin C programming is a repetition control structure that allows programmers to write a loop that will be executed a specific number of times. for loop enables programmers to perform n number of steps together in a single line. Syntax: for (initialize expression; test expression; increment) { // // body of for loop // ; } 7
  • 8.
    While Loop While loopdoes not depend upon the number of iterations. In for loop the number of iterations was previously known to us but in the While loop, the execution is terminated on the basis of the test condition. If the test condition will become false then it will break from the while loop else body will be executed. Syntax: initialization_expression; while (test_expression) { // body of the while loop update_expression; } 8
  • 9.
    do-while Loop The do-whileloop is similar to a while loop but the only difference lies in the do- while loop test condition which is tested at the end of the body. In the do-while loop, the loop body will execute at least once irrespective of the test condition. Syntax: initialization_expression; do { // body of do-while loop update_expression; } while (test_expression); 9
  • 10.
    ILLUSTRATE RECURSION INSTRUCTURE PROGRAMMING Recursion is the technique of making a function call itself. This technique provides a way to break complicated problems down into simple problems which are easier to solve. 10
  • 11.
    DIFFERENCE BETWEEN METHODOVERLOADING AND METHOD OVERRIDING 11
  • 12.
    WRITE A C++PROGRAM TO CALCULATE FACTORIAL OF ANY INTEGER 12
  • 13.
    DISTINGUISH BETWEEN POSTINCREMENT AND PRE INCREMENT 13
  • 14.
    FIND ERROR ANDSOLVE IT IN C++ Problem:  #include <Iostream>  int main()  {  int a=2;  if(A>1)   Cout<<"a is greater than 1")  return 0;  } Solution:  #include <iostream>  int main()  {  int a=2;  if(a>1)   cout<<("a is greater than 1");  return 0;  } 14
  • 15.
    EXPLAIN THE OUTPUTOF THIS C++ PROGRAM: #include <iostream> using namespace std; int main() { for (int i = 0; i < 10; i++) { if (i == 4) { continue; } cout << i << "n"; } return 0; } 15
  • 16.
    WRITE THE OUTPUTOF THIS FOLLOWING CODE #include<iostream> using namespace std; void main() { int y=10; if(y++>9 && y++!=10 && y++>11) cout<<y<<endl; else cout<<y<< endl; } 16
  • 17.