0% found this document useful (0 votes)
89 views18 pages

BCAC-301 - Lecture 1

This document provides an overview of object-oriented programming concepts including: - The course objectives which are to understand OOP fundamentals in Java like variables, conditionals, methods, inheritance and exceptions. - The content which will cover OOP, paradigms, characteristics, advantages, and differences between OOP and procedural programming. - Descriptions of key OOP concepts like objects, classes, encapsulation, inheritance, polymorphism and dynamic binding.

Uploaded by

01ABHIGYAN MAJI
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)
89 views18 pages

BCAC-301 - Lecture 1

This document provides an overview of object-oriented programming concepts including: - The course objectives which are to understand OOP fundamentals in Java like variables, conditionals, methods, inheritance and exceptions. - The content which will cover OOP, paradigms, characteristics, advantages, and differences between OOP and procedural programming. - Descriptions of key OOP concepts like objects, classes, encapsulation, inheritance, polymorphism and dynamic binding.

Uploaded by

01ABHIGYAN MAJI
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/ 18

Presented by:

SUJOY KUMAR BASU


AP, Dept. of Computer Application
AEC, Asansol
Course Objective
2

• Understand the fundamentals of object-oriented


programming in J av a .
• Use concepts s uch as variables, conditional
and iterative constructs.
• Working with methods.
• Exception Handling mechanisms and Multi
threading.
• Understand the principles of inheritance,
packages, interfaces.
• Understand the use of Applets
Content
3

 Object Oriented Programming


 O O P Paradigm
 Characteristics of O O P
 Advantages of O O P
 Applications of O O P
 Difference between POP & O O P
Object Oriented Programming
4

Object-Oriented Programming or O O P s refers to


languages that uses objects in programming. Object-
oriented programming aims to implement real-world
entities like inheritance, data hiding, polymorphism etc
in programming. The main aim of O O P is to bind
together the data and the functions that operate on
them so that no other part of the code can access this
data except that function.
OPP allows decomposition of a problem into a number of
entities called object & then builds data & functions
around these object. The data of an object can be
accessed only by the functions associated with the
object. Functions of one object can access the functions
of other objects.
O O P Paradigm
5

It is necessary to understand some of the concepts


used extensively in O O P. T he main features of O O P
approach are:
1. Object
2. Classes
3. Encapsulation
4. Data Abstraction
5. Inheritance
6. Polymorphism
7. Dynamic Binding
8. Message Passing
O O P Paradigm Cont d …
6

Object: An object is a basic run-time entities in a n object oriented


programming. It is a concrete instance of some classes. A typical
J a va program creates many objects, which as you know, interact
by invoking methods. An object consists of :
State : It is represented by attributes of a n object. It also reflects the
properties of a n object.
Behavior : It is represented by methods of a n object. It also
reflects the response of a n object with other objects.
Identity : It gives a unique name to a n object and enables one
object to interact with other objects.
Example: An object is “dog”.
Identity: Name is dog.
State / Attribute: Breed, Age, color.
Behavior: Ba rks , Sleeps, Ea ts.
Method: A method is a function or a procedure that access to
the internal state of the object needed to perform some
operation.
O O P Paradigm Cont d …
7

Classes: Object contain data, and code to manipulate that data.


The entire set of data & code of a n object can be made a user-
defined data type with the help of a Cl a ss . In fact, objects are
variables of the type class. Once a class ha s been defined, we
can create any number of objects belonging to the class. Ea c h
object is associated with the data of type class with which they
are created. A class is thus a collection of objects of similar
type.

Example: Mango, Apple, Orange are member of the class Fruit.


Classes are user defined data type & behave like the built-in
types of a programming language. An object is a n individual
instance of a class.
O O P Paradigm Cont d …
8

When a n object of a class is created, the class is said to


be instantiated. All the instances share the attributes and the
behavior of the class. B ut the values of those attributes, i.e. the
state are unique for each object. A single class may have any
number of instances.
Example :

Class dog
State/Attribute
Breed
dog1 dog3
Age
Color
Behavors
Bark dog4
dog2
Sleep
Eat
O O P Paradigm Cont d …
9

Encapsulation: The wrapping up of data & 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. These functions provide the interface between the
object’s data & the program. This insulation of the data from direct
access by the program is called data hiding or information hiding.

Abstraction: Abstraction refers to the act of representing essential


features without including background details or explanations.
Classes use the concept of abstraction & are defined as a list of
abstract attributes such as size, weight & cost & functions to operate
on these attributes. They encapsulate all the essential properties of
the objects that are to be created.
Example: A real life example of a ma n driving a car. The ma n only
knows that pressing the accelerators will increase the speed of car
but he does not know about how on pressing the accelerator the
speed is actually increasing, he does not know about the inner
mechanism of the car.
O O P Paradigm Cont d …
10

Inheritance: Inheritance is the process by which objects of one class


acquire the properties of objects of another class. It supports the
concept of hierarchical classification.
In O O P, the concept of inheritance provides the idea of reusability.
This means that we can add additional features to a n 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 the classes.
Example:

Parent

Children
O O P Paradigm Cont d …
11

Polymorphism: The word polymorphism means having many


forms. In simple words, we can define polymorphism as the
ability of a message to be displayed in more than one form.
Polymorphism is considered a s one of the important features of
Object Oriented Programming. Polymorphism allows u s to
perform a single action in different ways. In other words,
polymorphism allows you to define one interface and have
multiple implementations. The word “poly” means many and
“morphs” means forms, So it means many forms.
E xample: A person at the sa me time can have different
characteristic. Like a ma n at the sa me time is a father, a
husba nd , a n employee. So the sam e person posses different
behaviour in different situations. This is called polymorphism.
O O P Paradigm Cont d …
12

Dynamic Binding: Binding refers to 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 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.
O O P Paradigm Cont d …
13

Message Passing: An object oriented program consists of a objects


that communicate with each other. Objects communicate with one
another by sending & receiving information m u c h the same way as
people pass message to one another. The concept of message passing
makes it easier to talk about building systems that directly simulate
their real world counterparts.

A message for a n object is a request for execution of a procedure, and


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

Example:
emp.salary(name);
Characteristics of OOP
14

Some of the striking characteristics of OOP are:


 Emphasis is on data rather than procedure.
 Programs are divided into what are known a s objects.
 D a ta structures are designed suc h tha t they characterized the
object.
 Functions that operate on the data of a n object are tied together in
the data structure.
 Data is hidden & cannot be accessed by external functions.
 Objects may communicate with each other through functions.
 New data & functions can be easily added whenever necessary.
 It follows bottom-up approach in program design.
Advantages of O O P
15

The advantages of O O P are mentioned below:


 O O P provides a clear modular structure for programs.
 It is good for defining abstract data types.
 Implementation details are hidden from other modules and other
modules ha s a clearly defined interface.
 It is easy to maintain and modify existing code as new objects can
be created with small differences to existing ones.
 Objects, methods, instance, message passing, inheritance are some
important properties provided by these particular languages
 Encapsulation, polymorphism, abstraction are also counts in these
fundamentals of programming language.
 It implements real life scenario.
 In O O P, programmer not only defines data types but also deals with
operations applied for data structures.
Applications of O O P
16

Main application areas of O O P are:


 User interface design such as windows, me n u.

 Real Time Systems


 Simulation and Modelling
 Object oriented databases
 AI and Expert System
 Neural Networks and parallel programming
 Decision support and office automation systems etc.
Procedure oriented vs Object
oriented programming
17

Procedure Oriented Object Oriented


In object oriented programming,
In procedural programming, program is
program is divided into small parts
divided into small parts called functions.
called objects.
Procedural programming does not have Object oriented programming provides
any proper way for hiding data so it data hiding so it is more secure.
is less secure.

In procedural programming, function is In object oriented programming, data is


more important than data. more important than function.

Inheritance is not allowed. Inheritance property is used.

Procedural programming follows top Object oriented programming follows


down approach. bottom up approach.

Examples of POP C , FORTRAN, Pascal, Exemples of O O P C++, J a v a , Python, C#


Basic etc. etc.
Thank You.

You might also like