SlideShare a Scribd company logo
1 of 14
Object Oriented Concepts &
Principles
VIKAS SHARMA, DEPARTMENT OF COMPUTERSCIENCE
AGRASEN MAHAVIDYALAYA RAIPUR
Objects
• Object: Complex data type that has an identity,
contains other data types called attributes and
modules of code called operations or methods
• Attributes and associated values are hidden inside
the object.
• Any object that wants to obtain or change a value
associated with other object, must do so by
sending a message to one of the objects (invoking
a method)
Objects
Age: 35
methods (methods)
Attributes (values)
Set_salary (20)
Object: woman
method:
Set_salary
employer
Get_age
friend
Salary: 10
Encapsulation
• Each objects methods manage it’s own attributes.
• This is also known as hiding.
• An object A can learn about the values of
attributes of another object B, only by invoking
the corresponding method (message) associated to
the object B.
• Example:
– Class: Lady
– Attributes: Age, salary
– Methods: get_age, set_salary
Procedural vs. Object-Oriented
Procedural application OO-application
DATA
Line of code
Line of code
Line of code
Data is stored
independent
of application
Each object is independent of
the others
Classes
• Classes are templates that have methods and
attribute names and type information, but no
actual values!
• Objects are generated by these classes and they
actually contain values.
• We design an application at the class level.
• When the system is running objects are created by
classes as they are needed to contain state
information.
• When objects are no longer needed by the
application, they are eliminated.
Class & Objects
Name
Number
CLASS: Furniture
methods: Example
ChangeNumber
Objects:
Desk
123445
ChairA
32143
ChairB
45687
Message Passing & Associations
• Methods are associated with classes but classes
don’t send messages to each other.
• Objects send messages.
• A static diagram (class diagram) shows classes
and the logical associations between classes, it
doesn´t show the movement of messages.
• An association between two classes means that
the objects of the two classes can send messages to
each other.
• Aggregation: when an object contains other
objects ( a part-whole relationship)
Class Hierarchies & Inheritance
• Classes can be arranged in hierarchies so
that more classes inherit attributes and
methods from more abstract classes
• Class hierarchy diagrams
Class: Chair
subclasses
Chair Type A Chair Type B
Class Inheritance & Specialization
Class: Furniture
Attribute A1
Method A1
Class: Chairs
[Attribute A1]
Attribute B1
[Method A1]
Method B1
Class: Executive Chairs
[Attribute A1]
[Attribute B1]
Attribute C1
[Method A1]
Method B1 (B1 code modified)
Method C1
Class name Attributes
Methods
Is a specialization of
Or
Inherits from
Public, Private & Protected
• Attributes can be public or private:
– Private: it can only be accessed by its own methods
– Public: it can be modified by methods associated with
any class (violates encapsulation)
• Methods can be public, private or protected:
– Public: it’s name is exposed to other objects.
– Private: it can’t be accessed by other objects, only
internally
– Protected: (special case) only subclasses that descend
directly from a class that contains it, know and can use
this method.
Method signature
• It is the method’s name and the parameters
that must be passed with the message in
order for the method to function.
• The parameters are important because they
assure that the method will function
properly.
• Additionally they allow a compiler or
interpreter to discriminate between two
different methods with the same name.
Polimorphism
• Means that the same method will behave
differently when it is applied to the objects of
different classes
• It also means that different methods associated
with different classes can interpret the same
message in different ways.
• Example: an object can send a message PRINT to
several objects, and each one will use it’s own
PRINT method to execute the message.
Thank You

More Related Content

What's hot

What's hot (15)

Class
ClassClass
Class
 
Lo11
Lo11Lo11
Lo11
 
Introduction to OOP with java
Introduction to OOP with javaIntroduction to OOP with java
Introduction to OOP with java
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0
 
Inner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVAInner Classes & Multi Threading in JAVA
Inner Classes & Multi Threading in JAVA
 
Inner class
Inner classInner class
Inner class
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Inner classes
Inner classesInner classes
Inner classes
 
Eo gaddis java_chapter_03_5e
Eo gaddis java_chapter_03_5eEo gaddis java_chapter_03_5e
Eo gaddis java_chapter_03_5e
 
Java(inheritance)
Java(inheritance)Java(inheritance)
Java(inheritance)
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
Data members and member functions
Data members and member functionsData members and member functions
Data members and member functions
 
Java static keyword
Java static keywordJava static keyword
Java static keyword
 

Similar to Prof. Vikas Sharma (20)

OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
 
CIS110 Computer Programming Design Chapter (10)
CIS110 Computer Programming Design Chapter  (10)CIS110 Computer Programming Design Chapter  (10)
CIS110 Computer Programming Design Chapter (10)
 
OOPS Characteristics
OOPS CharacteristicsOOPS Characteristics
OOPS Characteristics
 
m211c25.ppt
m211c25.pptm211c25.ppt
m211c25.ppt
 
[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented programming 3 object oriented concepts
Object oriented programming 3 object oriented conceptsObject oriented programming 3 object oriented concepts
Object oriented programming 3 object oriented concepts
 
OOSD1-unit1_1_16_09.pptx
OOSD1-unit1_1_16_09.pptxOOSD1-unit1_1_16_09.pptx
OOSD1-unit1_1_16_09.pptx
 
Oops in c
Oops in cOops in c
Oops in c
 
class and object in c++.pptx
class and object in c++.pptxclass and object in c++.pptx
class and object in c++.pptx
 
8 oo approach&uml-23_feb
8 oo approach&uml-23_feb8 oo approach&uml-23_feb
8 oo approach&uml-23_feb
 

More from AGRASENMAHAVIDYALAY

More from AGRASENMAHAVIDYALAY (11)

prof. Vibhash kumar Jha
prof. Vibhash kumar Jhaprof. Vibhash kumar Jha
prof. Vibhash kumar Jha
 
prof. Ridwana Hasan
prof. Ridwana Hasanprof. Ridwana Hasan
prof. Ridwana Hasan
 
prof. Abhinav Agrawal
prof. Abhinav Agrawalprof. Abhinav Agrawal
prof. Abhinav Agrawal
 
Dr. Noopur Agrawal
Dr. Noopur AgrawalDr. Noopur Agrawal
Dr. Noopur Agrawal
 
prof. Abhinav Agrawal
prof. Abhinav Agrawalprof. Abhinav Agrawal
prof. Abhinav Agrawal
 
Dr. Dolly Pandey
Dr. Dolly PandeyDr. Dolly Pandey
Dr. Dolly Pandey
 
Database systems introduction final vaibhav
Database systems introduction final vaibhavDatabase systems introduction final vaibhav
Database systems introduction final vaibhav
 
Dr. Dolly Pandey
Dr. Dolly PandeyDr. Dolly Pandey
Dr. Dolly Pandey
 
Abhishek Agrawal
Abhishek AgrawalAbhishek Agrawal
Abhishek Agrawal
 
Elasticity of demand u 1, by Asst. Prof. Abhinav Agrawal
Elasticity of demand u 1, by Asst. Prof. Abhinav AgrawalElasticity of demand u 1, by Asst. Prof. Abhinav Agrawal
Elasticity of demand u 1, by Asst. Prof. Abhinav Agrawal
 
Production function and law of returns by Asst. Prof. Abhinav Agrawal.
Production function and law of returns by Asst. Prof. Abhinav Agrawal.Production function and law of returns by Asst. Prof. Abhinav Agrawal.
Production function and law of returns by Asst. Prof. Abhinav Agrawal.
 

Recently uploaded

REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 

Recently uploaded (20)

REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

Prof. Vikas Sharma

  • 1. Object Oriented Concepts & Principles VIKAS SHARMA, DEPARTMENT OF COMPUTERSCIENCE AGRASEN MAHAVIDYALAYA RAIPUR
  • 2. Objects • Object: Complex data type that has an identity, contains other data types called attributes and modules of code called operations or methods • Attributes and associated values are hidden inside the object. • Any object that wants to obtain or change a value associated with other object, must do so by sending a message to one of the objects (invoking a method)
  • 3. Objects Age: 35 methods (methods) Attributes (values) Set_salary (20) Object: woman method: Set_salary employer Get_age friend Salary: 10
  • 4. Encapsulation • Each objects methods manage it’s own attributes. • This is also known as hiding. • An object A can learn about the values of attributes of another object B, only by invoking the corresponding method (message) associated to the object B. • Example: – Class: Lady – Attributes: Age, salary – Methods: get_age, set_salary
  • 5. Procedural vs. Object-Oriented Procedural application OO-application DATA Line of code Line of code Line of code Data is stored independent of application Each object is independent of the others
  • 6. Classes • Classes are templates that have methods and attribute names and type information, but no actual values! • Objects are generated by these classes and they actually contain values. • We design an application at the class level. • When the system is running objects are created by classes as they are needed to contain state information. • When objects are no longer needed by the application, they are eliminated.
  • 7. Class & Objects Name Number CLASS: Furniture methods: Example ChangeNumber Objects: Desk 123445 ChairA 32143 ChairB 45687
  • 8. Message Passing & Associations • Methods are associated with classes but classes don’t send messages to each other. • Objects send messages. • A static diagram (class diagram) shows classes and the logical associations between classes, it doesn´t show the movement of messages. • An association between two classes means that the objects of the two classes can send messages to each other. • Aggregation: when an object contains other objects ( a part-whole relationship)
  • 9. Class Hierarchies & Inheritance • Classes can be arranged in hierarchies so that more classes inherit attributes and methods from more abstract classes • Class hierarchy diagrams Class: Chair subclasses Chair Type A Chair Type B
  • 10. Class Inheritance & Specialization Class: Furniture Attribute A1 Method A1 Class: Chairs [Attribute A1] Attribute B1 [Method A1] Method B1 Class: Executive Chairs [Attribute A1] [Attribute B1] Attribute C1 [Method A1] Method B1 (B1 code modified) Method C1 Class name Attributes Methods Is a specialization of Or Inherits from
  • 11. Public, Private & Protected • Attributes can be public or private: – Private: it can only be accessed by its own methods – Public: it can be modified by methods associated with any class (violates encapsulation) • Methods can be public, private or protected: – Public: it’s name is exposed to other objects. – Private: it can’t be accessed by other objects, only internally – Protected: (special case) only subclasses that descend directly from a class that contains it, know and can use this method.
  • 12. Method signature • It is the method’s name and the parameters that must be passed with the message in order for the method to function. • The parameters are important because they assure that the method will function properly. • Additionally they allow a compiler or interpreter to discriminate between two different methods with the same name.
  • 13. Polimorphism • Means that the same method will behave differently when it is applied to the objects of different classes • It also means that different methods associated with different classes can interpret the same message in different ways. • Example: an object can send a message PRINT to several objects, and each one will use it’s own PRINT method to execute the message.