SlideShare a Scribd company logo
SHARDA UNIVERSITY
“OOPs Using Java ”
Unit-I
Introduction
What is programming?
Programming is taking
A problem
Find the area of a rectangle
A set of data
length
width
A set of functions
area = length * width
Then,
Applying functions to data to solve the
problem
2
Programming Paradigm
 Procedural Programming Language (PPL)
 Object Oriented Programming (OOP)
3
Procedural Programming
The main program coordinates calls to procedures
and hands over appropriate data as parameters.
4
Procedural Concept
 Procedural Languages
 C, Pascal, Basic, Fortran
 Facilities to
 Pass arguments to functions
 Return values from functions
 For the rectangle problem, we develop a function
int compute_area (int l, int w){
return ( l * w );
}
5
Object-Oriented Concept
 Objects of the program interact by sending messages
to each other
6
Objects
An object is an encapsulation of both functions and data.
 Objects are an Abstraction
 represent real world entities
 Classes are data types that define shared common properties or
attributes
 Objects are instances of a class
 Objects have State
 have a value at a particular time
 Objects have Operations
 associated set of operations called methods that describe how to
carry out operations
 Objects have Messages
 request an object to carry out one of its operations by sending it a
message
 messages are the means by which we exchange data between
objects 7
Object as an Instance
 Instance refers to the copy of the object at a
particular time whereas object refers to the memory
address of the class.
 Object is instance of a Class.
 Instance means just creating a reference(copy) of an
object.
8
Cont…
 Class A {}
A obj1; //this is the object declaration without
occupy any memory.
A obj2 = new A(); //this is the object instance with
occupy memory for this.
also we can't create an instance for abstract class as
well as for interface.
9
Object Oriented Programming
 Object Oriented Programming (OOP) is a programming
paradigm that uses “Objects”
– data structures consisting of data fields and methods
together with their interactions
- to design applications and computer programs.
 An object is actually a discrete bundle of functions and
procedures, all related to a particular real-world concept.
 OOP focuses on data rather than processes, with programs
composed of self-sufficient modules (objects) each
containing all the information needed to manipulate its
own data structure.
10
Cont…
 In OOP, each object is capable of receiving messages,
processing data, and sending messages to other objects and
can be viewed as an independent ‘machine’ with a distinct
role or responsibility.
 The Simula67 programming language was the first to
introduce the concepts underlying OOP.
 Smalltalk was the first programming language to be called
“object-oriented”.
11
OOP vs. PPL
 OOL is concerned to develop an application based on real
time while PPL are more concerned with the processing of
procedures and functions.
 In OOL, more emphasis is given on data rather than
procedures, while the programs are divided into objects
and the data is encapsulated from the external
environment, providing more security to data which is not
applicable or rather possible in PPL.
 In OOL, the objects communicate with each other via
functions while there is no communication in PPL rather
it’s simply a passing values to the arguments to the
functions and/or procedures.
12
OOP vs. PPL
 OOL follows bottom up approach or program
execution while in PPL its top down approach.
 OOP languages :- JAVA, VB.Net, C#.Net
PPL Languages :- C, VB, Perl, Basic, Fortran
13
Design Methodology
 Functional decomposition (Top-Down)
 The whole system is characterized by a single function,
and then the function is decomposed into a set of
functions in a process of stepwise refinement.
 Functional composition (bottom-up)
 You can have different components of functions such as
that from a function library
 You can compose them into a module with a more
significant function.
14
OOL Languages
 Pure OO languages-
 Everything in them is treated consistently as an object,
from primitives such as characters and punctuation, all
the way up to whole classes, prototypes, blocks,
modules,etc.
 Designed specifically to facilitate, even enforce, OO
methods.
 Examples : Smalltalk, Eiffel, Ruby, JADE
 Languages designed mainly for OO
programming, but with some procedural
elements.
 Examples : C++ , JAVA, Python
15
OOL Languages
 Languages that are historically procedural languages,
but have been extended with some OO features.
 Examples : Fortran 2003, Perl, COBOL 2002, PHP.
16
CONCEPTS OF OOP
The concept of object oriented programming is categorized into the
following elements:
1. Class & Object.
2. Encapsulation.
3. Abstraction.
4. Data hiding.
5. Polymorphism.
6. Inheritance.
7. Dynamic Binding.
8. Message Passing.
17
CLASS & OBJECT
 A class is a collection of function code and data which forms
the basis of object oriented programming.
 A class is an Abstract Data type (ADT) i.e. the class definition
only provides the logical abstraction.
 The data and function defined within the class spring to life
only when a variable of type class is created.
 The variable of type class is called an objects which has a
physical existence and also known as an instance of a class.
 From one class several objects can be created.
 A class is termed as a basic unit of encapsulation.
 Each objects has similar set of data defined in the class and it
can use functions defined in the class for the manipulation of
data.
 For example we can create a class Car which have properties
like company model, year of manufacture, fuel type etc which
may have actions like accelerate ( ), brake( ) etc.
18
CLASS & OBJECT CONT.
 Objects are the basic entity in a C++ program.
 All objects are instances of a class. Depending upon type of class an
object may represented any thing like a person, mobile, chair, student,
employee, book, lecturer, speaker etc.
 The state of an object is determined by the data values they are having
at a particular instance.
 Objects occupy space in memory and all objects share same set of data
items which are defined when class is created.
 Two objects may communicate with each other through functions by
passing messages.
19
ENCAPSULATION
 Encapsulation is the mechanism that binds together function and data
in one compact form known as class.
 The data and function may be private or public.
 Private data/ function can only be accessed only with in the class.
 Public data/code can be accessed outside the class.
 The use of encapsulation hides complexity from the implementation.
 Linking of function code and data together gives rise to objects which
are variables of type class.
20
ABSTRACTION
 Abstraction is a mechnism to represent only essential features which are
of significance and hides the unimportant details.
 To make a good abstraction we require a sound knowledge of the problem
domain which we are going to implement using OOP principles.
 As an example of abstraction consider a class Vehicle. When we create the
vehicle class, we can decide what function code and data to put in the
class like vehicle name, no. of wheels, fuel type, vehicle type etc. and
functions like changing the gear, accelerating/ decelerating the vehicle. At
this time we are not interested how vehicle works like how acceleration,
changing gear take place. We are also not interested in making more parts
of vehicle to be part of the class like model number, vehicle color etc.
21
DATA HIDING
 Data hiding hides the data from external access by the user.
 In OOP language we have special keywords like private and protected
etc. which hides the data.
22
POLYMORPHISM
If we bi-furcate the words Polymorphism we get:
POLY Many
MORPHISM Form
1. Thus polymorphism means more than one form.
2. Thus polymorphism provides a way for an entity to behave in several
form.
3. In layman’s term a excellent example of polymorphism is Lord Krishna
in Hindu methodology.
4. From programmer point of view polymorphism means “ one interface
many methods”
5. Polymorphism is of two types
a) Compile time polymorphism.
b) Run Time polymorphism.
23
INHERITANCE
 Inheritance is the mechanism of deriving a new class from the earlier
existing class.
 The inheritance provides the basic idea of reusability in Object
Oriented Programming.
 The new class inherits the features of the old class.
CLASS – A (BASE CLASS)
CLASS –B (DERIVED CLASS)
Figure: Introduction of Inheritance
24
Inheritance example
DYNAMIC BINDING
 Binding means linking.
 It is linking of function definition to a function call.
 If linking of function call to function definition i.e. a place where
control has to be transferred is done at compile time, it is known
as static binding or early binding.
 When linking is delayed till run time or done during the
execution of the program then this type of linking is known as
dynamic binding.
 Which function will be called in response to a function call is find out
when program executes.
26
MESSAGE PASSING
 In C++ objects communicate each other by passing messages to each
other. A message contains the name of the member function and
arguments to pass. In message passing shown as follows:
object. Method (parameters);
 Message passing here means objects calling the method and passing
parameters. Message passing is nothing but calling the method of the
class and sending parameters. The method in turn executes in response
to a message.
27
CHARACTERISTICS OF OOP
 Programs are divided into classes and functions.
 Data is hidden and cannot be accessed by external
functions.
 Use of inheritance provides reusability of code.
 New functions and data items can be added easily.
 Data is given more importance than functions.
 Follows bottom-up approach.
 Data and functions are tied together in a single unit known
as class.
 Objects communicate each other by sending messages in
the form of function.
28
ADVANTAGES OF OOP
 Code reusability in terms of inheritance.
 Object oriented system can be easily upgraded from one
platform to another.
 Complex projects can be easily divided into small code
functions.
 The principle of abstraction and encapsulation enables a
programmer to build secure program.
 Software complexity decreases.
 Principle of data hiding helps programmer to design and
develop safe programs.
 Rapid development of software can be done in short span
of time.
 More than one instance of same class can exist together
without any interference.
29
OBJECT ORIENTED LANGUAGES
 Some of the most popular Object-Oriented programming
languages are:
1. C++
2. Java
3. Smalltalk
4. Eiffle
5. Ruby
6. Delphi
7. Charm++
8. Simula
30
OBJECT-BASED LANGUAGE
 The languages which only concerns with classes and
objects and do not have features like: inheritance,
polymorphism etc are known as object based language.
 In these types of languages we can create classes and
objects and can work with them .
 They are usually having a larger numbers of built-in objects
of various types.
 Some of the languages which are object-based are:
a) Java script
b) Visual Basic.
c) Delphi etc.
31

More Related Content

PPTX
Chapter 16 Dictionaries
Praveen M Jigajinni
 
PPTX
Python dictionary
Sagar Kumar
 
PDF
Python Programming - V. Sequences (List and Tuples) and Dictionaries
Ranel Padon
 
PPTX
Python dictionary
Mohammed Sikander
 
PPTX
Dictionaries
mansoura University
 
PPTX
Python dictionary
eman lotfy
 
PPTX
Chapter 10 data handling
Praveen M Jigajinni
 
Chapter 16 Dictionaries
Praveen M Jigajinni
 
Python dictionary
Sagar Kumar
 
Python Programming - V. Sequences (List and Tuples) and Dictionaries
Ranel Padon
 
Python dictionary
Mohammed Sikander
 
Dictionaries
mansoura University
 
Python dictionary
eman lotfy
 
Chapter 10 data handling
Praveen M Jigajinni
 

What's hot (20)

PPT
Object oriented programming using c++
Hoang Nguyen
 
PPT
11 Using classes and objects
maznabili
 
PDF
Function overloading
Prof. Dr. K. Adisesha
 
PPT
Python Dictionaries and Sets
Nicole Ryan
 
PDF
A COMPLETE FILE FOR C++
M Hussnain Ali
 
PPTX
Chapter 05 classes and objects
Praveen M Jigajinni
 
PDF
Data handling CBSE PYTHON CLASS 11
chinthala Vijaya Kumar
 
PPT
Object-Oriented Programming Using C++
Salahaddin University-Erbil
 
PPT
Object Oriented Programming Concepts using Java
Glenn Guden
 
PPT
Object and class
mohit tripathi
 
PDF
Classes and objects
Nilesh Dalvi
 
PPT
Chapter 7 - Defining Your Own Classes - Part II
Eduardo Bergavera
 
PPTX
Object Oriented Programming Using C++
Muhammad Waqas
 
PDF
Python Fundamentals Class 11
chinthala Vijaya Kumar
 
PDF
Farhaan Ahmed, BCA 2nd Year
dezyneecole
 
PPT
OOP Principles
Upender Upr
 
PDF
Wrapper classes
Ravi_Kant_Sahu
 
PPT
Lecture 2
Avinash Kapse
 
PPTX
classes and objects in C++
HalaiHansaika
 
PPT
4 Classes & Objects
Praveen M Jigajinni
 
Object oriented programming using c++
Hoang Nguyen
 
11 Using classes and objects
maznabili
 
Function overloading
Prof. Dr. K. Adisesha
 
Python Dictionaries and Sets
Nicole Ryan
 
A COMPLETE FILE FOR C++
M Hussnain Ali
 
Chapter 05 classes and objects
Praveen M Jigajinni
 
Data handling CBSE PYTHON CLASS 11
chinthala Vijaya Kumar
 
Object-Oriented Programming Using C++
Salahaddin University-Erbil
 
Object Oriented Programming Concepts using Java
Glenn Guden
 
Object and class
mohit tripathi
 
Classes and objects
Nilesh Dalvi
 
Chapter 7 - Defining Your Own Classes - Part II
Eduardo Bergavera
 
Object Oriented Programming Using C++
Muhammad Waqas
 
Python Fundamentals Class 11
chinthala Vijaya Kumar
 
Farhaan Ahmed, BCA 2nd Year
dezyneecole
 
OOP Principles
Upender Upr
 
Wrapper classes
Ravi_Kant_Sahu
 
Lecture 2
Avinash Kapse
 
classes and objects in C++
HalaiHansaika
 
4 Classes & Objects
Praveen M Jigajinni
 
Ad

Similar to 1 intro (20)

PDF
MCA NOTES.pdf
RAJASEKHARV10
 
PDF
M.c.a. (sem iv)- java programming
Praveen Chowdary
 
PPT
Object Oriented Language
dheva B
 
PPTX
Chapter1 introduction
Jeevan Acharya
 
DOCX
LECTURE NOTES ON Object Oriented Programming Using C++
SandeepAwasthi15
 
PPTX
fileE_1722655797_5000762_Unit-1OOPS.pptx
mashokacem
 
PDF
Java pdf
Vinod Panchatcharam
 
PPTX
basics of c++ object oriented programming l anguage
farooqabubakar4000
 
PPTX
introduction to object oriented programming
farooqabubakar4000
 
PDF
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
PPTX
Birasa 1
Niyitegekabilly
 
PPTX
JAVA PROGRAMMING
Niyitegekabilly
 
PPTX
POP vs OOP Introduction
Hashni T
 
PPTX
JAVA PROGRAMMINGD
Niyitegekabilly
 
PPTX
Chapter 04 object oriented programming
Praveen M Jigajinni
 
PDF
OOPS_Unit_1
Shipra Swati
 
PDF
CS3391 -OOP -UNIT – I NOTES FINAL.pdf
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
DOCX
Cs6301 programming and datastactures
K.s. Ramesh
 
PDF
Object Oriented Programming Lecture Notes
FellowBuddy.com
 
PPTX
Object Oriented Programming using c++ main four piller in this
vidhimangal05
 
MCA NOTES.pdf
RAJASEKHARV10
 
M.c.a. (sem iv)- java programming
Praveen Chowdary
 
Object Oriented Language
dheva B
 
Chapter1 introduction
Jeevan Acharya
 
LECTURE NOTES ON Object Oriented Programming Using C++
SandeepAwasthi15
 
fileE_1722655797_5000762_Unit-1OOPS.pptx
mashokacem
 
basics of c++ object oriented programming l anguage
farooqabubakar4000
 
introduction to object oriented programming
farooqabubakar4000
 
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
Birasa 1
Niyitegekabilly
 
JAVA PROGRAMMING
Niyitegekabilly
 
POP vs OOP Introduction
Hashni T
 
JAVA PROGRAMMINGD
Niyitegekabilly
 
Chapter 04 object oriented programming
Praveen M Jigajinni
 
OOPS_Unit_1
Shipra Swati
 
CS3391 -OOP -UNIT – I NOTES FINAL.pdf
AALIM MUHAMMED SALEGH COLLEGE OF ENGINEERING
 
Cs6301 programming and datastactures
K.s. Ramesh
 
Object Oriented Programming Lecture Notes
FellowBuddy.com
 
Object Oriented Programming using c++ main four piller in this
vidhimangal05
 
Ad

Recently uploaded (20)

PPTX
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PPTX
quantum computing transition from classical mechanics.pptx
gvlbcy
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PPTX
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PDF
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PPTX
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
PDF
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
PDF
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
PPTX
Online Cab Booking and Management System.pptx
diptipaneri80
 
PPT
1. SYSTEMS, ROLES, AND DEVELOPMENT METHODOLOGIES.ppt
zilow058
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
quantum computing transition from classical mechanics.pptx
gvlbcy
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
2025 Laurence Sigler - Advancing Decision Support. Content Management Ecommer...
Francisco Javier Mora Serrano
 
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
Online Cab Booking and Management System.pptx
diptipaneri80
 
1. SYSTEMS, ROLES, AND DEVELOPMENT METHODOLOGIES.ppt
zilow058
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 

1 intro

  • 1. SHARDA UNIVERSITY “OOPs Using Java ” Unit-I Introduction
  • 2. What is programming? Programming is taking A problem Find the area of a rectangle A set of data length width A set of functions area = length * width Then, Applying functions to data to solve the problem 2
  • 3. Programming Paradigm  Procedural Programming Language (PPL)  Object Oriented Programming (OOP) 3
  • 4. Procedural Programming The main program coordinates calls to procedures and hands over appropriate data as parameters. 4
  • 5. Procedural Concept  Procedural Languages  C, Pascal, Basic, Fortran  Facilities to  Pass arguments to functions  Return values from functions  For the rectangle problem, we develop a function int compute_area (int l, int w){ return ( l * w ); } 5
  • 6. Object-Oriented Concept  Objects of the program interact by sending messages to each other 6
  • 7. Objects An object is an encapsulation of both functions and data.  Objects are an Abstraction  represent real world entities  Classes are data types that define shared common properties or attributes  Objects are instances of a class  Objects have State  have a value at a particular time  Objects have Operations  associated set of operations called methods that describe how to carry out operations  Objects have Messages  request an object to carry out one of its operations by sending it a message  messages are the means by which we exchange data between objects 7
  • 8. Object as an Instance  Instance refers to the copy of the object at a particular time whereas object refers to the memory address of the class.  Object is instance of a Class.  Instance means just creating a reference(copy) of an object. 8
  • 9. Cont…  Class A {} A obj1; //this is the object declaration without occupy any memory. A obj2 = new A(); //this is the object instance with occupy memory for this. also we can't create an instance for abstract class as well as for interface. 9
  • 10. Object Oriented Programming  Object Oriented Programming (OOP) is a programming paradigm that uses “Objects” – data structures consisting of data fields and methods together with their interactions - to design applications and computer programs.  An object is actually a discrete bundle of functions and procedures, all related to a particular real-world concept.  OOP focuses on data rather than processes, with programs composed of self-sufficient modules (objects) each containing all the information needed to manipulate its own data structure. 10
  • 11. Cont…  In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects and can be viewed as an independent ‘machine’ with a distinct role or responsibility.  The Simula67 programming language was the first to introduce the concepts underlying OOP.  Smalltalk was the first programming language to be called “object-oriented”. 11
  • 12. OOP vs. PPL  OOL is concerned to develop an application based on real time while PPL are more concerned with the processing of procedures and functions.  In OOL, more emphasis is given on data rather than procedures, while the programs are divided into objects and the data is encapsulated from the external environment, providing more security to data which is not applicable or rather possible in PPL.  In OOL, the objects communicate with each other via functions while there is no communication in PPL rather it’s simply a passing values to the arguments to the functions and/or procedures. 12
  • 13. OOP vs. PPL  OOL follows bottom up approach or program execution while in PPL its top down approach.  OOP languages :- JAVA, VB.Net, C#.Net PPL Languages :- C, VB, Perl, Basic, Fortran 13
  • 14. Design Methodology  Functional decomposition (Top-Down)  The whole system is characterized by a single function, and then the function is decomposed into a set of functions in a process of stepwise refinement.  Functional composition (bottom-up)  You can have different components of functions such as that from a function library  You can compose them into a module with a more significant function. 14
  • 15. OOL Languages  Pure OO languages-  Everything in them is treated consistently as an object, from primitives such as characters and punctuation, all the way up to whole classes, prototypes, blocks, modules,etc.  Designed specifically to facilitate, even enforce, OO methods.  Examples : Smalltalk, Eiffel, Ruby, JADE  Languages designed mainly for OO programming, but with some procedural elements.  Examples : C++ , JAVA, Python 15
  • 16. OOL Languages  Languages that are historically procedural languages, but have been extended with some OO features.  Examples : Fortran 2003, Perl, COBOL 2002, PHP. 16
  • 17. CONCEPTS OF OOP The concept of object oriented programming is categorized into the following elements: 1. Class & Object. 2. Encapsulation. 3. Abstraction. 4. Data hiding. 5. Polymorphism. 6. Inheritance. 7. Dynamic Binding. 8. Message Passing. 17
  • 18. CLASS & OBJECT  A class is a collection of function code and data which forms the basis of object oriented programming.  A class is an Abstract Data type (ADT) i.e. the class definition only provides the logical abstraction.  The data and function defined within the class spring to life only when a variable of type class is created.  The variable of type class is called an objects which has a physical existence and also known as an instance of a class.  From one class several objects can be created.  A class is termed as a basic unit of encapsulation.  Each objects has similar set of data defined in the class and it can use functions defined in the class for the manipulation of data.  For example we can create a class Car which have properties like company model, year of manufacture, fuel type etc which may have actions like accelerate ( ), brake( ) etc. 18
  • 19. CLASS & OBJECT CONT.  Objects are the basic entity in a C++ program.  All objects are instances of a class. Depending upon type of class an object may represented any thing like a person, mobile, chair, student, employee, book, lecturer, speaker etc.  The state of an object is determined by the data values they are having at a particular instance.  Objects occupy space in memory and all objects share same set of data items which are defined when class is created.  Two objects may communicate with each other through functions by passing messages. 19
  • 20. ENCAPSULATION  Encapsulation is the mechanism that binds together function and data in one compact form known as class.  The data and function may be private or public.  Private data/ function can only be accessed only with in the class.  Public data/code can be accessed outside the class.  The use of encapsulation hides complexity from the implementation.  Linking of function code and data together gives rise to objects which are variables of type class. 20
  • 21. ABSTRACTION  Abstraction is a mechnism to represent only essential features which are of significance and hides the unimportant details.  To make a good abstraction we require a sound knowledge of the problem domain which we are going to implement using OOP principles.  As an example of abstraction consider a class Vehicle. When we create the vehicle class, we can decide what function code and data to put in the class like vehicle name, no. of wheels, fuel type, vehicle type etc. and functions like changing the gear, accelerating/ decelerating the vehicle. At this time we are not interested how vehicle works like how acceleration, changing gear take place. We are also not interested in making more parts of vehicle to be part of the class like model number, vehicle color etc. 21
  • 22. DATA HIDING  Data hiding hides the data from external access by the user.  In OOP language we have special keywords like private and protected etc. which hides the data. 22
  • 23. POLYMORPHISM If we bi-furcate the words Polymorphism we get: POLY Many MORPHISM Form 1. Thus polymorphism means more than one form. 2. Thus polymorphism provides a way for an entity to behave in several form. 3. In layman’s term a excellent example of polymorphism is Lord Krishna in Hindu methodology. 4. From programmer point of view polymorphism means “ one interface many methods” 5. Polymorphism is of two types a) Compile time polymorphism. b) Run Time polymorphism. 23
  • 24. INHERITANCE  Inheritance is the mechanism of deriving a new class from the earlier existing class.  The inheritance provides the basic idea of reusability in Object Oriented Programming.  The new class inherits the features of the old class. CLASS – A (BASE CLASS) CLASS –B (DERIVED CLASS) Figure: Introduction of Inheritance 24
  • 26. DYNAMIC BINDING  Binding means linking.  It is linking of function definition to a function call.  If linking of function call to function definition i.e. a place where control has to be transferred is done at compile time, it is known as static binding or early binding.  When linking is delayed till run time or done during the execution of the program then this type of linking is known as dynamic binding.  Which function will be called in response to a function call is find out when program executes. 26
  • 27. MESSAGE PASSING  In C++ objects communicate each other by passing messages to each other. A message contains the name of the member function and arguments to pass. In message passing shown as follows: object. Method (parameters);  Message passing here means objects calling the method and passing parameters. Message passing is nothing but calling the method of the class and sending parameters. The method in turn executes in response to a message. 27
  • 28. CHARACTERISTICS OF OOP  Programs are divided into classes and functions.  Data is hidden and cannot be accessed by external functions.  Use of inheritance provides reusability of code.  New functions and data items can be added easily.  Data is given more importance than functions.  Follows bottom-up approach.  Data and functions are tied together in a single unit known as class.  Objects communicate each other by sending messages in the form of function. 28
  • 29. ADVANTAGES OF OOP  Code reusability in terms of inheritance.  Object oriented system can be easily upgraded from one platform to another.  Complex projects can be easily divided into small code functions.  The principle of abstraction and encapsulation enables a programmer to build secure program.  Software complexity decreases.  Principle of data hiding helps programmer to design and develop safe programs.  Rapid development of software can be done in short span of time.  More than one instance of same class can exist together without any interference. 29
  • 30. OBJECT ORIENTED LANGUAGES  Some of the most popular Object-Oriented programming languages are: 1. C++ 2. Java 3. Smalltalk 4. Eiffle 5. Ruby 6. Delphi 7. Charm++ 8. Simula 30
  • 31. OBJECT-BASED LANGUAGE  The languages which only concerns with classes and objects and do not have features like: inheritance, polymorphism etc are known as object based language.  In these types of languages we can create classes and objects and can work with them .  They are usually having a larger numbers of built-in objects of various types.  Some of the languages which are object-based are: a) Java script b) Visual Basic. c) Delphi etc. 31