4. Object Oriented Programming
Object oriented Programming is a modern programming method
to design a program using Classes and Objects
Objects
Real world entities that has their own
properties and behaviours such as
Book, Chair, Car, Pen, Table, etc.,
Class
A class is a blueprint or prototype from
which objects are created.
Major objective is to eliminate unfavorable features
encountered in Procedural approach
5. Procedural Vs Object Oriented ProgrammingProcedural Programming:
It is known as POP
Top Down Approach
It deals with Algorithms
Divided into functions
It needs very less memory
Doesn’s have Access Modifiers
Data can move freely from function to function in the system
It is Less Secure
Example: C, Fortran
Object Oriented Programming:
It is known as OOP
Bottom Up Approach
It deals with data
Divided into Objects
It needs more memory that of POP
Has Access Modifiers
Objects can move & communicate with each other through member functions
It is more Secure
Example: C++, JAVA, C#
6. Object Oriented Paradigm features
Emphasis is on data rather than procedure.
Programs are divided into what are known as objects.
Data structures are designed such that they characterize the
objects.
Methods that operate on the data of an object are tied
together in the data structure.
Data is hidden and cannot be accessed by external functions.
Objects may communicate with each other through methods.
New data and methods can be easily added whenever
necessary.
Follows bottom up approach in program design.
First, the individual base elements of a program are specified.
Then they are linked together to form larger sub sytems.
7. Applications of OOP
Real-time systems
Simulation and modeling
Object-oriented databases
Hypertext, hypermedia and expertext
AI and expert systems
Neural networks and parallel programming
Decision support and office automation systems
8. What is Java?
Java is a computing platform for application development
and an object-oriented,
Class-based and Concurrent programming language
It means many statements can be executed at the same time
instead of sequentially executing it.
Java can run on all platforms and free to access.
It is platform-independent
Java is Simple, Secure, Robust, Complete Object oriented
and Platform Independent High level Language
It is Portable and Multi-thread technology gives High
Performance.
It supports concurrency
means the code can be executed by multiple processes at
the same time.
9.
10.
11. OOPS Concepts
OBJECT ORIENTED PROGRAMMING (OOP) is a programming
concept that works on the principles of abstraction, encapsulation,
inheritance, and polymorphism
It allows users to create the objects that they want and then,
create methods to handle those objects.
The basic concept of OOPs is to create objects, re-use them
throughout the program, and manipulate these objects to get
results.
Object Oriented Programming popularly known as OOP, is used in a
modern programming language like Java
Object-oriented programming has several advantages over procedural
programming:
OOP is faster and easier to execute
OOP provides a clear structure for the programs
OOP helps to keep the Java code DRY "Don't Repeat Yourself", and
makes the code easier to maintain, modify and debug
OOP makes it possible to create full reusable applications with less
code and shorter development time
12. OOP simplifies software development and maintenance by
providing some concepts:
1. Object
2. Class
3. Inheritance
4. Polymorphism
5. Abstraction
6. Encapsulation
7. Dynamic Binding
8. Message Passing
13. Object:
An instance of a class is known as a Object.
Objects are the basic runtime entities in an object oriented
system.
Real world entity that has state and behavior .
For example, a chair, pen, table, keyboard, bike, etc. It can be
physical or logical.
An object contains an address and takes up
some space in memory.
Each object contains data and code to
manipulate the data.
Representing an object
14. Class
A class is a blueprint or prototype from which objects
are created.
Collection of objects.
It is a logical entity not the physical entity
The class is a group of similar entities.
For example, if a class is “Expensive Cars”
then objects like Mercedes, BMW, Toyota, etc.
Its properties(data) can be - price, model or speed etc.,
Methods - driving, reverse, braking etc.
Two instances of the class Student
15. Classes and objects are the two main aspects of object-
oriented programming.
So, a class is a template for objects, and an object is an
instance of a class.
When the individual objects are created, they inherit all
the variables and methods from the class.
16. Data Abstraction
Hiding internal details and showing functionality is known
as abstraction.
For example phone call, we don't know the internal
processing.
Abstraction refers to the act of representing essential
features without including the background details or
explanations.
Classes use the concept of abstraction and they are known
as abstract data types (ADT).
Classes are defined as a list of abstract attributes such as
size, weight and cost and methods that operate on these
attributes.
The technique of creating new data types that are well
suited to an application to be programmed is known as Data
Abstraction
In Java, we use abstract class and interface to achieve
abstraction.
17. Encapsulation
Encapsulation means “Combining”.
The wrapping up of data and methods into a
single unit (called class) is known as
Encapsulation.
For example - in school, a student cannot exist
without a class.
Capsule
18. Inheritance
Inheritance involves the creation of new classes (derived classes) from the
existing ones ( base classes ).
It is the process by which object of one class acquire the properties of
another class.
It supports the concept of hierarchical classification.
Example: The bird Robin is a part of the class flying bird which is
again a part of the bird
Provides code reusability.
Used to achieve runtime
Polymorphism
19. o Single Inheritance refers to deriving a class from a single
class.
o A class is derived from more than one base class is known as
Multiple inherence.
20. Polymorphism
It is a Greek term, “Poly” means “many” and “morph” means
“form”.
Polymorphism means the ability to take more than one form.
When one task is performed by different ways
An operation may exhibit different behaviors in different
instances.
The behavior depends upon
the types of data used in the
operation.
21. There are 2 types of Polymorphism:
1. Compile-time Polymorphism (Method overloading / Static)
2. Runtime Polymorphism (Method Overriding / Dynamic)
Method overloading
Having multiple methods with same name but with
different signature (number, type and order of
parameters).
Method Overriding
When a subclass contains a method with the same name
and signature as in the super class .
22. Dynamic Binding
Binding refers the linking of a procedure call to the code
to be executed in response to the call.
Dynamic binding means that the code associated with a
given procedure call is not known until the time of the
call at runtime.
It is associated with polymorphism & inheritance.
23. Message Passing
A Message for an object is a request for execution of a
procedure .
It is the process of invoking an operation on an object.
It involves the name of the object, the name of the
method (message) and the information to be sent.
For Example: Employee. salary (name);
Here, Employee is the object,
salary is the message and
name is the parameter that contains information.
25. Conclusion
In this lesson you learnt about
Object Oriented Programming
Procedural Vs Object Oriented Programming
Object Oriented Paradigm
Applications of OOP
What is Java?
OOPs Concepts