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

Basic Knowledge About OOP

Uploaded by

Vaibhav More
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Basic Knowledge About OOP

Uploaded by

Vaibhav More
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

UNIT-01

Foundations of Object Oriented Programming


⚫ Sachin D. Shelke
Foundations of Object Oriented
Programming
⚫ Introduction to OOP: Software Evolution, Introduction to Procedural,
Modular, Object-Oriented and Generic Programming Techniques, Limitations
of Procedural Programming, Need of Object Oriented Programming

⚫ Fundamentals of Object Oriented Programming: Objects, Classes, Data


Members, Methods, Messages, Data Encapsulation, Data Abstraction and
Information Hiding, Inheritance, Polymorphism, Static & Dynamic Binding,
Message Passing

⚫ Case Study: Model a real world scenario ( vehicle class, fruit class, student
management in university etc.) using Object Oriented Paradigm
Software Evolution
⚫ Machine Language [ 1, 0 ]

⚫ Assembly Language

⚫ Procedure-Oriented

⚫ Object-Oriented Programming
Introduction to Procedural
Introduction to Procedural
Introduction to Procedural [
characteristics ]
⚫ Emphasis on doing the things (algorithms).

⚫ Large programs are divided into smaller programs known as functions.

⚫ Most of the functions share global data.

⚫ Employs top-town approach in program design.


Limitations of Procedural
Programming
⚫ Procedure codes are very difficult to maintain, if the code is larger.

⚫ Data is exposed to whole program, so security is low for data ( global ).

⚫ It is difficult to relate with real world problems.

⚫ It is tough to updating programs.


Modular Programming
Modular Programming
⚫ Programming concept where source code is divided into independent
building blocks, each containing all the parts needed to execute a single
aspect of the functionality.

⚫ Modularity is about making building blocks, and even building blocks made
up of smaller building blocks.
Advantages of Modular
Programming
⚫ Code is easy to read

⚫ Code is easy to test

⚫ Reusability

⚫ Single Source for faster fixes

⚫ Easier Refactoring
Limitations of Modular
Programming

⚫ Code Size
Object-Oriented Programming
Object-Oriented Programming [
characteristics ]

⚫ Emphasis on data rather than procedures.

⚫ Programs are divided into what are known as objects.

⚫ Functions that operated on the data of an object are tied together in the data
structure.

⚫ Data is hidden and cannot be accessed by external functions.

⚫ Follows bottom-up approach in program design.


Advantages of OOP
⚫ It is easy to partition the work on project based on object.

⚫ The principle of Data Hiding helps programmar to build secure programs.

⚫ It is easy to relate with real world objects.

⚫ Through Inheritance, we eliminate the redundant code.

⚫ It is easy to update code.


Fundamentals of OOP
Classes
⚫ It is a user defined data type, which holds it’s own data members and
member functions, which can be accessed and used by creating instance of
that class.

⚫ Class is a blueprint for creating objects.

⚫ Ex. Car, Person, Mobile etc


Classes
Objects
⚫ Instance of Class

⚫ Objects are the basic run-time entities in an object-oriented system.

⚫ Objects take up space in memory and have associated address like a


structure in ‘C’.

⚫ Objects can interact without having to know details of each other’s data or
code.
Objects
Example
class GFG {
⚫ import java.io.*; ⚫

⚫ public static void main (String[] args) {

⚫ ⚫ Car ferrari = new Car();

⚫ ferrari.displaycarDetails();
⚫ class Car{ ⚫ }

⚫ String carModel; ⚫ }

⚫ String
companyName;
⚫ double carWeight;
Data Abstraction and Encapsulation
⚫ Abstraction refers to the act of representing essential features without
including the background details or explanations.

⚫ Classes use the concept of abstraction and are defined as a list of abstract
attributes such as size, weight and cost, and functions to operate on these
attributes.

⚫ The attributes are sometimes called data members because they hold
information. The functions that operate on these data are called member
functions or methods.
Data Abstraction and Encapsulation
Data Abstraction and Encapsulation
⚫ The wrapping up of data and functions into a single unit ( called class) is
known as encapsulation.

⚫ The data is not accessible to the outside world, and only those functions
which are wrapped in the class can access it.

⚫ This insulation of the data from direct access by the program is called data
hiding and information hiding
Inheritance
⚫ Inheritance is the process by which objects of one class acquire the
properties of another class. It supports the concept of hierarchical
classification.

⚫ The concept of reusability provides the idea of reusability. This means we


can add additional features to an existing class without modifying it. This is
possible by deriving a new class from the existing one.
Inheritance
Inheritance
Polymorphism
⚫ Polymorphism, a Greek term, means the ability to take more than one form.
An operation may exibit different behavior in different instances. The
behavior depends upon the type of data used in the operation.

⚫ Polymorphism plays an important role in allowing objects having different


internal structure to share the same external interfaces.
Polymorphism
Static and Dynamic Binding
⚫ Binding refers to the linking of a procedure call to the code to be executed in
reponse to the call.

⚫ Static Binding: The binding which can be resolved at compile time by


compiler is known as static or early binding. Binding of all the static, private
and final methods is done at compile-time.
Static and Dynamic Binding
⚫ Binding refers to the linking of a procedure call to the code to be executed in
reponse 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 run time.

⚫ It is associated with polymorphism and inheritance. A function call associated


with a polymorphic reference depends on the dynamic type of that reference.
Static and Dynamic Binding
Message Passing
⚫ Messgae passing, in terms of computer is communication between
processes. It is a form of communication used in object oriented
programming as well as parallel programming.

⚫ A messagae for an object is a request for execution of a procedure, and


therefore will invoke a function in the receiving object that generates the
desired results. Message passing involves specifying the name of object, the
name of the function(message) and the information to be sent.
Message Passing

You might also like