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

Object Oriented Programming Slides

Uploaded by

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

Object Oriented Programming Slides

Uploaded by

lokidddd0
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Object Oriented

Programming
Prepared by: Er. Gaurab Mishra ( HOD)
Computer Department ( K.M.C)
Programming Paradigm
• A programming paradigm is a way of programming to solve problems by
using some programming languages.
• It is a set of designs that define the program structure.
• A programming language uses a specific way of writing and organizing
program code.
• Programmers have to follow different styles for coding in different
programming languages.
Programming Paradigm
• There are generally 3 types of programming paradigms.
1. structured programming
2. Procedural programming
3. Object oriented programming
Structured programming
• Structured programming is a programming paradigm that uses structured
control flow ( without goto) to improve code clarity and quality.
• The paradigm uses the concept of block structures ( sequential, selection and
repetition ) control structures.
• The code will execute instruction by instruction(one after another)
• In serial form.
• Example: Basic, Pascal, Fortran
Procedural Programming
• A program in a procedural language is a list of instructions.
• The programmer creates the list of instructions and the computer carries them out.
• When program becomes larger, Procedural programming allows splitting those
instructions into procedures.
• It uses a linear or top-down approach.
• A set of procedures is uses in procedural programming languages.
• Functions, methods, subroutines used in this language are called procedures.
Procedural Programming
• IN procedural programming , a complex program is divided into many small,
functional and manageable modules.
• A module is a part of a program that performs some task.
• Therefore also known as modular programming.
• Eg: FORTAN, COBOL,ALGOL,BASIC,C AND PASCAL
Procedural Programming
Features:
1. Top-down approach
2. Pre-defined functions
3. Local and global variable scope
4.Parameter passing
5. Emphasis is given on procedures.
6. Programs are divided into procedures
Object oriented programming
• It allows the programmers to represent real world scenarios using objects.
• An object is any entity that has states and behaviors.
• States represent the attributes or data of an object.
• Whereas the methods represent the behaviors of objects.
• Objects interact with each other by passing messages.
Object oriented programming
• A class is a blueprint for creating an object.
• It is necessary to have class to create objects.
• Example: C++, Smalltalk, Ruby, Php, perl c#.net ,java
• Emphasis is on data rather than procedures.
• Programs are divided into objects.
• Follows bottom-up approach
• Access modifiers: Public, private,protected
Object oriented programming
• Feature of data hiding.
• Code Reusability
Class and objects
Class and objects
Class
• A class is simply a representation of a type of an object.
• It is a blueprint/plan that describes the detail of an object.
• A class is the design from which the individual objects are created.
• It describes the data and its behavior or functionality.
• A number of objects can be created with one class.
Objects
• It is a self-contained component which consists of methods and properties
to make a particular type of data useful.
• It can also be considered as a thing that can perform a set of activities.
• It bundles together the data and operations that are relevant to that kind of
data.
• Therefore objects are the instances of a class.
FEATURES OF OOP
• Abstraction
• Encapsulation
• Inheritance
• Polymorphism
Abstraction
• Abstraction refers to the act of representing essential features without
including the background details or explanations. since the classes use the
concept of data abstraction ,they are known as abstraction data type(ADT).
• Abstraction occurs when a programmer hides any irrelevant data about an
object or an instantiated class to reduce complexity and help users interact
with a program more efficiently
Abstraction
• For example, a class Car would be made up of an Engine, Gearbox, Steering
objects, and many more components.
• To build the Car class, one does not need to know how the different
components work internally, but only how to interface with them, i.e., send
messages to them, receive messages from them, and perhaps make the
different objects composing the class interact with each other.
Abstraction
• Humans manage complexity through abstraction. When you drive your car
you do not have to be concerned with the exact internal working of your
car(unless you are a mechanic).
• What you are concerned with is interacting with your car via its interfaces
like steering wheel, brake pedal, accelerator pedal etc.
Encapsulation( Data hiding)
• The process of binding the data and functions together into a single
enclosed class is known as encapsulation.
Encapsulation
• Encapsulation is a process of binding or wrapping the data and the codes that
operate on the data into a single entity. This keeps the data safe from outside
interface and misuse.
• It is a protective shield that prevents the data from being accessed by the code
outside this shield.
• The variables or data of a class is hidden from any other class and can be accessed
only through any member function of its own class in which it is declared.
• Encapsulation may also refer to a mechanism of restricting the direct access to
some components of an object, such that users cannot access state values for all of
the variables of a particular object

You might also like