SlideShare a Scribd company logo
1 of 20
OOP With Java
Feature: Object oriented
programming
2
Terms
 Object
 Class
 Abstraction
 Encapsulation
 Inheritance
Object-oriented programming is a method of implementation in
which programs are organized as cooperative collections of
objects, each of which represents an instance of some class,
and whose classes are all members of a hierarchy of classes
united via inheritance relationships.
- Grady Booch
Object
3
 A thing in a real world that can be either physical or
conceptual. An object in object oriented programming
can be physical or conceptual.
 Conceptual objects are entities that are not tangible
in the way real-world physical objects are.
 Bulb is a physical object. While college is a
conceptual object.
 Conceptual objects may not have a real world
equivalent. For instance, a Stack object in a program.
 Object has state and behavior.
What is the state and behavior of this bulb?
Attributes and Operations
4
 The object’s state is determined by the value of
its properties or attributes.
 Properties or attributes  member variables or
data members
 The object’s behaviour is determined by the
operations that it provides.
 Operations  member functions or methods
A bulb:
1. It’s a real-world thing.
2. Can be switched on to generate light and switched off.
3. It has real features like the glass covering, filament and holder.
4. It also has conceptual features like power.
5. A bulb manufacturing factory produces many bulbs based on a basic
description / pattern of what a bulb is.
object
methods
member variables
class
Putting it together
5
Class
6
 A class is a construct created in object-oriented
programming languages that enables creation of
objects.
 Also sometimes called blueprint or template or
prototype from which objects are created.
 It defines members (variables and methods).
 A class is an abstraction.
Abstraction
7
 Abstraction is the process of taking only a set of
essential characteristics from something.
 Example
 For a Doctor you are a Patient
 Name, Age, Old medical records
 For a Teacher you are a Student
 Name, Roll Number/RegNo, Education background
 For HR Staff you are ______________
 ___________,_____________,___________
You
Abstraction denotes essential characteristics of an object that
distinguish it from all other kinds of objects and thus provide crisply
defined conceptual boundaries, relative to the perspective of the
viewer.
-Grady Booch
Encapsulation
8
 Encapsulation is binding data and operations that
work on data together in a construct.
 Encapsulation involves Data and Implementation
Hiding.
Would you like it if your CPU is given
to you like this?
What are the problems if it were given
to you like this?
Encapsulation is the process of compartmentalizing the elements of
abstraction that constitute its structure and behavior; encapsulation
serves to separate the contractual interface of an abstraction and its
implementation.
- Grady Booch
Inheritance
9
 Defines IS-A relationship between classes
 Cat IS-A Animal
 Car IS-A Vehicle
 Rose IS-A Flower
Inheritance defines relationship among classes, wherein one class
share structure or behavior defined in one or more classes.
- Grady Booch
Inheritance hierarchy
10
Animal
legs
tail
run()
Dog
bark()
Tiger
growl()
CatFamily
paddedClaws
whiskers
Cat
meow()
Single -level
Multi-level
11
 Many Object-orientated language does not support
this type of inheritance.
 Java, C# are the examples of object-oriented
language that does not support multiple inheritance
through classes.
Mammal Bird
Bat
Multiple inheritance
Generalization and Specialization
12
WildAnimal
legs
tail
run()
Tiger
growl()
CatFamily
paddedClaws
whiskers
Cat
meow()
Specialization
Generalization
Activity: match the following
Super class Subclass
13
 Fruit
 Library
 Cat
 Bird
 Parrot
 Music
 Tiger
 Books
 Apple
 Mango
Activity
14
 Given the following classes. Can you form
inheritance hierarchy?
 Person
 Teacher
 Student
 HOD
 Typist
 Clerk
 What are the common members shared ?
Polymorphism
15
A concept in type theory, according to which a name (such
as a
variable declaration) may denote objects of many different
classes that are related by some common superclass; thus,
any object denoted by this name is able to respond to some
common set of operations in different ways.
- Grady Booch
Polymorphism example
16
Flower
fragrance()
Rose
fragrance()
Sunflower
fragrance()
FlowerVase
Flower f[]
smell()
17
 You pick a rose from the vase and
smell it?
 What fragrance do you expect?
Flower
fragrance()
Rose
fragrance()
Sunflower
fragrance()
FlowerVase
Flower f[]
smell()
f[0]= rose;
f[1]= sunflower;
….
f[0]. fragrance();
f[1]. fragrance();
…
Exercise: Inheritance
18
 Among the classes that you identified, are there
any classes that you can relate via inheritance.
(Hint: are there any classes which have common
attributes/methods that can be moved up the
hierarchy)
Revisiting definition
19
Object-oriented programming is a method of implementation in which programs
are organized as cooperative collections of objects, each of which represents an
instance of some class, and whose classes are all members of a hierarchy of
classes united via inheritance relationships.
Rama
123
Student
• -roll: long
• + read(): boolean
B.Tech
2010
Course
• -name: String
• -year: Date
• + display(): void
• + enroll(Student): boolean
enroll()
Person
• -name: String
• + display(): void
Summary
20
 Object-oriented programming is a method of
implementation in which programs are organized as
cooperative collections of objects.
 The object’s state is determined by the value of its
properties and its behavior is determined by the operations
that it provides.
 Abstraction is the process of taking only a set of essential
characteristics from something.
 Encapsulation is binding data and operations that work on
data together in a construct.
 Inheritance defines relationship among classes, wherein
one class share structure or behavior defined in one or
more classes.

More Related Content

Similar to Oop in java.pptx

Object oriented programming mine normalized
Object oriented programming   mine normalizedObject oriented programming   mine normalized
Object oriented programming mine normalizedManish Kungwani
 
JAVA - Oops Concept.pptx
JAVA - Oops Concept.pptxJAVA - Oops Concept.pptx
JAVA - Oops Concept.pptxayankamila005
 
Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindiappsdevelopment
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Techglyphs
 
Paradigms.pptx
Paradigms.pptxParadigms.pptx
Paradigms.pptxaikomo1
 
Object oriented software engineering concepts
Object oriented software engineering conceptsObject oriented software engineering concepts
Object oriented software engineering conceptsKomal Singh
 
L ab # 07
L ab # 07L ab # 07
L ab # 07Mr SMAK
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented conceptschristradus
 
SE_Lec 06_Object Oriented Analysis and Design
SE_Lec 06_Object Oriented Analysis and DesignSE_Lec 06_Object Oriented Analysis and Design
SE_Lec 06_Object Oriented Analysis and DesignAmr E. Mohamed
 
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 And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) LanguagesObject And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) LanguagesJessica Deakin
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming conceptPina Parmar
 

Similar to Oop in java.pptx (20)

Object oriented programming mine normalized
Object oriented programming   mine normalizedObject oriented programming   mine normalized
Object oriented programming mine normalized
 
JAVA - Oops Concept.pptx
JAVA - Oops Concept.pptxJAVA - Oops Concept.pptx
JAVA - Oops Concept.pptx
 
2.oop concept
2.oop concept2.oop concept
2.oop concept
 
Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1Synapseindia strcture of dotnet development part 1
Synapseindia strcture of dotnet development part 1
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1
 
Paradigms.pptx
Paradigms.pptxParadigms.pptx
Paradigms.pptx
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
OOP Lesson 2.pptx
OOP Lesson 2.pptxOOP Lesson 2.pptx
OOP Lesson 2.pptx
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
OOPS ABAP.docx
OOPS ABAP.docxOOPS ABAP.docx
OOPS ABAP.docx
 
Ooad 2
Ooad 2Ooad 2
Ooad 2
 
Ooad
OoadOoad
Ooad
 
Object oriented software engineering concepts
Object oriented software engineering conceptsObject oriented software engineering concepts
Object oriented software engineering concepts
 
L ab # 07
L ab # 07L ab # 07
L ab # 07
 
Object oriented concepts
Object oriented conceptsObject oriented concepts
Object oriented concepts
 
SE_Lec 06_Object Oriented Analysis and Design
SE_Lec 06_Object Oriented Analysis and DesignSE_Lec 06_Object Oriented Analysis and Design
SE_Lec 06_Object Oriented Analysis and Design
 
Ashish oot
Ashish ootAshish oot
Ashish oot
 
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...
 
Object And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) LanguagesObject And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) Languages
 
Object oriented programming concept
Object oriented programming conceptObject oriented programming concept
Object oriented programming concept
 

Recently uploaded

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 

Recently uploaded (20)

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 

Oop in java.pptx

  • 2. Feature: Object oriented programming 2 Terms  Object  Class  Abstraction  Encapsulation  Inheritance Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of a hierarchy of classes united via inheritance relationships. - Grady Booch
  • 3. Object 3  A thing in a real world that can be either physical or conceptual. An object in object oriented programming can be physical or conceptual.  Conceptual objects are entities that are not tangible in the way real-world physical objects are.  Bulb is a physical object. While college is a conceptual object.  Conceptual objects may not have a real world equivalent. For instance, a Stack object in a program.  Object has state and behavior. What is the state and behavior of this bulb?
  • 4. Attributes and Operations 4  The object’s state is determined by the value of its properties or attributes.  Properties or attributes  member variables or data members  The object’s behaviour is determined by the operations that it provides.  Operations  member functions or methods
  • 5. A bulb: 1. It’s a real-world thing. 2. Can be switched on to generate light and switched off. 3. It has real features like the glass covering, filament and holder. 4. It also has conceptual features like power. 5. A bulb manufacturing factory produces many bulbs based on a basic description / pattern of what a bulb is. object methods member variables class Putting it together 5
  • 6. Class 6  A class is a construct created in object-oriented programming languages that enables creation of objects.  Also sometimes called blueprint or template or prototype from which objects are created.  It defines members (variables and methods).  A class is an abstraction.
  • 7. Abstraction 7  Abstraction is the process of taking only a set of essential characteristics from something.  Example  For a Doctor you are a Patient  Name, Age, Old medical records  For a Teacher you are a Student  Name, Roll Number/RegNo, Education background  For HR Staff you are ______________  ___________,_____________,___________ You Abstraction denotes essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer. -Grady Booch
  • 8. Encapsulation 8  Encapsulation is binding data and operations that work on data together in a construct.  Encapsulation involves Data and Implementation Hiding. Would you like it if your CPU is given to you like this? What are the problems if it were given to you like this? Encapsulation is the process of compartmentalizing the elements of abstraction that constitute its structure and behavior; encapsulation serves to separate the contractual interface of an abstraction and its implementation. - Grady Booch
  • 9. Inheritance 9  Defines IS-A relationship between classes  Cat IS-A Animal  Car IS-A Vehicle  Rose IS-A Flower Inheritance defines relationship among classes, wherein one class share structure or behavior defined in one or more classes. - Grady Booch
  • 11. 11  Many Object-orientated language does not support this type of inheritance.  Java, C# are the examples of object-oriented language that does not support multiple inheritance through classes. Mammal Bird Bat Multiple inheritance
  • 13. Activity: match the following Super class Subclass 13  Fruit  Library  Cat  Bird  Parrot  Music  Tiger  Books  Apple  Mango
  • 14. Activity 14  Given the following classes. Can you form inheritance hierarchy?  Person  Teacher  Student  HOD  Typist  Clerk  What are the common members shared ?
  • 15. Polymorphism 15 A concept in type theory, according to which a name (such as a variable declaration) may denote objects of many different classes that are related by some common superclass; thus, any object denoted by this name is able to respond to some common set of operations in different ways. - Grady Booch
  • 17. 17  You pick a rose from the vase and smell it?  What fragrance do you expect? Flower fragrance() Rose fragrance() Sunflower fragrance() FlowerVase Flower f[] smell() f[0]= rose; f[1]= sunflower; …. f[0]. fragrance(); f[1]. fragrance(); …
  • 18. Exercise: Inheritance 18  Among the classes that you identified, are there any classes that you can relate via inheritance. (Hint: are there any classes which have common attributes/methods that can be moved up the hierarchy)
  • 19. Revisiting definition 19 Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of a hierarchy of classes united via inheritance relationships. Rama 123 Student • -roll: long • + read(): boolean B.Tech 2010 Course • -name: String • -year: Date • + display(): void • + enroll(Student): boolean enroll() Person • -name: String • + display(): void
  • 20. Summary 20  Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects.  The object’s state is determined by the value of its properties and its behavior is determined by the operations that it provides.  Abstraction is the process of taking only a set of essential characteristics from something.  Encapsulation is binding data and operations that work on data together in a construct.  Inheritance defines relationship among classes, wherein one class share structure or behavior defined in one or more classes.