0% found this document useful (0 votes)
60 views

About Object Oriented Programming

About Object Oriented Programming ICSE Class 10

Uploaded by

Rajesh Mahajan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

About Object Oriented Programming

About Object Oriented Programming ICSE Class 10

Uploaded by

Rajesh Mahajan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Chapter 1

Object Oriented Programming


Topics in this chapter

 Procedure Oriented Approach


 Object Oriented Programming
 Features of Object Oriented Programming
 Principals of Object Oriented Programming
 Class
 Encapsulation
 Data Abstraction
 Inheritance
 Dynamic Binding
Procedure Oriented Approach

 The procedure oriented approach allows the users to


develop their logic by applying a number of Main Program
functions.
 So we can say, it focuses more on function rather
than data.
 Examples of procedure Oriented Programming Function 1 Function 2
(OOP) are BASIC, COBOL, FORTRAN and C
 Function is collection of instructions grouped
together.
 It follows top-down approach (Executing instruction Function 3 Function 4
one by one from first to last)
Local Data and Global Data

Main Program
 When we deal with a program containing
many functions, important data items are String DOB = “8-march-1995”;
applied globally to be used by all the
functions, whereas, a function may contain
Function age
its own local data. Int age ;
 Variable used my multiple functions is
known as global data
 Variable used within function is known as Function Birthday
String message ;
local data.
 Local data is accessible within function only.
More about POP

Characteristics of POP Limitations of POP


 Emphasis is on function  As data values are global if you
 Functions share global data change the data value, you may
require to make necessary
 Data values can keep floating changes in all the functions
from one function to another.
 It is not suitable to solve more
 It uses top down approach of complex problems
programming
 Data are not secured
Object Oriented Programming (OOP)
 OOP is an approach to standardize the programs by creating a
partitioned memory are for data and function.
 Emphasis is on data rather than functions.
 OOP does not allow data to flow freely from one function to
another.
 Program is decomposed into a number of entities called objects.
 The data values of an object only within the function and can not
be accessed by external functions which makes data secured and
protected.
 This feature makes OOP a powerful tool for programming.
 Example of OOP are C++, JAVA, Eiffel
Features of Object Oriented Programming
 It gives stress on the data items rather than functions
 It makes the complete program simpler by dividing into
number of objects.
 The objects can be used to move values between
functions.
 The concept of data hiding enhances security in programs
 It is beneficial to solve complex problems.
Differences between POP and OOP
POP OOP
 The stress is put on function  The stress is put on data rather
rather than data than function
 It allows data to flow freely  The data is restricted to be used
throughout the program in a specific program area
 It doesn’t have any access  It has three different types of
specifier access specifiers e.g. public,
private, protected
  It follows bottom-up approach
It follows top-down approach
Basic elements of OOP / Principles of OOP
 Object
 Class
 Data Abstraction
 Encapsulation
 Data Hiding
 Inheritance
 Polymorphism
 Dynamic Binding
Object
 Object is known as instance of class (Example of a class)
 E.g. class ‘school’ may have object ‘Barnes’
 Object is unique entity, contains data and function
(Characteristics and Behaviour)
 There are two types of object Real World Object and
Software Object.
 Real World Object have Characteristics and Behaviours
 Software Object have Data and Functions

continue …..
Real World Object Software Object
Class : Car Class : Student
Characteristics : Data member :
Model no String name;
Company name int Roll_no;
No of seats String address;
Behaviour : Member functions :
To travel Admission( )
Pick and drop Examination( )
Message Passing

 Objects can interact with each other using member


functions

 An Object can pass information and receive as well.

 The process of exchanging information between two


Objects is known as Message Passing.
Class

 Class is a collection of data member and member function


 Class is also known as blue print of an object.
 Each Object of a class has to follow the protocol set by the
Class.
 If we create a class ‘fruits’ , apple, banana, pear, grapes are
referred as objects.
Creating object of a class

Syntax to create an object of a class :


<Class name > <Object name> = new <Class name> ( ) ;
Example : Object of class fruit
fruit apple = new fruit( );

Declaration Instantiation Initialization

continue…
Declaration : It uses class as data type along with an object

Instantiation : The keyword ‘new’ is used for allocating


space in the dynamic memory

Initialization : It is used for calling a constructor to initialize


attributes of an object.
Attributes of a class

Data member (Characteristics ) are known as Attributes of a


class

Examples of attributes :
String name;
int roll_no;
Class as an object factory

The term ‘factory’ is used along with a class for creating


similar kinds of objects.

We can create as many objects as needed in programming.

This is the reason why class is known as object factory.


Class is a user defined data type

 In class we can group multiple primitive data types like


int, float, char, String.
 User can select data type as per the need and order.
 As user decides the data types, it’s called as user defined
data types.
Difference between Class and Object
Class Object
 Class is a collection of  It is real and unique entity
data members and having some characteristics
member functions and behavior
 It is known as Object  Object is an instance of a
factory Class
 It is created using Class  It is created using ‘new’
keyword and compound keyword
statements
Data Encapsulation

 Encapsulation in Java is a process of


wrapping code and data together into a
single unit, for example, a capsule which
is mixed of several medicines

 We can create a fully encapsulated class


in Java by making all the data members of
the class private. 
Data Abstraction
 Abstraction refers to an act of representing
essential features without including
background details
 It is a process of hiding the implementation details
from the user. Only the functionality will be
provided to the user
 For example Math.min( ) – we know it will give
minimum out of two, but we don’t know the code
behind it
Inheritance
 Inheritance in Java is a mechanism in which one
object acquires all the properties and behaviors of a
parent object. It is an important part of OOP
 The idea behind inheritance in Java is that you can
create new classes that are built upon existing
classes
Types of Inheritance
.

Continue …
Types of Inheritance
Polymorphism

 Polymorphism is the ability of an object to take on many


forms.
 The best example of Polymorphism is function
overloading – where more then one function have same
name but there signatures are different.
 E.g. Void get_data(int x) { …. }
Void get_data(int x, int y) { ….. }
Binding
Connecting a method call
to the method body is
known as binding.
There are two types of
binding
Static Binding (also
known as Early Binding).
Dynamic Binding (also
known as Late Binding).

You might also like