SlideShare a Scribd company logo
Welcome To Our
Presentation
TOPIC:
Object Oriented Programming(OOP)
 Name: DM.Mehedi Hasan Abid
 Dept: CSE
Contents
• Introduction to Object Oriented Programming
• Encapsulation
• Association
• Inheritance
• Polymorphism
• Exception Handling
• Abstract Class and Interface.
• Advantage Object Oriented Programming
Introduction to Object Oriented
Programming
• An object is a unit of code that is responsible to accomplish a particular
task located inside code. In other way, we can tell that an object is a data
structure which solves a particular problem. To do its work, an object may
need some data and methods.
• From books we might have learned how to use classes (class library) or even learned how to write our own
classes and making object from them. But OOP is more than these. Designing beautiful classes, keep them
simple, make them for reusability and easy to change is the ultimate goal of OO code and design.
Object:
A thing that has identity, state, and behavior
• Identity: a distinguished instance of a class
• State: collection of values for its variables
• Behavior: capability to execute methods
* variables and methods are defined in a class.
Class:
In object-oriented programming, a class is an extensible program-code-template for creating objects,
providing initial values for state (member variables) and implementations of behavior (member functions or
methods).
Animal
Dog Cat Fish
• Encapsulation (Information Hiding):
• When creating new data types (classes) the details of the actual data and the way operations work is hidden
from the other programmers who will use those new data types
• Unnecessary implementation details should be hidden from the user
• In Java/C++, use classes and access modifiers (public, private, protected)
• Example: microwave, radio, iPad.
Example:
public class RunEncap{
public static void main(String args[]){
EncapTest encap = new EncapTest();
encap.setName(“MH Abid");
encap.setAge(22);
encap.setIdNum("151-51-226");
System.out.print("Name : " +
encap.getName() + " Age : " + encap.getAge());
}
}
OUTPUT:
Name : MH Abid Age : 22
Association:
• It represents a relationship between two or more objects where all objects have their own lifecycle
and there is no owner.
• Let’s take an example of relationship between Teacher and Student. Multiple students can associate
with a single teacher and a single student can associate with multiple teachers. Both object can be
created and deleted independently.
Here is an example of
“Association”
from our project.
In the picture we can see that in
the “Main”class we made an
object of “HomePage and
Sample”class.
• Inheritance
• In object-oriented programming, inheritance enables new objects to take on the properties of existing
objects. A class that is used as the basis for inheritance is called a superclass or base class. A class that
inherits from a superclass is called a subclass or derived class.
• Every Employee has a name, age, and birthday method as well as a salary and a pay
method.
class Person {
String name;
int age;
String id;
void birthday () {
}
}
class Employee extends Person {
double salary;
void pay () {
}
}
•Polymorphism:
“Poly”= Many, “Morphism”= forms
• Polymorphism = ability to take more than one form (objects have more than one type)
• A class can be used through its parent interface
• A child class may override some of the behaviors of the parent class.
Two types –
 Compile time polymorphism(Overloading).
 Run time polymorphism(Overriding).
• Compile time polymorphism:
• Compile time Polymorphism ( or Static polymorphism) Compile time polymorphism is nothing but the
method overloading in java.
• Run time polymorphism:
• The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a
child class object. Dynamic Binding/Runtime Polymorphism : Run time Polymorphism also known as
method overriding.
Exception Handling:
• An exception is a problem that arises during the execution of a program. A exception is a
response to an exceptional circumstance that arises while a program is running, such as an
attempt to divide by zero.
• Exceptions provide a way to transfer control from one part of a program to another.
exception handling keywords: try, catch, throw ,throws and finally.
class Exception
{
public static void main(String args[])
{
int a = 42 / 0;
}
}
• try: A try block identifies a block of code for which particular exceptions will be activated. It's followed by
one or more catch blocks.
• catch: A program catches an exception with an exception handler at the place in a program where you want
to handle the problem. The catch keyword indicates the catching of an exception.
• throw: throw keyword is used to throw an exception explicitly. Only object of Throwable class or its sub
classes can be thrown. Program execution stops on encountering throw statement.
Throws:
Any method capable of causing
exceptions must list all the exceptions
possible during its execution, so that
anyone calling that method gets a prior
knowledge about which exceptions to
handle. A method can do so by using
the throws keyword.
Finally:
A finally keyword is used to create a
block of code that follows a try
block. A finally block of code
always executes whether or not
exception has occurred.
• Abstract Class :
• Classes which contain one or more abstract methods or abstract properties, such methods or properties do
not provide implementation.
• Syntax :
• abstract class class name { }
• Abstract method:
• Method that are declared without any body within an abstract class is known as abstract method. The
method body will be defined by its subclass. Abstract method can never be final and static. Any class that
extends an abstract class must implement all the abstract methods declared by the super class.
• Syntax :
• Abstract return_typefunction_name ();
Output will be Ferrari moves
firster than all cars
• Interface:
• An interface is a description of the actions that an object can do. For example when you flip a light switch,
the light goes on, you don't care how, just that it does. In Object Oriented Programming, an Interface is a
description of all functions that an object must have in order to be an "X“.
• Syntax:
• interface interface name { }
Interface
Implementation
This is how a class implements an
interface. It has to provide the body
of all the methods that are declared
in interface.
Note: class implements interface but
an interface extends another
interface.
Difference between abstract class and Interface
Advantages of OOP
• • Simplicity: software objects model real world objects, so the complexity is reduced
and the program structure is very clear;
• • Modularity: each object forms a separate entity whose internal workings are
decoupled from other parts of the system;
• • Extensibility: adding new features or responding to changing operating
environments can be solved by
• • Maintainability: objects can be maintained separately, making locating and fixing
problems easier;
• •Re-usability: objects can be reused in different programs
THANK YOU
Ad

More Related Content

What's hot (20)

Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in java
Elizabeth alexander
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Oops in java
Oops in javaOops in java
Oops in java
baabtra.com - No. 1 supplier of quality freshers
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
BG Java EE Course
 
Java oops and fundamentals
Java oops and fundamentalsJava oops and fundamentals
Java oops and fundamentals
javaease
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
baabtra.com - No. 1 supplier of quality freshers
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
ppd1961
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
Rick Ogden
 
Oop
OopOop
Oop
志明 陳
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
Skillwise Group
 
Object oriented programming concepts
Object oriented programming conceptsObject oriented programming concepts
Object oriented programming concepts
rahuld115
 
Advance oops concepts
Advance oops conceptsAdvance oops concepts
Advance oops concepts
Sangharsh agarwal
 
Introduction to OOP(in java) BY Govind Singh
Introduction to OOP(in java)  BY Govind SinghIntroduction to OOP(in java)  BY Govind Singh
Introduction to OOP(in java) BY Govind Singh
prabhat engineering college
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using Java
Glenn Guden
 
Java Programming Paradigms Chapter 1
Java Programming Paradigms Chapter 1 Java Programming Paradigms Chapter 1
Java Programming Paradigms Chapter 1
Sakthi Durai
 
Oop basic overview
Oop basic overviewOop basic overview
Oop basic overview
Deborah Akuoko
 
Introduction to java and oop
Introduction to java and oopIntroduction to java and oop
Introduction to java and oop
baabtra.com - No. 1 supplier of quality freshers
 
Basic concept of OOP's
Basic concept of OOP'sBasic concept of OOP's
Basic concept of OOP's
Prof. Dr. K. Adisesha
 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in java
Elizabeth alexander
 
Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)Basic Concepts of OOPs (Object Oriented Programming in Java)
Basic Concepts of OOPs (Object Oriented Programming in Java)
Michelle Anne Meralpis
 
Java oops and fundamentals
Java oops and fundamentalsJava oops and fundamentals
Java oops and fundamentals
javaease
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
ppd1961
 
Object Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaionObject Oriented Programing JAVA presentaion
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
Beginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHPBeginners Guide to Object Orientation in PHP
Beginners Guide to Object Orientation in PHP
Rick Ogden
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
Skillwise Group
 
Object oriented programming concepts
Object oriented programming conceptsObject oriented programming concepts
Object oriented programming concepts
rahuld115
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using Java
Glenn Guden
 
Java Programming Paradigms Chapter 1
Java Programming Paradigms Chapter 1 Java Programming Paradigms Chapter 1
Java Programming Paradigms Chapter 1
Sakthi Durai
 

Similar to Object oriented programming (20)

Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
colleges
 
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.pptJava Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
akashsachu221
 
Class and Objects in python programming.pptx
Class and Objects in python programming.pptxClass and Objects in python programming.pptx
Class and Objects in python programming.pptx
Rajtherock
 
Presentation 4th
Presentation 4thPresentation 4th
Presentation 4th
Connex
 
UNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year csUNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year cs
javed75
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rd
Connex
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
Saiful Islam Sany
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
Sudip Simkhada
 
oop.pptx
oop.pptxoop.pptx
oop.pptx
KabitaParajuli3
 
01-introductionto Object ooriented Programming in JAVA CS.ppt
01-introductionto Object ooriented Programming in JAVA CS.ppt01-introductionto Object ooriented Programming in JAVA CS.ppt
01-introductionto Object ooriented Programming in JAVA CS.ppt
GESISLAMIAPATTOKI
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
Ahmed Farag
 
The View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptThe View object orientated programming in Lotuscript
The View object orientated programming in Lotuscript
Bill Buchan
 
Software enginnnering introduction (2).pptx
Software enginnnering introduction (2).pptxSoftware enginnnering introduction (2).pptx
Software enginnnering introduction (2).pptx
parmidakhrz02
 
Lesson 13 object and class
Lesson 13 object and classLesson 13 object and class
Lesson 13 object and class
MLG College of Learning, Inc
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) Introduction
SamuelAnsong6
 
Object Oriented Programming Class and Objects
Object Oriented Programming Class and ObjectsObject Oriented Programming Class and Objects
Object Oriented Programming Class and Objects
rubini8582
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
Sagar Verma
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
Geophery sanga
 
Python programming Concepts (Functions, classes and Oops concept
Python programming Concepts (Functions, classes and Oops conceptPython programming Concepts (Functions, classes and Oops concept
Python programming Concepts (Functions, classes and Oops concept
Lipika Sharma
 
Summer Training Project On C++
Summer Training Project On  C++Summer Training Project On  C++
Summer Training Project On C++
KAUSHAL KUMAR JHA
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
colleges
 
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.pptJava Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
Java Fundamentalojhgghjjjjhhgghhjjjjhhj.ppt
akashsachu221
 
Class and Objects in python programming.pptx
Class and Objects in python programming.pptxClass and Objects in python programming.pptx
Class and Objects in python programming.pptx
Rajtherock
 
Presentation 4th
Presentation 4thPresentation 4th
Presentation 4th
Connex
 
UNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year csUNIT-IV WT web technology for 1st year cs
UNIT-IV WT web technology for 1st year cs
javed75
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rd
Connex
 
01-introductionto Object ooriented Programming in JAVA CS.ppt
01-introductionto Object ooriented Programming in JAVA CS.ppt01-introductionto Object ooriented Programming in JAVA CS.ppt
01-introductionto Object ooriented Programming in JAVA CS.ppt
GESISLAMIAPATTOKI
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
Ahmed Farag
 
The View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptThe View object orientated programming in Lotuscript
The View object orientated programming in Lotuscript
Bill Buchan
 
Software enginnnering introduction (2).pptx
Software enginnnering introduction (2).pptxSoftware enginnnering introduction (2).pptx
Software enginnnering introduction (2).pptx
parmidakhrz02
 
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) IntroductionObject Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) Introduction
SamuelAnsong6
 
Object Oriented Programming Class and Objects
Object Oriented Programming Class and ObjectsObject Oriented Programming Class and Objects
Object Oriented Programming Class and Objects
rubini8582
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
Sagar Verma
 
object oriented programing lecture 1
object oriented programing lecture 1object oriented programing lecture 1
object oriented programing lecture 1
Geophery sanga
 
Python programming Concepts (Functions, classes and Oops concept
Python programming Concepts (Functions, classes and Oops conceptPython programming Concepts (Functions, classes and Oops concept
Python programming Concepts (Functions, classes and Oops concept
Lipika Sharma
 
Summer Training Project On C++
Summer Training Project On  C++Summer Training Project On  C++
Summer Training Project On C++
KAUSHAL KUMAR JHA
 
Ad

Recently uploaded (20)

Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025Stein, Hunt, Green letter to Congress April 2025
Stein, Hunt, Green letter to Congress April 2025
Mebane Rash
 
How to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POSHow to Manage Opening & Closing Controls in Odoo 17 POS
How to Manage Opening & Closing Controls in Odoo 17 POS
Celine George
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
Social Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy StudentsSocial Problem-Unemployment .pptx notes for Physiotherapy Students
Social Problem-Unemployment .pptx notes for Physiotherapy Students
DrNidhiAgarwal
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptxSCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
SCI BIZ TECH QUIZ (OPEN) PRELIMS XTASY 2025.pptx
Ronisha Das
 
GDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptxGDGLSPGCOER - Git and GitHub Workshop.pptx
GDGLSPGCOER - Git and GitHub Workshop.pptx
azeenhodekar
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
To study the nervous system of insect.pptx
To study the nervous system of insect.pptxTo study the nervous system of insect.pptx
To study the nervous system of insect.pptx
Arshad Shaikh
 
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsepulse  ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulse
sushreesangita003
 
The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...The ever evoilving world of science /7th class science curiosity /samyans aca...
The ever evoilving world of science /7th class science curiosity /samyans aca...
Sandeep Swamy
 
Sinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_NameSinhala_Male_Names.pdf Sinhala_Male_Name
Sinhala_Male_Names.pdf Sinhala_Male_Name
keshanf79
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Handling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptxHandling Multiple Choice Responses: Fortune Effiong.pptx
Handling Multiple Choice Responses: Fortune Effiong.pptx
AuthorAIDNationalRes
 
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam SuccessUltimate VMware 2V0-11.25 Exam Dumps for Exam Success
Ultimate VMware 2V0-11.25 Exam Dumps for Exam Success
Mark Soia
 
Ad

Object oriented programming

  • 3.  Name: DM.Mehedi Hasan Abid  Dept: CSE
  • 4. Contents • Introduction to Object Oriented Programming • Encapsulation • Association • Inheritance • Polymorphism • Exception Handling • Abstract Class and Interface. • Advantage Object Oriented Programming
  • 5. Introduction to Object Oriented Programming • An object is a unit of code that is responsible to accomplish a particular task located inside code. In other way, we can tell that an object is a data structure which solves a particular problem. To do its work, an object may need some data and methods. • From books we might have learned how to use classes (class library) or even learned how to write our own classes and making object from them. But OOP is more than these. Designing beautiful classes, keep them simple, make them for reusability and easy to change is the ultimate goal of OO code and design.
  • 6. Object: A thing that has identity, state, and behavior • Identity: a distinguished instance of a class • State: collection of values for its variables • Behavior: capability to execute methods * variables and methods are defined in a class. Class: In object-oriented programming, a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods). Animal Dog Cat Fish
  • 7. • Encapsulation (Information Hiding): • When creating new data types (classes) the details of the actual data and the way operations work is hidden from the other programmers who will use those new data types • Unnecessary implementation details should be hidden from the user • In Java/C++, use classes and access modifiers (public, private, protected) • Example: microwave, radio, iPad.
  • 8. Example: public class RunEncap{ public static void main(String args[]){ EncapTest encap = new EncapTest(); encap.setName(“MH Abid"); encap.setAge(22); encap.setIdNum("151-51-226"); System.out.print("Name : " + encap.getName() + " Age : " + encap.getAge()); } } OUTPUT: Name : MH Abid Age : 22
  • 9. Association: • It represents a relationship between two or more objects where all objects have their own lifecycle and there is no owner. • Let’s take an example of relationship between Teacher and Student. Multiple students can associate with a single teacher and a single student can associate with multiple teachers. Both object can be created and deleted independently.
  • 10. Here is an example of “Association” from our project. In the picture we can see that in the “Main”class we made an object of “HomePage and Sample”class.
  • 11. • Inheritance • In object-oriented programming, inheritance enables new objects to take on the properties of existing objects. A class that is used as the basis for inheritance is called a superclass or base class. A class that inherits from a superclass is called a subclass or derived class.
  • 12. • Every Employee has a name, age, and birthday method as well as a salary and a pay method. class Person { String name; int age; String id; void birthday () { } } class Employee extends Person { double salary; void pay () { } }
  • 13. •Polymorphism: “Poly”= Many, “Morphism”= forms • Polymorphism = ability to take more than one form (objects have more than one type) • A class can be used through its parent interface • A child class may override some of the behaviors of the parent class. Two types –  Compile time polymorphism(Overloading).  Run time polymorphism(Overriding).
  • 14. • Compile time polymorphism: • Compile time Polymorphism ( or Static polymorphism) Compile time polymorphism is nothing but the method overloading in java.
  • 15. • Run time polymorphism: • The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. Dynamic Binding/Runtime Polymorphism : Run time Polymorphism also known as method overriding.
  • 16. Exception Handling: • An exception is a problem that arises during the execution of a program. A exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. • Exceptions provide a way to transfer control from one part of a program to another. exception handling keywords: try, catch, throw ,throws and finally. class Exception { public static void main(String args[]) { int a = 42 / 0; } }
  • 17. • try: A try block identifies a block of code for which particular exceptions will be activated. It's followed by one or more catch blocks. • catch: A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception. • throw: throw keyword is used to throw an exception explicitly. Only object of Throwable class or its sub classes can be thrown. Program execution stops on encountering throw statement.
  • 18. Throws: Any method capable of causing exceptions must list all the exceptions possible during its execution, so that anyone calling that method gets a prior knowledge about which exceptions to handle. A method can do so by using the throws keyword.
  • 19. Finally: A finally keyword is used to create a block of code that follows a try block. A finally block of code always executes whether or not exception has occurred.
  • 20. • Abstract Class : • Classes which contain one or more abstract methods or abstract properties, such methods or properties do not provide implementation. • Syntax : • abstract class class name { } • Abstract method: • Method that are declared without any body within an abstract class is known as abstract method. The method body will be defined by its subclass. Abstract method can never be final and static. Any class that extends an abstract class must implement all the abstract methods declared by the super class. • Syntax : • Abstract return_typefunction_name ();
  • 21. Output will be Ferrari moves firster than all cars
  • 22. • Interface: • An interface is a description of the actions that an object can do. For example when you flip a light switch, the light goes on, you don't care how, just that it does. In Object Oriented Programming, an Interface is a description of all functions that an object must have in order to be an "X“. • Syntax: • interface interface name { }
  • 23. Interface Implementation This is how a class implements an interface. It has to provide the body of all the methods that are declared in interface. Note: class implements interface but an interface extends another interface.
  • 24. Difference between abstract class and Interface
  • 25. Advantages of OOP • • Simplicity: software objects model real world objects, so the complexity is reduced and the program structure is very clear; • • Modularity: each object forms a separate entity whose internal workings are decoupled from other parts of the system; • • Extensibility: adding new features or responding to changing operating environments can be solved by • • Maintainability: objects can be maintained separately, making locating and fixing problems easier; • •Re-usability: objects can be reused in different programs