Introduction to object
oriented programming
Chapter -1
Computer applications - Lorven public school, Chandapura
Introduction
 A computer program is a collection of instructions that can be executed by a
computer to perform a specific task.
 A computer program is usually written by a computer programmer in a
programming language.
 Programming language is a computer language that is understood by the
computer.
 Program has a all the steps to perform some work/task.
Computer applications - Lorven public school, Chandapura
Example for a program: preparing mango
milk shake
 Step 1: wash the mango.
 Step 2: cut the mango.
 Step 3: remove the mango pulp.
 Step 4: add mango pulp, milk and sugar to blender
 Step 5: blend it
 Step 6: pour it to a glass.
Computer applications - Lorven public school, Chandapura
Computer languages
 Low level language
 This is a binary language
 Only this language is understood by computer machine.
 High level language
 This is used by programmers to write programs.
 POP –procedure oriented programming
 OOP- 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
Computer applications - Lorven public school, Chandapura
example
Computer applications - Lorven public school, Chandapura
DATA
Function 1
f2
f3
f4
MAIN PROGRAM
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.
Computer applications - Lorven public school, Chandapura
Class Object
Computer applications - Lorven public school, Chandapura
Features of OOP
 It gives importance to data
 Programs are divided into objects
 Objects are used as bridge to have communication from function to another.
 Concept of data hiding enhances the security
 It is highly beneficial to solve complex programs.
Computer applications - Lorven public school, Chandapura
 Class example
 {
 Int a,b;
 Void calculate();
 Void input();
 Void display();}
Computer applications - Lorven public school, Chandapura
O1 – a=3 and b=5
O2 - a=5 and b=9
O2.Calculate ()
{
O1.display()
}
Differences between POP and OOP
Computer applications - Lorven public school, Chandapura
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
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 see only dispensing buttons of coffee machine but
we do not see 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
Computer applications - Lorven public school, Chandapura
 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.
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
Computer applications - Lorven public school, Chandapura
 POP
 OOP
 Classes
 Objects
 Principles of oops
 Abstraction
 Encapsulation
 Inheritance
 Polymorphism
References
 Watch the video below
 https://www.youtube.com/watch?v=esflI8fDlRo
 For class work click link below
 https://www.happycompiler.com/oop/
 https://www.knowledgeboat.com/learn/class-9-icse-understanding-computer-
applications-bluej/solutions/lkjyx/object-oriented-programming-principles
Computer applications - Lorven public school, Chandapura
Computer applications - Lorven public school, Chandapura

1-1-Intoduction_to_OOP.pptx

  • 1.
    Introduction to object orientedprogramming Chapter -1 Computer applications - Lorven public school, Chandapura
  • 2.
    Introduction  A computerprogram is a collection of instructions that can be executed by a computer to perform a specific task.  A computer program is usually written by a computer programmer in a programming language.  Programming language is a computer language that is understood by the computer.  Program has a all the steps to perform some work/task. Computer applications - Lorven public school, Chandapura
  • 3.
    Example for aprogram: preparing mango milk shake  Step 1: wash the mango.  Step 2: cut the mango.  Step 3: remove the mango pulp.  Step 4: add mango pulp, milk and sugar to blender  Step 5: blend it  Step 6: pour it to a glass. Computer applications - Lorven public school, Chandapura
  • 4.
    Computer languages  Lowlevel language  This is a binary language  Only this language is understood by computer machine.  High level language  This is used by programmers to write programs.  POP –procedure oriented programming  OOP- object oriented programming Computer applications - Lorven public school, Chandapura
  • 5.
    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
  • 6.
    Computer applications -Lorven public school, Chandapura
  • 7.
    example Computer applications -Lorven public school, Chandapura DATA Function 1 f2 f3 f4 MAIN PROGRAM
  • 8.
    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
  • 9.
    classes and objects. Computerapplications - Lorven public school, Chandapura Class Object
  • 10.
    Computer applications -Lorven public school, Chandapura
  • 11.
    Features of OOP It gives importance to data  Programs are divided into objects  Objects are used as bridge to have communication from function to another.  Concept of data hiding enhances the security  It is highly beneficial to solve complex programs. Computer applications - Lorven public school, Chandapura
  • 12.
     Class example {  Int a,b;  Void calculate();  Void input();  Void display();} Computer applications - Lorven public school, Chandapura O1 – a=3 and b=5 O2 - a=5 and b=9 O2.Calculate () { O1.display() }
  • 13.
    Differences between POPand OOP Computer applications - Lorven public school, Chandapura 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
  • 14.
    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
  • 15.
    Abstraction  Abstraction isnothing but a method of hiding background details and representing essential features.  It is an act of presenting only essential features.  Example: coffee machine. We see only dispensing buttons of coffee machine but we do not see 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
  • 16.
    Encapsulation  The encapsulationis 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
  • 17.
    Example of encapsulation Computerapplications - Lorven public school, Chandapura  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.
  • 18.
    Inheritance  Inheritance isa 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
  • 19.
    example  Inheritance istransitive.  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
  • 20.
    Polymorphism  Polymorphism meanstaking 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
  • 21.
    Computer applications -Lorven public school, Chandapura
  • 22.
    Quick Revision Computer applications- Lorven public school, Chandapura  POP  OOP  Classes  Objects  Principles of oops  Abstraction  Encapsulation  Inheritance  Polymorphism
  • 23.
    References  Watch thevideo below  https://www.youtube.com/watch?v=esflI8fDlRo  For class work click link below  https://www.happycompiler.com/oop/  https://www.knowledgeboat.com/learn/class-9-icse-understanding-computer- applications-bluej/solutions/lkjyx/object-oriented-programming-principles Computer applications - Lorven public school, Chandapura
  • 24.
    Computer applications -Lorven public school, Chandapura