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

Chaptero 1

The document outlines a Java Object-Oriented Programming (OOP) course for Information Science undergraduates at Madda Walabu University. It covers various programming paradigms, emphasizing the advantages of OOP, such as encapsulation, inheritance, and polymorphism, which enhance software development and management. Additionally, it highlights the applications of OOP in areas like real-time systems, AI, and databases.

Uploaded by

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

Chaptero 1

The document outlines a Java Object-Oriented Programming (OOP) course for Information Science undergraduates at Madda Walabu University. It covers various programming paradigms, emphasizing the advantages of OOP, such as encapsulation, inheritance, and polymorphism, which enhance software development and management. Additionally, it highlights the applications of OOP in areas like real-time systems, AI, and databases.

Uploaded by

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

Java in OOP course

Compiled by:
Tefera.S (PhD. Candidate in Information Science @ JIT).

Academic Year: 2024

Course Credit: 3, for 3rd year, 1st semester, Information Science


undergraduates

Madda Walabu University


Bale Robe, Ethiopia
27/04/2025 1
Chapter 1
Introduction to Object-Oriented Programming

Types of Programming Paradigm:-

• Nowadays, the major revolutions and innovations in the


programming world are unlike the features or properties
observed in advance of programming languages and interfaces.

• As might be expected, there is no unique standard for


classifying programming languages in a dynamic and evolving
field.

• The most fundamental way programming languages are


characterized or classified by programming paradigm.
27/04/2025 2
Cont…
• A programming paradigm provides the programmer's
view of code execution.
• Among these, the following are worth mentioning:
• Procedural programming paradigm
• Structured programming paradigm and
• Object-Oriented Programming Paradigms
A) Procedural Programming Paradigms:-
• Procedural programming specifies a list of operations
that the program must complete to reach the desired
state.
• Each program has a starting state, a list of operations to
complete, and an ending point.
27/04/2025 3
Cont…
• A procedure is effectively a list of computations (Steps) to be carried
out.

• Procedural programming can be compared to unstructured

programming, where all the code exists in a single large block.

• High-level languages such as COBOL, FORTRAN and C, are usually


recognised as procedure-oriented programming Languages
(POPL).

• In the procedure-oriented approach, the problem is viewed as an


order of things to be done such as reading, calculating and printing.
27/04/2025 4
The techniques of hierarchical decomposition have been used to specify the tasks to be
completed to solve a problem.

27/04/2025 5
• Procedure-oriented programming consists of writing a list of
instructions (actions) for the computer to follow and organising these
instructions into groups known as functions.
• A serious drawback of the procedural approach is that it does not
model real-world problems very well.
• Because functions are action-oriented and do not correspond to
the elements of the problem.
• Some characteristics exhibited by procedure-oriented programming
are:
• Emphasis is on doing things (algorithms).
• Large programs are separated into smaller programs known as
Functions.
• Most of the functions help to share global data.
• Data moves openly around the system from function to function.
• Functions enhance to transform data from one to another
programming bodies.
• Employs a top-down approach in program design.
27/04/2025 6
B) Structured Programming Paradigms
• (SPP):-is a special type of procedural programming:-

It provides extra tools to manage the problems that larger


programs are creating.
It requires that programmers break program structure into
small pieces of code that are easily understood.
Also not comfortable with the use of global variables, and
instead uses variables local to each subroutine.

27/04/2025 7
C) Object-Oriented Programming Paradigms (OOPP)

• This is the cornerstone and the major inspiring factor in the


invention of the object-oriented approach is to remove some of the
flaws encountered in the procedural approach.

• So, the (OOP) treats data as a critical element in the program


advance and does not allow it to flow freely around the system.

• It ties data more strictly to the functions that operate on it and


keeps it from accidental modification from outside functions.

• So, OOP allows the decomposition of a problem into many entities


called objects and then builds data & functions around these
objects.
27/04/2025 8
• The data of an object can be accessed only by the functions
allied with that object.
• So, the functions of one object can access the functions of
other objects.

27/04/2025 9
Some of the striking features of OOP are:

• Emphasis is on data rather than procedure.

• Programs are divided into what are known as objects.

• Data structures are designed such that they describe the objects.

• Functions that operate on an object’s data are tied together in the


data structure.

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

• Objects may communicate with each other through functions.

• New data and functions can be easily added whenever necessary.


27/04/2025 10
Overview of OO principles:-
 Overall understanding of some of the concepts used widely in OOP are:-
 Objects (a specific instance of a class)
 Classes (It is a blueprint for creating objects)
 Data abstraction/data hiding(showing only the vital features of an object). E.g. ATM
 Encapsulation (allows a class to hide the operation details of programmed elements).
 Inheritance (that allows a class to inherit properties & behaviors from another class).
 Polymorphism (something that occurs in several different forms). E.g. (Class Area).
 Dynamic binding (the actual method that gets executed isn't known until the code is running).
 Message Passing (objects to talk and interact with each other by sending messages).

27/04/2025 11
Objects

• Objects are the basic run-time entities in an object-


oriented system.
• It may signify a Person, Animal, Thing, a place, a bank
account, a Table of data, or any item that the program
has to handle.
• Programming problem is analyzed in terms of objects and
the nature of communication between them.
• When a program is executed, the objects interact by
27/04/2025 12
• For example, if “customer” & “account” are two objects
in a program, the customer object may send a message to
the account object requesting the bank balance.
• Each object contains data, and code to manipulate the data.
• Objects can interact without having to know details of each
other’s data or code.

27/04/2025 13
Classes
• Objects are variables of the type class.
• Once a class has been defined, we can create any
number of objects belonging to that class.
• Each object is associated with the data of the type class
with which they are created.
• A class is thus a collection of objects of similar type.
• For example, mango, apple and orange are members of the
class fruit.
• Classes are user-defined data types and behave like the
built-in types of a programming language.
• If fruit has been defined as a class, then the statement
• fruit mango; Orange, Banana…..
• will create as an objects belonging to the class fruit.
27/04/2025 14
Data Abstraction and Encapsulation

• Wrapping up of data and functions into a single unit (called


class) is known as encapsulation.

• Data encapsulation is the most striking feature of a class.

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

• Functions offer the interface B/n the object’s data & the
program.

• This insulation of the data from direct access by the program is


called
27/04/2025 data hiding or information hiding. 15
Cont...

• Abstraction is 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, cost, and functions to operate on these attributes.
• They encapsulate all the essential properties of the objects that are to be created.

• The attributes are sometimes called data members, b/c they hold evidence.

• The functions that operate on these data are sometimes called methods /member

functions.
• Since the classes use the concept of data abstraction, they are known as Abstract

Data Types (ADT).

27/04/2025 16
Inheritance

• Inheritance is the process by which objects of one class acquire the


properties of objects of another class.

• It is a mechanism that allows a class to inherit properties and behaviors from


another class.

• It supports the concept of hierarchical classification.

• For example, the bird ‘robin’ is a part of the class ‘flying bird’ which
is again a part of the class ‘bird’.

• The belief behind this sort of division is that each derived class
shares common characteristics with the class from which it is derived.
27/04/2025 17
Cont…

27/04/2025 18
Cont…
• In OOP, the concept of inheritance provides the idea of reusability.
• This means we can add extra features to an existing class without modifying it.
• This is possible by deriving a new class from the existing one.
• The new class will have the combined features of both classes.

Polymorphism
• It is a Greek term, that means the ability to take more than one form.
• An operation may exhibit unlike behaviours in unlike instances.
• The behaviour depends upon the types of data used in the operation.
• For example, consider the operation of addition (+).
• For two numbers, the operation will generate a sum (2+3=5).
• If the operands are strings, then the operation would produce a third string by concatenation
(string 1 =“Hello,”, string2 = “World!”; result = string1 + string2 and print (result) then the
output = Hello, World!).
• The process of making an operator exhibit diverse behaviours in diverse instances
is known as operator overloading.
27/04/2025 19
Cont…
• Using a single function name to perform diverse types of
tasks is known as function overloading.

• Polymorphism plays an important role in allowing objects


having different internal structures to share the same
external interface.

• This means that a general class of operations may be


accessed in the same manner even though specific
actions associated with each operation may differ.

• 27/04/2025
Polymorphism is extensively used in implementing 20
Cont…

27/04/2025 21
Dynamic Binding

• Binding linking of a procedure call to the code to be


executed in response to the call.
• Dynamic binding (recognised as late binding) means
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.
27/04/2025 22
Cont…
• Consider the way “draw” in the above figure, By
inheritance, every object will have this process.
• Its algorithm is, however, unique to each object, and so
the draw procedure will be redefined in each class that
defines the object.
• At run-time, the code matching the object under the
current reference will be called.

27/04/2025 23
Message Passing

• An OOP contains a set of objects that communicate with


each other.
• The process of programming in an object-oriented language,
therefore, involves the following basic steps:
1. Creating classes that define objects and their behaviour,
2. Creating objects from class definitions, and
3. Establishing communication among objects .

27/04/2025 24
• Objects communicate with one another by sending and
receiving info much the same way as people pass
messages to one another.
• A message for an object is a request for execution of a
procedure and therefore will invoke a function (procedure)
in the receiving object that generates the desired result.
• Message passing involves specifying the name of the
object, the name of the function (message) and the
information to be sent.

27/04/2025 25
Cont...
• Objects have a life cycle.
• They can be created and destroyed.
• Communication with an object is feasible as long as it is alive.
Benefits of OOP
• OOP offers many benefits to both the program designer and the
user.
• Object-orientation contributes to the solution of many problems
associated with the development and quality of software products.
• Through inheritance, we can eliminate redundant code and extend
the use of the existing class
• We can build programs from the standard working modules that
communicate with one another, rather than having to start writing
the code from scratch.
• This leads to saving development time and higher productivity
27/04/2025 26
Cont...
• The principle of data hiding helps the programmer build
secure programs that cannot be invaded by code in
other parts of the program.
• It is possible to have multiple instances of an object to
co-exist without any interference.
• It is easy to partition the work in a project based on
objects
• Software complexity can be easily managed.
27/04/2025 27
Some of the Applications of OOP:-

• The promising areas for application of OOP include:

• Real-time systems

• Simulation and modelling

• Object-oriented databases

• Hypertext, hypermedia and experts

• AI and expert systems

• Neural networks and parallel programming

• Decision support and office automation systems


27/04/2025 28
End of ch-1!

“If Spider Webs United Together


It Can Tie a Lion”

Thank you for the smooth attention.

27/04/2025 29

You might also like