Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 17

Chapter -1

Introduction to object oriented


programming
Computer applications - Lorven public school, Chandapura
What is POP?

 POP is procedure oriented programming.


 In procedural programming, program is divided into small parts called functions.
 Procedural programming follows top down approach.
 Procedural programming does not have any proper way for hiding data so it is less secure.
 In procedural programming, function is more important than data.
 Examples: C, FORTRAN, Pascal, Basic etc.

Computer applications - Lorven public school, Chandapura


example
MAIN PROGRAM

Function 1 DATA f4

f2
f3

Computer applications - Lorven public school, Chandapura


Computer applications - Lorven public school, Chandapura
What is OOP?
 OOP is Object oriented programming.
 Its  a programming approach based on objects and classes.
 A class is an entity that determines how an object will behave and what the object will
contain. In other words, it is a blueprint or a set of instruction to build a specific type of
object.
 Objects contain data in the form of attributes and code in the form of methods.
 In object oriented programming, data is more important than function.
 Examples: C++, Java, Python, C# etc.

Computer applications - Lorven public school, Chandapura


classes and objects.
Class Object

Computer applications - Lorven public school, Chandapura


Computer applications - Lorven public school, Chandapura
Differences between POP and OOP

POP OOP

Gives importance to Procedure Gives importance to Data

Programs are divided into functions Programs are divided into objects

Follows top-down approach Follows bottom-up approach

Data is insecure Data is secured

Example: FORTRAN, C Example: C++,JAVA

Computer applications - Lorven public school, Chandapura


Object-Oriented Concepts
 Objects: It is considered as a variable of type class and an instance of a class.it is a real word
entity. which exists. That we can see.

 Example: car, tree, mobile

 Class: it is a blueprint of an object. It is a set of objects of similar type. A is the data type for
objects. It shows wat object has and how it behaves. It is called an object factory.
 Example: animal class. If animal is a class then dog, cat, cow etc.. Can be the objects of it.

Computer applications - Lorven public school, Chandapura


Abstraction

 Abstraction is nothing but a method of hiding background details and representing


essential features.
 It is an act of presenting only essential features.
 Example: coffee machine. We only dispensing buttons of coffee machine but we do not is
how coffee is prepared inside. All the process is hidden.
 ATM machine:
 Reading card details
 Verifying PIN
 Checking the account balance.
 Counting the cash

Computer applications - Lorven public school, Chandapura


Encapsulation

 The encapsulation is a method of packing the data and functions into a single unit.
 data can only be accessed by methods thus making the private fields and their
implementation hidden for outside classes. That’s why encapsulation is known as data
hiding.

Computer applications - Lorven public school, Chandapura


Example of encapsulation

 Coffee machine
 When we press button , machine grinds coffee beans into powder, heats some water and
pours it into coffee powder and then coffee decoction is ready to which it adds milk.
 But all these steps are encapsulated together to make coffee when a sing button is pressed.
 Here, coffee beans, water, milk are data that we don’t see directly.

Computer applications - Lorven public school, Chandapura


Inheritance

 Inheritance is a technique of acquiring features of objects from one class to the other class
objects. In other words, it helps in deriving a new class from the existing one.
 Example : animal class. It can have variable called colour and method called sound().
 If there is another class called Bird, even it may need to have same method because even
birds have sound.
 So bird class can use method of animal class by inheritance.
 The class that gets inherited is called base class, super class or parent class.
 The class that inherits base class is known as derived class, sub class or child class.

Computer applications - Lorven public school, Chandapura


example
 Inheritance is transitive.
 It means that all the attributes and behaviours of base class can be passed down from
parent class to child class.

Computer applications - Lorven public school, Chandapura


Polymorphism

 Polymorphism means taking many forms. Poly= many and morph=form


 It is the ability of a function to take multipole forms.
 Polymorphism provides a method of creating multiple forms of a function by using a
single function name.
 It is a mechanism by you can send same message to different objects and each object can
respond in a different way based on its class

Computer applications - Lorven public school, Chandapura


Computer applications - Lorven public school, Chandapura
Quick Revision
 POP
 OOP
 Classes
 Objects
 Principles of oops
 Abstraction
 Encapsulation
 Inheritance
 Polymorphism

Computer applications - Lorven public school, Chandapura

You might also like