SlideShare a Scribd company logo
ACCESS MODIFIER AND
INHERITANCE
DEFINATION OF ACCESS MODIFIER
• It is simply a keyword in java that provides accessibility of a class and its members.
• Set in the access level to method, variable, classes and constructors.
• Classification of access modifier are:-
• Private
• Protected
• Public
PRIVATE ACCESS MODIFIER
• It is the most restrictive access level whereby they are accessible only within the class itself.
• A superclass private members are not inherited by its subclasses.
• Example of Private Access Modifier is:
PROTECTED ACCESS MODIFIER
• It can be accessed by only the class of same package and the subclass present in any package.
• It has visibility in sub classes and Classes cannot be declared as protected.
• Example of Protected Access Modifier:
PUBLIC ACCESS MODIFIER
• It can be access with any classes.
• It is widest scope among all other modifiers.
• Example of Public Access Modifier is:
SCOPE OF ACCESS MODIFIERS IN TABULAR FORM
Access
Modifier
Within
Class
Within
Package
Outside Package By
Subclass only
Outside
Package
Private Y N N N
Protected Y Y Y N
Public Y Y Y Y
ACCESS MODIFIER AND INHERITANCE
• Inherits features of parent’s object/class to the child’s object/class.
• Extends keyword is used to inherit the features of superclass.
THANK YOU!!

More Related Content

Similar to Access modifier and inheritance

Java Access Specifier
Java Access SpecifierJava Access Specifier
Java Access Specifier
DeeptiJava
 
Access Specifier and encapusulation.pdf
Access Specifier and encapusulation.pdfAccess Specifier and encapusulation.pdf
Access Specifier and encapusulation.pdf
SunithaKrishnan9
 
Access Modifiers .pptx
Access Modifiers .pptxAccess Modifiers .pptx
Access Modifiers .pptx
MDRakibKhan3
 
Java introduction
Java introductionJava introduction
Java introduction
Muthukumaran Subramanian
 
Access specifiers(modifiers) in java
Access specifiers(modifiers) in javaAccess specifiers(modifiers) in java
Access specifiers(modifiers) in java
HrithikShinde
 
D2 Object Oriented Programming
D2 Object Oriented ProgrammingD2 Object Oriented Programming
D2 Object Oriented Programming
Pakorn Weecharungsan
 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In Java
MD SALEEM QAISAR
 
27c
27c27c
27csharp
27csharp27csharp
27csharp
Sireesh K
 
Chap1 packages
Chap1 packagesChap1 packages
Chap1 packages
raksharao
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
Jadavsejal
 
How totestinternalprotectmethodsinc#
How totestinternalprotectmethodsinc#How totestinternalprotectmethodsinc#
How totestinternalprotectmethodsinc#LearningTech
 
4th_class.pdf
4th_class.pdf4th_class.pdf
4th_class.pdf
RumiHossain5
 
Chapter 7 & 8 Classes in Java and Functions.pdf
Chapter 7 & 8 Classes in Java and Functions.pdfChapter 7 & 8 Classes in Java and Functions.pdf
Chapter 7 & 8 Classes in Java and Functions.pdf
KavitaHegde4
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
BG Java EE Course
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
Arslan Waseem
 
Java(inheritance)
Java(inheritance)Java(inheritance)
Java(inheritance)
Pooja Bhojwani
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
Sourabrata Mukherjee
 
Access Protection
Access ProtectionAccess Protection
Access Protectionmyrajendra
 
Differentiate between class Derived -public Base and class Derived- pr.docx
Differentiate between class Derived -public Base and class Derived- pr.docxDifferentiate between class Derived -public Base and class Derived- pr.docx
Differentiate between class Derived -public Base and class Derived- pr.docx
wviola
 

Similar to Access modifier and inheritance (20)

Java Access Specifier
Java Access SpecifierJava Access Specifier
Java Access Specifier
 
Access Specifier and encapusulation.pdf
Access Specifier and encapusulation.pdfAccess Specifier and encapusulation.pdf
Access Specifier and encapusulation.pdf
 
Access Modifiers .pptx
Access Modifiers .pptxAccess Modifiers .pptx
Access Modifiers .pptx
 
Java introduction
Java introductionJava introduction
Java introduction
 
Access specifiers(modifiers) in java
Access specifiers(modifiers) in javaAccess specifiers(modifiers) in java
Access specifiers(modifiers) in java
 
D2 Object Oriented Programming
D2 Object Oriented ProgrammingD2 Object Oriented Programming
D2 Object Oriented Programming
 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In Java
 
27c
27c27c
27c
 
27csharp
27csharp27csharp
27csharp
 
Chap1 packages
Chap1 packagesChap1 packages
Chap1 packages
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
How totestinternalprotectmethodsinc#
How totestinternalprotectmethodsinc#How totestinternalprotectmethodsinc#
How totestinternalprotectmethodsinc#
 
4th_class.pdf
4th_class.pdf4th_class.pdf
4th_class.pdf
 
Chapter 7 & 8 Classes in Java and Functions.pdf
Chapter 7 & 8 Classes in Java and Functions.pdfChapter 7 & 8 Classes in Java and Functions.pdf
Chapter 7 & 8 Classes in Java and Functions.pdf
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
 
Java(inheritance)
Java(inheritance)Java(inheritance)
Java(inheritance)
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
Access Protection
Access ProtectionAccess Protection
Access Protection
 
Differentiate between class Derived -public Base and class Derived- pr.docx
Differentiate between class Derived -public Base and class Derived- pr.docxDifferentiate between class Derived -public Base and class Derived- pr.docx
Differentiate between class Derived -public Base and class Derived- pr.docx
 

More from Dikshyanta Dhungana

Punctuation
PunctuationPunctuation
Punctuation
Dikshyanta Dhungana
 
Heuristic evaluation
Heuristic evaluationHeuristic evaluation
Heuristic evaluation
Dikshyanta Dhungana
 
Building learning organization
Building learning organizationBuilding learning organization
Building learning organization
Dikshyanta Dhungana
 
Daily stand up meeting
Daily stand up meetingDaily stand up meeting
Daily stand up meeting
Dikshyanta Dhungana
 
Stlc and v model
Stlc and v modelStlc and v model
Stlc and v model
Dikshyanta Dhungana
 
Agile manifesto
Agile manifestoAgile manifesto
Agile manifesto
Dikshyanta Dhungana
 
Functional and non functional
Functional and non functionalFunctional and non functional
Functional and non functional
Dikshyanta Dhungana
 
Computer virus
Computer virusComputer virus
Computer virus
Dikshyanta Dhungana
 
Autodesk maya
Autodesk mayaAutodesk maya
Autodesk maya
Dikshyanta Dhungana
 

More from Dikshyanta Dhungana (9)

Punctuation
PunctuationPunctuation
Punctuation
 
Heuristic evaluation
Heuristic evaluationHeuristic evaluation
Heuristic evaluation
 
Building learning organization
Building learning organizationBuilding learning organization
Building learning organization
 
Daily stand up meeting
Daily stand up meetingDaily stand up meeting
Daily stand up meeting
 
Stlc and v model
Stlc and v modelStlc and v model
Stlc and v model
 
Agile manifesto
Agile manifestoAgile manifesto
Agile manifesto
 
Functional and non functional
Functional and non functionalFunctional and non functional
Functional and non functional
 
Computer virus
Computer virusComputer virus
Computer virus
 
Autodesk maya
Autodesk mayaAutodesk maya
Autodesk maya
 

Recently uploaded

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 

Recently uploaded (20)

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 

Access modifier and inheritance

  • 2. DEFINATION OF ACCESS MODIFIER • It is simply a keyword in java that provides accessibility of a class and its members. • Set in the access level to method, variable, classes and constructors. • Classification of access modifier are:- • Private • Protected • Public
  • 3. PRIVATE ACCESS MODIFIER • It is the most restrictive access level whereby they are accessible only within the class itself. • A superclass private members are not inherited by its subclasses. • Example of Private Access Modifier is:
  • 4.
  • 5. PROTECTED ACCESS MODIFIER • It can be accessed by only the class of same package and the subclass present in any package. • It has visibility in sub classes and Classes cannot be declared as protected. • Example of Protected Access Modifier:
  • 6.
  • 7. PUBLIC ACCESS MODIFIER • It can be access with any classes. • It is widest scope among all other modifiers. • Example of Public Access Modifier is:
  • 8.
  • 9. SCOPE OF ACCESS MODIFIERS IN TABULAR FORM Access Modifier Within Class Within Package Outside Package By Subclass only Outside Package Private Y N N N Protected Y Y Y N Public Y Y Y Y
  • 10. ACCESS MODIFIER AND INHERITANCE • Inherits features of parent’s object/class to the child’s object/class. • Extends keyword is used to inherit the features of superclass.