Object-oriented programming (OOP) is a programming paradigm that represents concepts as "objects" that have properties and behaviors. Some key concepts of OOP include:
- Objects can be defined as instances of classes that have states and behaviors. Classes are collections of objects.
- Inheritance allows objects to acquire properties and behaviors from parent objects.
- Polymorphism allows the same task to be performed in different ways.
- Abstraction hides internal details and shows functionality.
- Encapsulation binds code and data together into a single unit.
OOP aims to implement real-world entities and is used in languages like Java, C++, and Python.
Java Programming
Object-Oriented concepts
by
GOWRUBHARATH KUMAR
M.Tech, (Ph.D)
Assistant Professor
I'm not a great programmer; I'm just a good
programmer with great habits
It is not enough for code to work
2.
Object- Oriented Langugaes
Object-OrientedProgramming is a paradigm that provides many concepts, such
as inheritance, data binding, polymorphism, etc.
Simula is considered the first object-oriented programming language. The
programming paradigm where everything is represented as an object is known as
a truly object-oriented programming language.
Smalltalk is considered the first truly object-oriented programming language.
The popular object-oriented languages are Java, C#, PHP, Python, C++, etc.
The main aim of object-oriented programming is to implement real-world
entities, for example, object, classes, abstraction, inheritance, polymorphism, etc.
I'm not a great programmer; I'm just a good
programmer with great habits
3.
OOPs (Object-Oriented ProgrammingSystem)
• Object means a real-world entity such as a pen, chair,
table, computer, watch, etc.
Object-Oriented Programming is a methodology or
paradigm to design a program using classes and objects. It
simplifies software development and maintenance by
providing some concepts:
• Object
• Class
• Inheritance
• Polymorphism
• Abstraction
• Encapsulation
Apart from these concepts, there are some other terms
which are used in Object-Oriented design:
• Coupling
• Cohesion
• Association
• Aggregation
• Composition
I'm not a great programmer; I'm just a good programmer with
great habits
4.
Object
• Any entitythat has state and behavior is known as an object.
For example, a chair, pen, table, keyboard, bike, etc. It can be physical or
logical.
• An Object can be defined as an instance of a class. (or) An object is a
real-world entity. (or) An object is a runtime entity.
• An object contains an address and takes up some space in memory. Objects
can communicate without knowing the details of each other's data or code.
The only necessary thing is the type of message accepted and the type of
response returned by the objects.
Example: A dog is an object because it has states like color, name, breed, etc. as
well as behaviors like wagging the tail, barking, eating, etc.
I'm not a great programmer; I'm just a good
programmer with great habits
5.
Object Cont…
I'm nota great programmer; I'm just a good
programmer with great habits
6.
Class
• Collection ofobjects is called class.
• It is a logical entity.
• A class can also be defined as a blueprint from which you can create an
individual object. Class doesn't consume any space.
I'm not a great programmer; I'm just a good
programmer with great habits
7.
Inheritance
• When oneobject acquires all the properties and behaviors of a parent
object, it is known as inheritance.
• It provides code reusability. It is used to achieve runtime polymorphism.
I'm not a great programmer; I'm just a good
programmer with great habits
8.
Polymorphism
• If onetask is performed in different ways, it is known as polymorphism.
For example: to convince the customer differently, to draw something, for
example, shape, triangle, rectangle, etc.
• In Java, we use method overloading and method overriding to achieve
polymorphism.
• Another example can be to speak something; for example, a cat speaks
meow, dog barks woof, etc.
I'm not a great programmer; I'm just a good
programmer with great habits
9.
Abstraction
• Hiding internaldetails and showing functionality is known as
abstraction.
For example phone call, we don't know the internal processing.
• In Java, we use abstract class and interface to achieve abstraction.
I'm not a great programmer; I'm just a good
programmer with great habits
10.
Encapsulation
• Binding (orwrapping) code and data together into a single unit are
known as encapsulation. For example, a capsule, it is wrapped with
different medicines.
• A java class is the example of encapsulation. Java bean is the fully
encapsulated class because all the data members are private here.
I'm not a great programmer; I'm just a good
programmer with great habits
11.
Procedural languages vsOOP
I'm not a great programmer; I'm just a good
programmer with great habits
Procedural Oriented Programming Object Oriented Programming
In procedural programming, program is divided into
small parts called functions.
In object oriented programming, program is divided
into small parts called objects.
Procedural programming follows top down approach.
Object oriented programming follows bottom up
approach.
There is no access specifier in procedural
programming.
Object oriented programming have access specifiers
like private, public, protected etc.
Adding new data and function is not easy. Adding new data and function is easy.
Procedural programming does not have any proper
way for hiding data so it is less secure.
Object oriented programming provides data hiding so
it is more secure.
In procedural programming, overloading is not
possible.
Overloading is possible in object oriented
programming.
In procedural programming, function is more
important than data.
In object oriented programming, data is more
important than function.
Procedural programming is based on unreal world. Object oriented programming is based on real world.
Examples: C, FORTRAN, Pascal, Basic etc. Examples: C++, Java, Python, C# etc.
12.
Summary
• Any entitythat has state and behavior is known as an object. (or) An
Object can be defined as an instance of a class. (or) An object is a real-
world entity. (or) An object is a runtime entity.
• Collection of objects is called class.
• Hiding internal details and showing functionality is known as
abstraction.
• When one object acquires all the properties and behaviors of a parent
object, it is known as inheritance.
• If one task is performed in different ways, it is known as polymorphism.
• Binding (or wrapping) code and data together into a single unit are
known as encapsulation.
• OOP is a programming methodology that helps organize complex programs
using inheritance, encapsulation and polymorphism.
I'm not a great programmer; I'm just a good
programmer with great habits
13.
I'm not agreat programmer; I'm just a good
programmer with great habits