SlideShare a Scribd company logo
1 of 40
Introduction to
OOP
Prepared by : Abrar Ahmed
What is Object???
• An object is a noun (or pronoun).
⮚In this universe every thing is noun , so we can conclude that every
thing which we are surrounded by is an object.
⮚Are you an Object??
⮚Each and every object in this universe has some properties.
⮚If u consider yourself as an object, what properties do you have???
⮚Color , height ,weight , Name , Address etc
What is oop
Stands for "Object-Oriented Programming." OOP(not Oops!) refers to a programming methodology based on objects, instead of just
functions and procedures.
Most modern programming languages including
Java,
C#, and
PHP,
are object-oriented languages,
and many older programming languages now have object-oriented versions.
▪ Object-oriented programming makes it easier for programmers to structure and organize software programs.
▪ Because individual objects can be modified without affecting other aspects of the program.
▪ it is also easier to update and change programs written in object-oriented languages.
▪ As software programs have grown larger over the years, OOP has made developing these large programs more manageable.
Pillars Of OOP
• There are 4 fundamentals ideas of Object Oriented Programming. They have the
wonderful terms:
1. Abstraction
2. Polymorphism
3. Inheritance
4. Encapsulation
• One way to remember these is the acronym APIE. Let’s dive into each of them
one by one.
Abstraction (Hiding Something
)
Abstraction is the process of hiding out the working style of an object and showing only the required information of the object
in understandable manner.
Real World Example:
▪ Consider an example if you are driving a car on a road and suddenly another car cross you what would you do??
▪ Most probably you will apply brakes . but if you don’t know where is the paddle of brake , can you apply them???
▪ Exactly not.so information about shape and location of brakes are necessary.
▪
▪ But is it necessary to you to know about the procedure running behind the car when you apply brakes?? Does it really
matter to you.
▪ NO!!!! We are only interested in the end results it is beyond of our interest that what mechanicaloperations are
performing.
▪ Same on this pattern abstraction says “show only those things which are relevant and hide unnecessary complexities”.
Polymorphism (Many F orm)
Poly=many morph= form
By name we can come to a conclusion that it's about something with many forms. In OOP it is an ability of an object to
take many forms.
Real World Example:
My name is Owais:
I am a Faculty,
a brother,
a friend,
a son,
a student
depending upon the situation i.e. parameter surrounding me.
Similarlyin OOP we can have a function with different form but with same name.
Inheritance (sharing)
• Inheritance is when an object acquires the property of another object.
• Inheritance allows a class (subclass) to acquire the properties and behavior of another class (superclass).
• It helps to reuse, customize and enhance the existing code.
• So it helps to write a code accurately and reduce the development time.
• Real World Example
• In our tradition if a father has any property , it will be further divided into his children or we can say that children can have
advantages of their father’s possessions.
• Same as it is inheritance say that if there is a relation of child and parent between objects.so the properties of parent ca n be
inherited by children.
• Another example, a scientific calculator is an extended form of Calculator, here Calculator is parent and scientific calculator is Child object.
Encapsulation (packing)
• Encapsulation means wrapping up data and member function (Method) together into a single unit .
• Encapsulation automatically achieve the concept of data hiding providing security to data by making the variable as
private and expose the property to access the private data which would be public.
• Real World Example
Advantages Of OOP
• Improved software-developmentproductivity: Object-oriented programming is modular, as it provides separation of duties in
object-based program development.
• Improved software maintainability: For the reasons mentioned above, object oriented software is also easier to maintain.
Since the design is modular, part of the system can be updated in case of issues without a need to make large-scale changes.
• Faster development: Reuse enables faster development.Object-oriented programming languages come with rich libraries of
objects, and code developed during projects is also reusable in future projects.
• Real World Modeling : as we know that oop is based on object and object are the part of real world. So we can easily
associate all of our task with real world.
Disadvantages Of OOP
• Steep learning curve: The thought process involved in object-oriented programming may not be natural for some people, and it can take time
to get used to it. It is complex to create programs based on interaction of objects. Some of the key programming techniques, such as
inheritance and polymorphism, can be challenging to comprehend initially.
• Larger program size: Object-oriented programs typically involve more lines of code than procedural programs.
• Slower programs: Object-oriented programs are typically slower than procedurebased programs, as they typically require more instructions to
be executed.
Object Oriented Design
• Object Oriented Design is the concept that forces programmers to plan out their code in order to have a better flowing program.
• Technique that focuses on designing the data and the interfaces to it.
• Process of creating a system where objects coordinate or interact with each other to accomplish a task
Classes
Object :
• Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors – wagging
the tail, barking, eating. An object is an instance of a class.
Object can also be referred to as an instance of a class.
• An object is one copy of the class.
Class :
• A class can be defined as a template/blueprint that describes the behavior/state that the object of its type
support.
• A class or a category is a group of people or things having common characteristics .
Messages And Method
• A method is a set of steps or instructions, or a procedure to accomplish something
• Message is a set of words, a phrase, or statement to convey something
• The figure shows how the objects pass messages to each other to fulfill a task.
• Here (makeCake,DeliverCake,AcceptCake) are methods while each entity passing messages to
another to make the task completed.
Modules
• To solve complex problems divide the problem into smaller units or modules.
• The figure shows the approximate time it took to Bob to deliver the cake when he does everything himself.
• This shows that by dividingthe task between multiple people, Bob was able to achieve his goal in almost half the time than he
would have done it himself
Generalization
• Generalizationis a bottom-up approach in which two lower level entities combine to forma higher level entity. In generalization, the
higher level entity can also combine with other lower level entity to make further higher level entity.
Specializatio
n
• Specialization is opposite toGeneralization. It is a top-downapproach in which one higher level entity can be broken down into two lower level
entity. In specialization, some higher level entities may not have lower-level entity sets at all.
Coupling
• Coupling is the principle of "separation of concerns". This means that one object doesn't directly change or modify the state or behavior of
another object.
• Coupling looks at the relationship between objects and how closely connected they are.
• A good example of coupling is HTML and CSS. Before CSS, HTML was used for both markup and presentation. This created bloated code that
was hard to change and difficult to maintain. With the advent of CSS, HTML became used just for markup, and CSS took over for presentation.
This made the code fairly clean and easily changeable. The concerns of presentation and markup were separated.
loosely coupled:
• Objects that are independent from one another and do not directly modify the state of other objects are said to be loosely coupled. Loose
coupling lets the code be more flexible, more changeable, and easier to work with.
tightly coupled:
• Objects that rely on other objects and can modify the states of other objects are said to be tightly coupled. Tight coupling creates situations
where modifying the code of one object also requires changing the code of other objects (also known as a ripple effect). Tightly coupled code
is also harder to reuse because it can't be separated.
Tightly Coupled
Loosely
Coupled
Cohesion
• Cohesion is the principle of being or doing one thing well. In other words, cohesion means grouping together code that
contributes to a single task.
• Each object should only have one responsibility.Every behaviorof that object should only do one task. Any more than that
and you'll have a much harder time making changes to the code.
• Code that is organized by functionality and does only one task is said to have high cohesion. Highly cohesive code is reusable,
simple, and easy to understand. It also creates objects that are small and focused.
• Code that is organized arbitrarily and has multiple tasks is said to have low cohesion. Such code is difficult to understand,
maintain, and reuse, and is often complex. It also creates objects that are large and unfocused.
• Having high cohesion is generally good, while having low cohesion is generally bad. When writing code, always strive to write
highly cohesive code.
Classes In OOP
• It is similar to structures in C language. Class can also be defined as user defined data type but it also
contains functions in it. So, class is basically a blueprint for object. It declare &defines what data
variables the object will have and what operations can be performed on the class's object.
• In Java, a class is a definition of objects of the same kind. In other words, a class is a blueprint, template, or
prototype that defines and describes the static attributes and dynamic behaviors commonto all objects of the
same kind.
Access Modifiers
• There are 4 types of java access modifiers:
1. private
2. default
3. protected
4. Public
private access modifier
• The private access modifier is accessible only within class.
default access modifier
• If you don't use any modifier, it is treated as default bydefault. The default modifier is accessible only within package.
protected access modifier
• The protected access modifier is accessible within package and outside the package but through inheritance only.The protected
access modifier can be applied on the data member, method and constructor.It can't be applied on the class.
public access modifier
• The public access modifier is accessible everywhere. It has the widest scope among all other modifiers.
Method
• A Java method is a collection of statements that are grouped together to perform an operation.
• Defines the behavior of a class
• Consists of the actions that an object or instance of a class can perform on the data members
Constructor
• A constructor is a special method of a class or structure in object-oriented programming that initializes an object of that type. A constructor is
an instance method that usually has the same name as the class, and can be used to set the values of the members of an object , either to
default or to user-defined values.
There are basically two rules defined for the constructor.
• Constructor name must be same as its class name
• Constructor must have no explicit return type
There are two types of constructors :
• Default constructor (no-arg constructor)
• Parameterized constructor
Default Constructor
• A constructor is called "Default Constructor" when it doesn't have any parameter.
parameterized constructor
A constructor which has a specific number of parameters is called parameterized constructor.
Level Of Abstraction
• The amount of complexity by which a system is viewed or programmed. The higher the level, the less detail. The lower the level, the more
detail. The highest level of abstraction is the entire system.
There are three level of Abstraction:
1. Top Most Level
2. Next Level
3. Last Level
• Example: Let’s say we are storing customer information in a customer table. At Last Level these records can be described as blocks of storage
(bytes, gigabytes, terabytes etc.) in memory. These details are often hidden from the programmers.
• At the Next Level these records can be described as fields and attributes along with their data types, their relationship among each other can be
logically implemented. The programmers generally work at this level because they are aware of such things about database systems.
• At Top Most Level, user just interact with system with the help of GUI and enter the details at the screen, they are not aware of how the data is
stored and what data is stored; such details are hidden from them.
Types of Inheritance
we have 5 different types of Inheritance. Namely,
1. Single Inheritance
2. Multiple Inheritance
3. Hierarchical Inheritance
4. Multilevel Inheritance
5. Hybrid Inheritance (also known as Virtual Inheritance)
1. Single Inheritance
Parents have only one child at a time OR there should only be a derived class from base class.
Parent/Base
Child/Derived
2. Multiple Inheritance
• In this type of inheritance a single derived class may inherit from two or more than two base classes.
3. Hierarchical Inheritance
In this type of inheritance, multiple derived classes inherits from a single base class. means parents have more than one children.
parent1 Parent2
Child
Parent
child1 child2 child3
4. Multilevel Inheritance
In Multilevel Inheritancea derived class will be inheriting a parent class and as well as the derived class act as the parent class
to other class.
5. Hybrid Inheritance in Java
Hybrid Inheritance is the combination of both Single and Multiple Inheritance. Again Hybrid inheritance is also not directly supported in Java only through interface
we can achieve this. Flow diagram of the Hybrid inheritance will look like below. As you can ClassA will be acting as the Parent class for ClassB & ClassC and ClassB &
ClassC will be acting as Parent for ClassD.
parent Child Child Grand Child
Problem With Multiple Inheritance
The Diamond Problem - a class inherits from two parent classes each of which in turn inherit from a common
super class.
Interface
There are mainly three reasons to use interface. They are given below.
1. Itis used to achieve abstraction.
2. By interface, we can support the functionality of multiple inheritance.
3. Itcan be used to achieve loose coupling.
PolyMorphism
• If a class has multiple methods having same name but different in parameters, it is known as Method Overloading.
• If we have to performonly one operation, having same name of the methods increases the readability of the program.
Differentways to overload the method
There are two ways to overload the method in java
1. By changing number of arguments
2. By changing the data type
By Changing Arguments
Int add(int a,int b) int add(int a,int b, int c)
By Changing DataTypes
int add(int a, int b)
{
}
int add(double a ,double b)
{
}
{
{
} }
Overriding
If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in
java.
Rules for Java Method Overriding
1. method must have same name as in the parent class
2. method must have same parameter as in the parent class.
3. must be IS-A relationship (inheritance).
Difference between method overloading and method overriding
Replacement & Refinement
Replacement :
When the child class completely overrides the parent class method implementation.
Refinement :
When the child class includes the functionality of the parent class version of the overridden
method within its own version.
Abstract Method
• An abstract method is one which is declared inside parent class but not implemented there.
pattern
• In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design . A design
pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be
used in many different situations.
Design patterns
• Design patterns in software are strategies which are language-independent and used for solving commonly encountered object-oriented
design problems.
Documenting patterns serves two important purposes:
• It speeds up the process of finding a solution when another problem with similar characteristics is encountered.
• Giving names to patterns allows programmers to use a common vocabulary to discuss design alternatives.
Factory Pattern
• creates objects without exposing the instantiation logic to the client.
• refers to the newly created object through a common interface
The implementation is really simple
The client needs a product, but instead of creating it directly using the new operator, it asks the factory object for a new
product, providing the information about the type of object it needs.
• The factory instantiates a new concrete product and then returns to the client the newly created product(casted to
abstract product class).
• The client uses the products as abstract products without being aware about their concrete implementation.
Singleton Design Pattern
• Ensure a class has only one instance, and provide a global point of access to it.
• The Singleton pattern ensures that a class has only one instance and provides a
global point of access to that instance.
• Example
• The office of the President of the United States is a Singleton. The United States Constitution specifies the means
by which a president is elected, limits the term of office, and defines the order of succession. As a result, there
can be at most one active president at any given time. Regardless of the personal identity of the active president,
the title, "The President of the United States" is a global point of access that identifies the person in the office.
Composite Design Pattern
composite objects:
• objects that contain other objects; for example, a drawing may be composed of graphic primitives, such as lines, circles, rectangles, text, and
so on.
• Composite pattern is used where we need to treat a group of objects in similar way as a single object. Composite pattern composes objects in
term of a tree structure to represent part as well as whole hierarchy.
Example
In an organization, It have general managers and under general managers, there can be managers and under managers there can be developers.
Now you can set a tree structure and ask each node to perform common operation like getSalary().
Composite design pattern treats each node in two ways:
1) Composite – Composite means it can have other objects below it.
2) leaf – leaf means it has no objects below it.
Decorator pattern
• Decorator pattern is used to dynamically add or remove responsibilities to an object without affecting
other objects.
• Decorator pattern allows a user to add new functionality to an existing object without altering its
structure.
• assault gun is a deadly weapon on it's own. But you can apply certain "decorations" to make it more
accurate, silent and devastating.
Proxy Pattern
• In proxy pattern, a class represents functionality of another class.
• When creating an object is too expensive in terms of time or memory.
• To postpone creation of an object until it is actually needed.
• When loading a large image which can be time consuming.
• For example, you save your money in bank in form of rupees.but when you want
to withdraw money you have to write a check. It means check is not it self money
but having functionality of money.
Frameworks
• In OOP, a framework is a set of reusable software components or classes that
form the basis of an application.
• it makes it easier to work with complex technologies
• it ties together a bunch of discrete objects/components into something more
useful
• it forces the team (or just me) to implement code in a way that promotes
consistent coding, fewer bugs, and more flexible applications
• everyone can easily test and debug the code, even code that they didn't write
• A software framework is an abstraction in which software providing generic
functionality can be selectively changed by additional user-written code, thus
providing application-specific software.

More Related Content

Similar to Intro to oop.pptx

OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.pptAkash553872
 
Introduction To Design Patterns Class 4 Composition vs Inheritance
 Introduction To Design Patterns Class 4 Composition vs Inheritance Introduction To Design Patterns Class 4 Composition vs Inheritance
Introduction To Design Patterns Class 4 Composition vs InheritanceBlue Elephant Consulting
 
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.pptsagarjsicg
 
object oriented programming(syed munib ali 11b-023-bs)
object oriented programming(syed munib ali 11b-023-bs)object oriented programming(syed munib ali 11b-023-bs)
object oriented programming(syed munib ali 11b-023-bs)munibali55
 
Object-Oriented concepts.pptx
Object-Oriented concepts.pptxObject-Oriented concepts.pptx
Object-Oriented concepts.pptxBHARATH KUMAR
 
JAVA - Oops Concept.pptx
JAVA - Oops Concept.pptxJAVA - Oops Concept.pptx
JAVA - Oops Concept.pptxayankamila005
 
Intro to iOS: Object Oriented Programming and Objective-C
Intro to iOS: Object Oriented Programming and Objective-CIntro to iOS: Object Oriented Programming and Objective-C
Intro to iOS: Object Oriented Programming and Objective-CAndrew Rohn
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programmingAmar Jukuntla
 
PHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxPHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxAtikur Rahman
 
OOPs-Interview-Questions.pdf
OOPs-Interview-Questions.pdfOOPs-Interview-Questions.pdf
OOPs-Interview-Questions.pdfSamir Paul
 
Oo concepts and class modeling
Oo concepts and class modelingOo concepts and class modeling
Oo concepts and class modelingPreeti Mishra
 

Similar to Intro to oop.pptx (20)

OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.ppt
 
OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.ppt
 
OOPs concepts.ppt
OOPs concepts.pptOOPs concepts.ppt
OOPs concepts.ppt
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
Introduction To Design Patterns Class 4 Composition vs Inheritance
 Introduction To Design Patterns Class 4 Composition vs Inheritance Introduction To Design Patterns Class 4 Composition vs Inheritance
Introduction To Design Patterns Class 4 Composition vs Inheritance
 
130704798265658191
130704798265658191130704798265658191
130704798265658191
 
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Oop.pptx
Oop.pptxOop.pptx
Oop.pptx
 
object oriented programming(syed munib ali 11b-023-bs)
object oriented programming(syed munib ali 11b-023-bs)object oriented programming(syed munib ali 11b-023-bs)
object oriented programming(syed munib ali 11b-023-bs)
 
Object-Oriented concepts.pptx
Object-Oriented concepts.pptxObject-Oriented concepts.pptx
Object-Oriented concepts.pptx
 
JAVA - Oops Concept.pptx
JAVA - Oops Concept.pptxJAVA - Oops Concept.pptx
JAVA - Oops Concept.pptx
 
Intro to iOS: Object Oriented Programming and Objective-C
Intro to iOS: Object Oriented Programming and Objective-CIntro to iOS: Object Oriented Programming and Objective-C
Intro to iOS: Object Oriented Programming and Objective-C
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
PHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxPHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptx
 
object oriented programming(oops)
object oriented programming(oops)object oriented programming(oops)
object oriented programming(oops)
 
Oops
OopsOops
Oops
 
OOPs-Interview-Questions.pdf
OOPs-Interview-Questions.pdfOOPs-Interview-Questions.pdf
OOPs-Interview-Questions.pdf
 
Oop's
Oop'sOop's
Oop's
 
Oo concepts and class modeling
Oo concepts and class modelingOo concepts and class modeling
Oo concepts and class modeling
 

Recently uploaded

Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...lizamodels9
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation SlidesKeppelCorporation
 
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...lizamodels9
 
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCRsoniya singh
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Roomdivyansh0kumar0
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewasmakika9823
 
Non Text Magic Studio Magic Design for Presentations L&P.pptx
Non Text Magic Studio Magic Design for Presentations L&P.pptxNon Text Magic Studio Magic Design for Presentations L&P.pptx
Non Text Magic Studio Magic Design for Presentations L&P.pptxAbhayThakur200703
 
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...lizamodels9
 
NewBase 22 April 2024 Energy News issue - 1718 by Khaled Al Awadi (AutoRe...
NewBase  22 April  2024  Energy News issue - 1718 by Khaled Al Awadi  (AutoRe...NewBase  22 April  2024  Energy News issue - 1718 by Khaled Al Awadi  (AutoRe...
NewBase 22 April 2024 Energy News issue - 1718 by Khaled Al Awadi (AutoRe...Khaled Al Awadi
 
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In.../:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...lizamodels9
 
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptxBanana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptxgeorgebrinton95
 
Call Girls In Kishangarh Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delh...
Call Girls In Kishangarh Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delh...Call Girls In Kishangarh Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delh...
Call Girls In Kishangarh Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delh...lizamodels9
 
2024 Numerator Consumer Study of Cannabis Usage
2024 Numerator Consumer Study of Cannabis Usage2024 Numerator Consumer Study of Cannabis Usage
2024 Numerator Consumer Study of Cannabis UsageNeil Kimberley
 
Pitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deckPitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deckHajeJanKamps
 
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfIntro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfpollardmorgan
 
Progress Report - Oracle Database Analyst Summit
Progress  Report - Oracle Database Analyst SummitProgress  Report - Oracle Database Analyst Summit
Progress Report - Oracle Database Analyst SummitHolger Mueller
 
Investment analysis and portfolio management
Investment analysis and portfolio managementInvestment analysis and portfolio management
Investment analysis and portfolio managementJunaidKhan750825
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,noida100girls
 

Recently uploaded (20)

Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
Call Girls In Sikandarpur Gurgaon ❤️8860477959_Russian 100% Genuine Escorts I...
 
Best Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting PartnershipBest Practices for Implementing an External Recruiting Partnership
Best Practices for Implementing an External Recruiting Partnership
 
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
Keppel Ltd. 1Q 2024 Business Update  Presentation SlidesKeppel Ltd. 1Q 2024 Business Update  Presentation Slides
Keppel Ltd. 1Q 2024 Business Update Presentation Slides
 
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
Lowrate Call Girls In Laxmi Nagar Delhi ❤️8860477959 Escorts 100% Genuine Ser...
 
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR
(8264348440) 🔝 Call Girls In Mahipalpur 🔝 Delhi NCR
 
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Howrah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Howrah 👉 8250192130 Available With Room
 
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service DewasVip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
Vip Dewas Call Girls #9907093804 Contact Number Escorts Service Dewas
 
Non Text Magic Studio Magic Design for Presentations L&P.pptx
Non Text Magic Studio Magic Design for Presentations L&P.pptxNon Text Magic Studio Magic Design for Presentations L&P.pptx
Non Text Magic Studio Magic Design for Presentations L&P.pptx
 
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
Call Girls In Radisson Blu Hotel New Delhi Paschim Vihar ❤️8860477959 Escorts...
 
NewBase 22 April 2024 Energy News issue - 1718 by Khaled Al Awadi (AutoRe...
NewBase  22 April  2024  Energy News issue - 1718 by Khaled Al Awadi  (AutoRe...NewBase  22 April  2024  Energy News issue - 1718 by Khaled Al Awadi  (AutoRe...
NewBase 22 April 2024 Energy News issue - 1718 by Khaled Al Awadi (AutoRe...
 
KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)KestrelPro Flyer Japan IT Week 2024 (English)
KestrelPro Flyer Japan IT Week 2024 (English)
 
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In.../:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
/:Call Girls In Indirapuram Ghaziabad ➥9990211544 Independent Best Escorts In...
 
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptxBanana Powder Manufacturing Plant Project Report 2024 Edition.pptx
Banana Powder Manufacturing Plant Project Report 2024 Edition.pptx
 
Call Girls In Kishangarh Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delh...
Call Girls In Kishangarh Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delh...Call Girls In Kishangarh Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delh...
Call Girls In Kishangarh Delhi ❤️8860477959 Good Looking Escorts In 24/7 Delh...
 
2024 Numerator Consumer Study of Cannabis Usage
2024 Numerator Consumer Study of Cannabis Usage2024 Numerator Consumer Study of Cannabis Usage
2024 Numerator Consumer Study of Cannabis Usage
 
Pitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deckPitch Deck Teardown: NOQX's $200k Pre-seed deck
Pitch Deck Teardown: NOQX's $200k Pre-seed deck
 
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdfIntro to BCG's Carbon Emissions Benchmark_vF.pdf
Intro to BCG's Carbon Emissions Benchmark_vF.pdf
 
Progress Report - Oracle Database Analyst Summit
Progress  Report - Oracle Database Analyst SummitProgress  Report - Oracle Database Analyst Summit
Progress Report - Oracle Database Analyst Summit
 
Investment analysis and portfolio management
Investment analysis and portfolio managementInvestment analysis and portfolio management
Investment analysis and portfolio management
 
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
BEST Call Girls In Greater Noida ✨ 9773824855 ✨ Escorts Service In Delhi Ncr,
 

Intro to oop.pptx

  • 2. What is Object??? • An object is a noun (or pronoun). ⮚In this universe every thing is noun , so we can conclude that every thing which we are surrounded by is an object. ⮚Are you an Object?? ⮚Each and every object in this universe has some properties. ⮚If u consider yourself as an object, what properties do you have??? ⮚Color , height ,weight , Name , Address etc
  • 3. What is oop Stands for "Object-Oriented Programming." OOP(not Oops!) refers to a programming methodology based on objects, instead of just functions and procedures. Most modern programming languages including Java, C#, and PHP, are object-oriented languages, and many older programming languages now have object-oriented versions. ▪ Object-oriented programming makes it easier for programmers to structure and organize software programs. ▪ Because individual objects can be modified without affecting other aspects of the program. ▪ it is also easier to update and change programs written in object-oriented languages. ▪ As software programs have grown larger over the years, OOP has made developing these large programs more manageable.
  • 4. Pillars Of OOP • There are 4 fundamentals ideas of Object Oriented Programming. They have the wonderful terms: 1. Abstraction 2. Polymorphism 3. Inheritance 4. Encapsulation • One way to remember these is the acronym APIE. Let’s dive into each of them one by one.
  • 5. Abstraction (Hiding Something ) Abstraction is the process of hiding out the working style of an object and showing only the required information of the object in understandable manner. Real World Example: ▪ Consider an example if you are driving a car on a road and suddenly another car cross you what would you do?? ▪ Most probably you will apply brakes . but if you don’t know where is the paddle of brake , can you apply them??? ▪ Exactly not.so information about shape and location of brakes are necessary. ▪ ▪ But is it necessary to you to know about the procedure running behind the car when you apply brakes?? Does it really matter to you. ▪ NO!!!! We are only interested in the end results it is beyond of our interest that what mechanicaloperations are performing. ▪ Same on this pattern abstraction says “show only those things which are relevant and hide unnecessary complexities”.
  • 6. Polymorphism (Many F orm) Poly=many morph= form By name we can come to a conclusion that it's about something with many forms. In OOP it is an ability of an object to take many forms. Real World Example: My name is Owais: I am a Faculty, a brother, a friend, a son, a student depending upon the situation i.e. parameter surrounding me. Similarlyin OOP we can have a function with different form but with same name.
  • 7. Inheritance (sharing) • Inheritance is when an object acquires the property of another object. • Inheritance allows a class (subclass) to acquire the properties and behavior of another class (superclass). • It helps to reuse, customize and enhance the existing code. • So it helps to write a code accurately and reduce the development time. • Real World Example • In our tradition if a father has any property , it will be further divided into his children or we can say that children can have advantages of their father’s possessions. • Same as it is inheritance say that if there is a relation of child and parent between objects.so the properties of parent ca n be inherited by children. • Another example, a scientific calculator is an extended form of Calculator, here Calculator is parent and scientific calculator is Child object.
  • 8. Encapsulation (packing) • Encapsulation means wrapping up data and member function (Method) together into a single unit . • Encapsulation automatically achieve the concept of data hiding providing security to data by making the variable as private and expose the property to access the private data which would be public. • Real World Example
  • 9. Advantages Of OOP • Improved software-developmentproductivity: Object-oriented programming is modular, as it provides separation of duties in object-based program development. • Improved software maintainability: For the reasons mentioned above, object oriented software is also easier to maintain. Since the design is modular, part of the system can be updated in case of issues without a need to make large-scale changes. • Faster development: Reuse enables faster development.Object-oriented programming languages come with rich libraries of objects, and code developed during projects is also reusable in future projects. • Real World Modeling : as we know that oop is based on object and object are the part of real world. So we can easily associate all of our task with real world.
  • 10. Disadvantages Of OOP • Steep learning curve: The thought process involved in object-oriented programming may not be natural for some people, and it can take time to get used to it. It is complex to create programs based on interaction of objects. Some of the key programming techniques, such as inheritance and polymorphism, can be challenging to comprehend initially. • Larger program size: Object-oriented programs typically involve more lines of code than procedural programs. • Slower programs: Object-oriented programs are typically slower than procedurebased programs, as they typically require more instructions to be executed.
  • 11. Object Oriented Design • Object Oriented Design is the concept that forces programmers to plan out their code in order to have a better flowing program. • Technique that focuses on designing the data and the interfaces to it. • Process of creating a system where objects coordinate or interact with each other to accomplish a task
  • 12. Classes Object : • Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors – wagging the tail, barking, eating. An object is an instance of a class. Object can also be referred to as an instance of a class. • An object is one copy of the class. Class : • A class can be defined as a template/blueprint that describes the behavior/state that the object of its type support. • A class or a category is a group of people or things having common characteristics .
  • 13. Messages And Method • A method is a set of steps or instructions, or a procedure to accomplish something • Message is a set of words, a phrase, or statement to convey something • The figure shows how the objects pass messages to each other to fulfill a task. • Here (makeCake,DeliverCake,AcceptCake) are methods while each entity passing messages to another to make the task completed.
  • 14. Modules • To solve complex problems divide the problem into smaller units or modules. • The figure shows the approximate time it took to Bob to deliver the cake when he does everything himself. • This shows that by dividingthe task between multiple people, Bob was able to achieve his goal in almost half the time than he would have done it himself
  • 15. Generalization • Generalizationis a bottom-up approach in which two lower level entities combine to forma higher level entity. In generalization, the higher level entity can also combine with other lower level entity to make further higher level entity.
  • 16. Specializatio n • Specialization is opposite toGeneralization. It is a top-downapproach in which one higher level entity can be broken down into two lower level entity. In specialization, some higher level entities may not have lower-level entity sets at all.
  • 17. Coupling • Coupling is the principle of "separation of concerns". This means that one object doesn't directly change or modify the state or behavior of another object. • Coupling looks at the relationship between objects and how closely connected they are. • A good example of coupling is HTML and CSS. Before CSS, HTML was used for both markup and presentation. This created bloated code that was hard to change and difficult to maintain. With the advent of CSS, HTML became used just for markup, and CSS took over for presentation. This made the code fairly clean and easily changeable. The concerns of presentation and markup were separated. loosely coupled: • Objects that are independent from one another and do not directly modify the state of other objects are said to be loosely coupled. Loose coupling lets the code be more flexible, more changeable, and easier to work with. tightly coupled: • Objects that rely on other objects and can modify the states of other objects are said to be tightly coupled. Tight coupling creates situations where modifying the code of one object also requires changing the code of other objects (also known as a ripple effect). Tightly coupled code is also harder to reuse because it can't be separated. Tightly Coupled Loosely Coupled
  • 18. Cohesion • Cohesion is the principle of being or doing one thing well. In other words, cohesion means grouping together code that contributes to a single task. • Each object should only have one responsibility.Every behaviorof that object should only do one task. Any more than that and you'll have a much harder time making changes to the code. • Code that is organized by functionality and does only one task is said to have high cohesion. Highly cohesive code is reusable, simple, and easy to understand. It also creates objects that are small and focused. • Code that is organized arbitrarily and has multiple tasks is said to have low cohesion. Such code is difficult to understand, maintain, and reuse, and is often complex. It also creates objects that are large and unfocused. • Having high cohesion is generally good, while having low cohesion is generally bad. When writing code, always strive to write highly cohesive code.
  • 19. Classes In OOP • It is similar to structures in C language. Class can also be defined as user defined data type but it also contains functions in it. So, class is basically a blueprint for object. It declare &defines what data variables the object will have and what operations can be performed on the class's object. • In Java, a class is a definition of objects of the same kind. In other words, a class is a blueprint, template, or prototype that defines and describes the static attributes and dynamic behaviors commonto all objects of the same kind.
  • 20. Access Modifiers • There are 4 types of java access modifiers: 1. private 2. default 3. protected 4. Public private access modifier • The private access modifier is accessible only within class. default access modifier • If you don't use any modifier, it is treated as default bydefault. The default modifier is accessible only within package. protected access modifier • The protected access modifier is accessible within package and outside the package but through inheritance only.The protected access modifier can be applied on the data member, method and constructor.It can't be applied on the class. public access modifier • The public access modifier is accessible everywhere. It has the widest scope among all other modifiers.
  • 21. Method • A Java method is a collection of statements that are grouped together to perform an operation. • Defines the behavior of a class • Consists of the actions that an object or instance of a class can perform on the data members Constructor • A constructor is a special method of a class or structure in object-oriented programming that initializes an object of that type. A constructor is an instance method that usually has the same name as the class, and can be used to set the values of the members of an object , either to default or to user-defined values. There are basically two rules defined for the constructor. • Constructor name must be same as its class name • Constructor must have no explicit return type
  • 22. There are two types of constructors : • Default constructor (no-arg constructor) • Parameterized constructor Default Constructor • A constructor is called "Default Constructor" when it doesn't have any parameter. parameterized constructor A constructor which has a specific number of parameters is called parameterized constructor.
  • 23. Level Of Abstraction • The amount of complexity by which a system is viewed or programmed. The higher the level, the less detail. The lower the level, the more detail. The highest level of abstraction is the entire system. There are three level of Abstraction: 1. Top Most Level 2. Next Level 3. Last Level • Example: Let’s say we are storing customer information in a customer table. At Last Level these records can be described as blocks of storage (bytes, gigabytes, terabytes etc.) in memory. These details are often hidden from the programmers. • At the Next Level these records can be described as fields and attributes along with their data types, their relationship among each other can be logically implemented. The programmers generally work at this level because they are aware of such things about database systems. • At Top Most Level, user just interact with system with the help of GUI and enter the details at the screen, they are not aware of how the data is stored and what data is stored; such details are hidden from them.
  • 24. Types of Inheritance we have 5 different types of Inheritance. Namely, 1. Single Inheritance 2. Multiple Inheritance 3. Hierarchical Inheritance 4. Multilevel Inheritance 5. Hybrid Inheritance (also known as Virtual Inheritance) 1. Single Inheritance Parents have only one child at a time OR there should only be a derived class from base class. Parent/Base Child/Derived
  • 25. 2. Multiple Inheritance • In this type of inheritance a single derived class may inherit from two or more than two base classes. 3. Hierarchical Inheritance In this type of inheritance, multiple derived classes inherits from a single base class. means parents have more than one children. parent1 Parent2 Child Parent child1 child2 child3
  • 26. 4. Multilevel Inheritance In Multilevel Inheritancea derived class will be inheriting a parent class and as well as the derived class act as the parent class to other class. 5. Hybrid Inheritance in Java Hybrid Inheritance is the combination of both Single and Multiple Inheritance. Again Hybrid inheritance is also not directly supported in Java only through interface we can achieve this. Flow diagram of the Hybrid inheritance will look like below. As you can ClassA will be acting as the Parent class for ClassB & ClassC and ClassB & ClassC will be acting as Parent for ClassD. parent Child Child Grand Child
  • 27. Problem With Multiple Inheritance The Diamond Problem - a class inherits from two parent classes each of which in turn inherit from a common super class.
  • 28. Interface There are mainly three reasons to use interface. They are given below. 1. Itis used to achieve abstraction. 2. By interface, we can support the functionality of multiple inheritance. 3. Itcan be used to achieve loose coupling.
  • 29. PolyMorphism • If a class has multiple methods having same name but different in parameters, it is known as Method Overloading. • If we have to performonly one operation, having same name of the methods increases the readability of the program. Differentways to overload the method There are two ways to overload the method in java 1. By changing number of arguments 2. By changing the data type By Changing Arguments Int add(int a,int b) int add(int a,int b, int c) By Changing DataTypes int add(int a, int b) { } int add(double a ,double b) { } { { } }
  • 30. Overriding If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in java. Rules for Java Method Overriding 1. method must have same name as in the parent class 2. method must have same parameter as in the parent class. 3. must be IS-A relationship (inheritance).
  • 31. Difference between method overloading and method overriding
  • 32. Replacement & Refinement Replacement : When the child class completely overrides the parent class method implementation. Refinement : When the child class includes the functionality of the parent class version of the overridden method within its own version.
  • 33. Abstract Method • An abstract method is one which is declared inside parent class but not implemented there.
  • 34. pattern • In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design . A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations. Design patterns • Design patterns in software are strategies which are language-independent and used for solving commonly encountered object-oriented design problems. Documenting patterns serves two important purposes: • It speeds up the process of finding a solution when another problem with similar characteristics is encountered. • Giving names to patterns allows programmers to use a common vocabulary to discuss design alternatives.
  • 35. Factory Pattern • creates objects without exposing the instantiation logic to the client. • refers to the newly created object through a common interface The implementation is really simple The client needs a product, but instead of creating it directly using the new operator, it asks the factory object for a new product, providing the information about the type of object it needs. • The factory instantiates a new concrete product and then returns to the client the newly created product(casted to abstract product class). • The client uses the products as abstract products without being aware about their concrete implementation.
  • 36. Singleton Design Pattern • Ensure a class has only one instance, and provide a global point of access to it. • The Singleton pattern ensures that a class has only one instance and provides a global point of access to that instance. • Example • The office of the President of the United States is a Singleton. The United States Constitution specifies the means by which a president is elected, limits the term of office, and defines the order of succession. As a result, there can be at most one active president at any given time. Regardless of the personal identity of the active president, the title, "The President of the United States" is a global point of access that identifies the person in the office.
  • 37. Composite Design Pattern composite objects: • objects that contain other objects; for example, a drawing may be composed of graphic primitives, such as lines, circles, rectangles, text, and so on. • Composite pattern is used where we need to treat a group of objects in similar way as a single object. Composite pattern composes objects in term of a tree structure to represent part as well as whole hierarchy. Example In an organization, It have general managers and under general managers, there can be managers and under managers there can be developers. Now you can set a tree structure and ask each node to perform common operation like getSalary(). Composite design pattern treats each node in two ways: 1) Composite – Composite means it can have other objects below it. 2) leaf – leaf means it has no objects below it.
  • 38. Decorator pattern • Decorator pattern is used to dynamically add or remove responsibilities to an object without affecting other objects. • Decorator pattern allows a user to add new functionality to an existing object without altering its structure. • assault gun is a deadly weapon on it's own. But you can apply certain "decorations" to make it more accurate, silent and devastating.
  • 39. Proxy Pattern • In proxy pattern, a class represents functionality of another class. • When creating an object is too expensive in terms of time or memory. • To postpone creation of an object until it is actually needed. • When loading a large image which can be time consuming. • For example, you save your money in bank in form of rupees.but when you want to withdraw money you have to write a check. It means check is not it self money but having functionality of money.
  • 40. Frameworks • In OOP, a framework is a set of reusable software components or classes that form the basis of an application. • it makes it easier to work with complex technologies • it ties together a bunch of discrete objects/components into something more useful • it forces the team (or just me) to implement code in a way that promotes consistent coding, fewer bugs, and more flexible applications • everyone can easily test and debug the code, even code that they didn't write • A software framework is an abstraction in which software providing generic functionality can be selectively changed by additional user-written code, thus providing application-specific software.