0% found this document useful (0 votes)
8 views27 pages

OOPS

The document provides an overview of Object-Oriented Programming (OOP), detailing its advantages, disadvantages, and core concepts such as classes, objects, encapsulation, abstraction, inheritance, and polymorphism. It explains how OOP allows for code reusability and easier management while also highlighting the complexities and skills required. Additionally, it discusses relationships between objects, including association, aggregation, and composition.

Uploaded by

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

OOPS

The document provides an overview of Object-Oriented Programming (OOP), detailing its advantages, disadvantages, and core concepts such as classes, objects, encapsulation, abstraction, inheritance, and polymorphism. It explains how OOP allows for code reusability and easier management while also highlighting the complexities and skills required. Additionally, it discusses relationships between objects, including association, aggregation, and composition.

Uploaded by

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

An Overview of Java

1
Object-oriented programming

Object-oriented programming (OOP) is a programming language


model in which programs are organized around data, or objects,
and a set of well-defined interfaces to that data.

Example OOP language:

1.Simula 2.Smalltalk 3. C++ 4.Java 5.JavaScript

6. Python 7 . PHP 8.Ruby 9.Scala 10. Visual Basic .NET

and etc

2
Advantages of OOP :
– Ability to represents Real Word Entities
– Code Reusability
– Easy Management
– Maintenance
– Abstraction
– Polymorphism
Disadvantages:
– Complex Design
– Many skills
– Large size & Many Instructions
– Slow Speed

3
OOP CONCEPTS

4
OOP CONCEPTS

• Class
• Object
• Encapsulation
• Abstraction
• Inheritence
• Polymorphism
• Message Passing
• Association
• Aggregation
• Composition

5
6
OBJECTS

• An real time / runtime entity that has state and behavior is known as
an object e.g. chair, bike, marker, pen, table, car etc.
• It can be physical or logical (tangible and intangible). The example
of an intangible object is the banking system.
• The object is an instance of a class.

7
8
CLASS

9
• It is a template or blueprint that describes the kinds of state and
behavior that objects of its type support.
• It is a template or blueprint from which objects are created.
• A class is a collection of objects which have common properties.
• It is a logical entity. It can't be physical.

10
Member of a class

11
Encapsulation

12
• Encapsulation is the mechanism that binds together code and the
data it manipulates, and keeps both safe from outside interference
and misuse.
• One way to think about encapsulation is as a protective wrapper
that prevents the code and data from being arbitrarily accessed by
other code defined outside the wrapper.
• Access to the code and data inside the wrapper is tightly controlled
through a well-defined interface.

13
• We can achieve encapsulation in Java by:
• Declaring the variables of a class as private.
• Providing public setter and getter methods to modify and view the
variables values.

14
Abstraction

15
• For Car as an example, people do not think of a car as a set of tens
of thousands of individual parts. They think of it as a well-defined
object with its own unique behavior.
• For driving car as an example, while driving a car, you do not have
to be concerned with its internal working. Here you just need to
concern about parts like steering wheel, Gears, accelerator, etc.

16
Making phone call as abstraction

For example phone call, we don't know the internal processing, to make a call, it is
enough to know the phone number.

17
• An abstraction is an act of representing essential features without
including background details.
• It basically deals with hiding the details and showing the essential
things to the user
• It is a technique of creating a new data type that is suited for a
specific application.
• Helps to reduce complexity.

18
• You can achieve abstraction in two ways:
• a) Abstract Class
• b) Interface

19
Inheritance

20
• Inheritance is the process by which one object acquires the
properties and behaviors of the parent object and reuse it .
• This is important because it supports the concept of hierarchical
classification i.e It’s creating a parent-child relationship between two
classes.

21
• A class which inherits the properties is known as Child Class
whereas a class whose properties are inherited is known as Parent
class.
• The child acquires the properties and behaviors of the parent object
in addition to that it has its own the properties and behaviors.
• It provides code reusability

22
23
Polymorphism

• Polymorphism means taking many forms, where ‘poly’ means many


and ‘morph’ means forms. It is the ability of a variable, function or
object to take on multiple forms.
• In other words, polymorphism allows you define one interface or
method and have multiple implementations.
• The base class reference have the ability to take multiple forms.

24
7) Association
Association is a relationship between two objects. It defines the
diversity between objects. In this OOP concept, all object have their
separate lifecycle, and there is no owner. For example, many
students can associate with one teacher while one student can also
associate with multiple teachers.
Aggregation
• In this technique, all objects have their separate lifecycle. However,
there is ownership such that child object can’t belong to another
parent object. For example consider class/objects department and
teacher. Here, a single teacher can’t belong to multiple
departments, but even if we delete the department, the teacher
object will never be destroyed.

25
Composition
• A composition is a specialized form of Aggregation. It is also called
"death" relationship. Child objects do not have their lifecycle so
when parent object deletes all child object will also delete
automatically. For that, let’s take an example of House and rooms.
Any house can have several rooms. One room can’t become part of
two different houses. So, if you delete the house room will also be
deleted.

• Message passing

A single object by itself may not be very useful. An application


contains many objects. One object interacts with another object by
invoking methods on that object. It is also referred to as Method
Invocation.

26
27

You might also like