1 Chapter Principal of Object Oriented Programming
1 Chapter Principal of Object Oriented Programming
Chapter -1
Principles of Object Oriented Programming
Prepared by
Md. Masum Billah
Lecturer, Dept. of CSE, CBST
Mobile: 01793200796
Q. What is Programming?
In procedure oriented program many important data items are placed as global
so that they can be accessed by all the functions. Each function may have its
own local data. Global data are more vulnerable to an unintended change by a
function.
Object: In OOP object is the representation of real life entity. Objects are
instances of classes. Each object contains data and functions to manipulate the
data. Following statements declare two objects of class Box −
Box Box1; // Declare Box1 of type Box
Box Box2; // Declare Box2 of type Box
Both of the objects Box1 and Box2 will have their own copy of data members.
Class: Class is the blue print for creating object. Objects are variables of the
type class. Once a class has been defined, we can create any number of objects
belonging to that class. A class definition starts with the keyword class followed
by the class name; and the class body, enclosed by a pair of curly braces. A
class Box {
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
};
Syntax:
class subclass_name : access_mode base_class_name
{
//body of subclass
};
Q. How does object oriented approach differ from object based approach?
Object-oriented approach
1. The object-oriented approach supports all the features of OOPs.
2. Object-oriented approach doesn't has an in-built object.
3. Object-oriented languages are C++, C#, Java etc.
Object-based approach
1. Object-based approach doesn't support all the features of OOPs like
Polymorphism and Inheritance.
2. Object-based approach has an in-built object like javascript has a window
object.
3. Object-based languages are Javascript, VB, etc.
Q. Write down the difference between Procedure Oriented Programming
and Object Oriented Programming.
Or, Write down the difference between
Prepared by Md. Masum Structured
Billah, Lecturer, Programming and
Dept of CSE, CBST
Object Oriented Programming.
Example The GUI of a mobile phone, After the icon is clicked, the
it has some icons to click end user has no idea
on, which on click perform regarding its implementation
the specific function. details