SlideShare a Scribd company logo
1 of 19
Download to read offline
OBJECT ORIENTED
Hasanka Wijesinghe
PROGRAMMING
MIT, B.Sc
Programming Design Techniques and Programming
Content
Class and Methods
Access Modifiers
Object Oriented Concepts
DSE004 Hasanka Wijesinghe
Java Class and Methods
DSE004 Hasanka Wijesinghe
Java Methods
DSE004 Hasanka Wijesinghe
Method type
Methods with return type
Methods without return type
Methods with return type Methods without return type
Java Object Creation
DSE004 Hasanka Wijesinghe
In Java, objects are instances of classes, and you create objects using the new keyword
along with a constructor.
Class
Object
Access Modifiers
DSE004 Hasanka Wijesinghe
Public
The most permissive access level.
Public members are accessible from any other class.
Access Modifiers
DSE004 Hasanka Wijesinghe
Private
The most restrictive access level.
Private members are only accessible within the same class.
Protected
Members are accessible within the same class, subclass (even if the subclass is in a
different package), and package.
Not accessible outside the package unless there is an inheritance relationship.
Access Modifiers
DSE004 Hasanka Wijesinghe
DSE004 Hasanka Wijesinghe
Object Oriented Programming Concepts
Encapsulation
Encapsulation is the bundling of data and
methods that operate on the data into a
single unit known as a class.
Polymorphism
Polymorphism means "many forms" and
refers to the ability of objects to take on
multiple forms.
Inheritance
Inheritance is a mechanism that allows a
class to inherit properties and behaviors
from another class
Abstraction
Abstraction is the process of simplifying
complex systems by modeling classes based
on the essential properties and behaviors they
possess.
DSE004 Hasanka Wijesinghe
Encapsulation is a way to restrict the direct access to some components of an object
Encapsulation can be used to hide both data members and data functions or
methods associated with an instantiated class or object.
Encapsulation
DSE004 Hasanka Wijesinghe
Consider a class representing a bank account. Apply encapsulation principles to
design the class with private attributes such as account number, balance, and owner's
name. Provide public methods to deposit and withdraw funds while ensuring that the
balance cannot be accessed or modified directly. Demonstrate the usage of
encapsulation in your solution.
Encapsulation
DSE004 Hasanka Wijesinghe
Inheritance is a mechanism that allows a
class (subclass or derived class) to inherit
properties and behaviors from another class
(superclass or base class).
It promotes code reuse and establishes a
relationship between classes, facilitating the
creation of a hierarchical structure.
Inheritance
DSE004 Hasanka Wijesinghe
Inheritance
DSE004 Hasanka Wijesinghe
Super Class / Parent Class
Sub Class / Child Class
In object-oriented programming (OOP), polymorphism is the concept
that an entity in code can have more than one form.
In Java, polymorphism is achieved through method overloading and
method overriding.
Method Overloading: Multiple methods with the same name but
different parameter lists.
Method Overriding: A subclass provides a specific implementation of
a method that is already defined in its superclass.
Polymorphism
DSE004 Hasanka Wijesinghe
Polymorphism
DSE004 Hasanka Wijesinghe
Abstraction involves simplifying complex systems by modeling classes based on the
essential properties and behaviors they possess.
Abstraction can create a clear separation between the interface (what the object does)
and the implementation (how it does it). This separation enhances modularity, making
it easier to maintain and update the system.
It helps break down a large, complex problem into smaller, more manageable
components.
Abstraction
DSE004 Hasanka Wijesinghe
Abstraction
DSE004 Hasanka Wijesinghe
THANK YOU!
DSE004 Hasanka Wijesinghe

More Related Content

Similar to Object Oriented Programming CONCEPTS.pdf

Ap Power Point Chpt7
Ap Power Point Chpt7Ap Power Point Chpt7
Ap Power Point Chpt7
dplunkett
 

Similar to Object Oriented Programming CONCEPTS.pdf (20)

Java(inheritance)
Java(inheritance)Java(inheritance)
Java(inheritance)
 
Dr. Rajeshree Khande : Java Inheritance
Dr. Rajeshree Khande : Java InheritanceDr. Rajeshree Khande : Java Inheritance
Dr. Rajeshree Khande : Java Inheritance
 
Chapter08 - Inheritance.ppt
Chapter08 - Inheritance.pptChapter08 - Inheritance.ppt
Chapter08 - Inheritance.ppt
 
Ap Power Point Chpt7
Ap Power Point Chpt7Ap Power Point Chpt7
Ap Power Point Chpt7
 
Nitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptxNitish Chaulagai Java1.pptx
Nitish Chaulagai Java1.pptx
 
Introduction to Inheritance in Java for presentation
Introduction to Inheritance in Java for presentationIntroduction to Inheritance in Java for presentation
Introduction to Inheritance in Java for presentation
 
Java ppt
Java pptJava ppt
Java ppt
 
Top 10 java oops interview questions
Top 10 java oops interview questionsTop 10 java oops interview questions
Top 10 java oops interview questions
 
Top 10 java oops interview questions
Top 10 java oops interview questionsTop 10 java oops interview questions
Top 10 java oops interview questions
 
Top 10 java_oops_interview_questions
Top 10 java_oops_interview_questionsTop 10 java_oops_interview_questions
Top 10 java_oops_interview_questions
 
Top 10 java_oops_interview_questions
Top 10 java_oops_interview_questionsTop 10 java_oops_interview_questions
Top 10 java_oops_interview_questions
 
Top 10 java_oops_interview_questions
Top 10 java_oops_interview_questionsTop 10 java_oops_interview_questions
Top 10 java_oops_interview_questions
 
Top 10 java_oops_interview_questions
Top 10 java_oops_interview_questionsTop 10 java_oops_interview_questions
Top 10 java_oops_interview_questions
 
Exploring the Pillars of Object java.pdf
Exploring the Pillars of Object java.pdfExploring the Pillars of Object java.pdf
Exploring the Pillars of Object java.pdf
 
Object oriented programming CLASSES-AND-OBJECTS.pptx
Object oriented programming CLASSES-AND-OBJECTS.pptxObject oriented programming CLASSES-AND-OBJECTS.pptx
Object oriented programming CLASSES-AND-OBJECTS.pptx
 
Title_ What are the four principles of OOP, and how does Java support them.pdf
Title_ What are the four principles of OOP, and how does Java support them.pdfTitle_ What are the four principles of OOP, and how does Java support them.pdf
Title_ What are the four principles of OOP, and how does Java support them.pdf
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
java_vyshali.pdf
java_vyshali.pdfjava_vyshali.pdf
java_vyshali.pdf
 
Inheritance in oop
Inheritance in oopInheritance in oop
Inheritance in oop
 
Inheritance and its necessity in java.ppt
Inheritance and its necessity in java.pptInheritance and its necessity in java.ppt
Inheritance and its necessity in java.ppt
 

More from HasankaNayanjith (6)

Introduction to computer programming.pdf
Introduction to computer programming.pdfIntroduction to computer programming.pdf
Introduction to computer programming.pdf
 
Introduction to Servers and Server Types.pptx
Introduction to Servers and Server Types.pptxIntroduction to Servers and Server Types.pptx
Introduction to Servers and Server Types.pptx
 
Introduction to Servers - Computer network.pptx
Introduction to Servers - Computer network.pptxIntroduction to Servers - Computer network.pptx
Introduction to Servers - Computer network.pptx
 
APPLICATIONS OF NETWORKS, Computer Network
APPLICATIONS OF NETWORKS, Computer NetworkAPPLICATIONS OF NETWORKS, Computer Network
APPLICATIONS OF NETWORKS, Computer Network
 
Lec 09 SQL - 3.pptx
Lec 09 SQL - 3.pptxLec 09 SQL - 3.pptx
Lec 09 SQL - 3.pptx
 
Lec 07 SQL - 1.pptx
Lec 07 SQL - 1.pptxLec 07 SQL - 1.pptx
Lec 07 SQL - 1.pptx
 

Recently uploaded

Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Lisi Hocke
 
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
drm1699
 

Recently uploaded (20)

Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
Abortion Clinic Pretoria ](+27832195400*)[ Abortion Clinic Near Me ● Abortion...
 
Rapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and InsightsRapidoform for Modern Form Building and Insights
Rapidoform for Modern Form Building and Insights
 
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Era
 
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-CloudAlluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
Alluxio Monthly Webinar | Simplify Data Access for AI in Multi-Cloud
 
Abortion Pill Prices Jozini ](+27832195400*)[ 🏥 Women's Abortion Clinic in Jo...
Abortion Pill Prices Jozini ](+27832195400*)[ 🏥 Women's Abortion Clinic in Jo...Abortion Pill Prices Jozini ](+27832195400*)[ 🏥 Women's Abortion Clinic in Jo...
Abortion Pill Prices Jozini ](+27832195400*)[ 🏥 Women's Abortion Clinic in Jo...
 
Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...
Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...
Abortion Pill Prices Mthatha (@](+27832195400*)[ 🏥 Women's Abortion Clinic In...
 
Novo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMsNovo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMs
 
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
 
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale IbridaUNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
 
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
Team Transformation Tactics for Holistic Testing and Quality (NewCrafts Paris...
 
Test Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdfTest Automation Design Patterns_ A Comprehensive Guide.pdf
Test Automation Design Patterns_ A Comprehensive Guide.pdf
 
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
 
[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST API
 
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
 

Object Oriented Programming CONCEPTS.pdf

  • 1. OBJECT ORIENTED Hasanka Wijesinghe PROGRAMMING MIT, B.Sc Programming Design Techniques and Programming
  • 2. Content Class and Methods Access Modifiers Object Oriented Concepts DSE004 Hasanka Wijesinghe
  • 3. Java Class and Methods DSE004 Hasanka Wijesinghe
  • 4. Java Methods DSE004 Hasanka Wijesinghe Method type Methods with return type Methods without return type Methods with return type Methods without return type
  • 5. Java Object Creation DSE004 Hasanka Wijesinghe In Java, objects are instances of classes, and you create objects using the new keyword along with a constructor. Class Object
  • 6. Access Modifiers DSE004 Hasanka Wijesinghe Public The most permissive access level. Public members are accessible from any other class.
  • 7. Access Modifiers DSE004 Hasanka Wijesinghe Private The most restrictive access level. Private members are only accessible within the same class.
  • 8. Protected Members are accessible within the same class, subclass (even if the subclass is in a different package), and package. Not accessible outside the package unless there is an inheritance relationship. Access Modifiers DSE004 Hasanka Wijesinghe
  • 10. Object Oriented Programming Concepts Encapsulation Encapsulation is the bundling of data and methods that operate on the data into a single unit known as a class. Polymorphism Polymorphism means "many forms" and refers to the ability of objects to take on multiple forms. Inheritance Inheritance is a mechanism that allows a class to inherit properties and behaviors from another class Abstraction Abstraction is the process of simplifying complex systems by modeling classes based on the essential properties and behaviors they possess. DSE004 Hasanka Wijesinghe
  • 11. Encapsulation is a way to restrict the direct access to some components of an object Encapsulation can be used to hide both data members and data functions or methods associated with an instantiated class or object. Encapsulation DSE004 Hasanka Wijesinghe
  • 12. Consider a class representing a bank account. Apply encapsulation principles to design the class with private attributes such as account number, balance, and owner's name. Provide public methods to deposit and withdraw funds while ensuring that the balance cannot be accessed or modified directly. Demonstrate the usage of encapsulation in your solution. Encapsulation DSE004 Hasanka Wijesinghe
  • 13. Inheritance is a mechanism that allows a class (subclass or derived class) to inherit properties and behaviors from another class (superclass or base class). It promotes code reuse and establishes a relationship between classes, facilitating the creation of a hierarchical structure. Inheritance DSE004 Hasanka Wijesinghe
  • 14. Inheritance DSE004 Hasanka Wijesinghe Super Class / Parent Class Sub Class / Child Class
  • 15. In object-oriented programming (OOP), polymorphism is the concept that an entity in code can have more than one form. In Java, polymorphism is achieved through method overloading and method overriding. Method Overloading: Multiple methods with the same name but different parameter lists. Method Overriding: A subclass provides a specific implementation of a method that is already defined in its superclass. Polymorphism DSE004 Hasanka Wijesinghe
  • 17. Abstraction involves simplifying complex systems by modeling classes based on the essential properties and behaviors they possess. Abstraction can create a clear separation between the interface (what the object does) and the implementation (how it does it). This separation enhances modularity, making it easier to maintain and update the system. It helps break down a large, complex problem into smaller, more manageable components. Abstraction DSE004 Hasanka Wijesinghe