SlideShare a Scribd company logo
1 of 27
SEMINAR ON JAVA
INHERITANCE
THE MECHANISM
OF DERIVING A NEW
CLASS FROM AN OLD
ONE IS CALLED
INHERITANCE.
•THE OLD CLASS IS KNOWN
AS BASE CLASS OR SUPER
CLASS OR PARENT CLASS

THE NEW ONE IS CALLED
THE SUB CLASS OR DERIVED
CLASS OR CHILD CLASS
TYPES OF INHARITANCE
SINGLE INHERITANCE
         •ONLY
          ONE BASE
          CLASS
MULTILEVEL
        INHERITANCE
GRAND FATHER   SUPER CLASS


FATHER         INTERMEDIATE SUPERCLASS



CHILD          SUB CLASS
A DERIVED CLASS WITH MULTILEVEL BASE CLASSES IS DECLARED AS
FOLLOWS
CLASS A
{
…………
…………
}
CLASS B extends A // first level
{
………….
………….
}
CLASS C //second level
{
………….
………….
}
EXAMPLE
HERE CERTAIN
FEATURES OF ONE
LEVEL ARE SHARED
BY MANY OTHER
BELOW THE LEVEL.
MULTIPLE INHERITANCE
   OVERRIDING CAN BE DONE BY
    DEFINING A METHOD IN THE SUB
    CLASS THAT HAS THE SAME
    NAME,SAME ARGUMENTS AND
    SAME RETURN TYPE AS A
    METHOD IN THE SUPER CLASS.

   THIS IS KNOWN AS OVERRIDING.
FINALIZER METHODS
 FINILIZATION IS JUST OPPOSITE TO
 INITIALASATION.
 JAVA RUN-TIME IS AN AUTOMATIC
  GARBAGE COLLECTING SYSTEM.
 IT FREES THE MEMORY RESOURCES USED
  BY OBJECTS.
 BUT OBJECTS MAY HOLD OTHER NON-
  OBJECT RESOURCES SUCH AS FILE
  DESCRIPTORS OR WINDOW SYSTEM
  FONTS.
 THE GARBAGE COLLECTOR CANNOT FREE
  THESE RESOURCES.
 IN ORDER TO FREE THIS WE USE FINALIZER
  METHOD.
 THIS IS SIMILAR TO

 DESTRUCTORS.
 THE FINALIZER METHOD IS SIMPLY

 FINALIZE()
ABSTRACT METHODS
 FINALIZER
          HELPS US NOT TO RE-
 DEFINE THE METHOD IN SUB
 CLASS.

 BUT
    TO DO THE OPPOSITE, i.e.
 REDEFINE THE METHOD IN SUB
 CLASS,WE USE THE MODIFIER
 KEYWORD abstract IN THE
 METHOD DEFINITION
EXAMPLE

abstract class shape
{
………….
………….
abstract void draw();
………….
………….
}
VISIBILITY CONTROL
 IT
   IS ALSO KNOWN AS ACCESS
 MODIFIERS.THIS PROVIDES THREE
 TYPES OF MODIFIERS:

PUBLIC

PRIVATE

PROTECTED
By   simply declaring the variable or
 method as public it is visible to
 entire class in which it is defined.

A variable or method which is
 declared as public has the widest
 possible visibility and
 accessible everywhere.
FRIENDLY ACCESS
• When no access modifier is specified,the
  member defaults to a limited version of public
  accessibility known as “friendly” level of
  access.

• this makes fields visible only in the same
  package,but not in other packages.
   The visibility lies in between the public
    access and friendly access.

   The protected modifier makes the fields
    visible not only to all classes and sub
    classes in the same package but also to
    sub classes in other packages.
PRIVATE ACCESS
 They enjoy the highest   degree of protection.
 They are accessible only with their own class.
 They cannot      be accessed and inherited
 by sub classes.
 The method declared as private behaves like a
  method declared as final.
 It prevents the method from being sub classed.
A  field can be declared with two key
  words private and protected together like:
Private protected int codenumber;
 the visibility level is between the
  “protected” access and private access.
 This makes the fields visible in all
  subclasses regardless of what package
  they are in
   USE PUBLIC IF THE FIELD IS TO BE VISIBLE
    EVERYWHERE.
   USE PROTECTED IF THE FIELD IS TO BE
    VISIBLE EVERYWHERE IN THE CURRENT
    PACKAGE AND ALSO SUBCLASSES IN
    OTHER PACKAGES.
   USE “DEFAULT” IF THE FIELD IS TO BE
    VISIBLE EVERYWHERE IN THE CURRENT
    PACKAGE ONLY.
   USE PRIVATE PROTECTED IF THE FIELD IS
thank you

More Related Content

What's hot (20)

Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Abstract class
Abstract classAbstract class
Abstract class
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Java collections concept
Java collections conceptJava collections concept
Java collections concept
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
 
java token
java tokenjava token
java token
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Oops in java
Oops in javaOops in java
Oops in java
 
Inheritance and Polymorphism
Inheritance and PolymorphismInheritance and Polymorphism
Inheritance and Polymorphism
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 
Abstraction in java
Abstraction in javaAbstraction in java
Abstraction in java
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
Applets
AppletsApplets
Applets
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 

Viewers also liked

Java Presentation
Java PresentationJava Presentation
Java Presentationpm2214
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core javamahir jain
 
Core java concepts
Core java  conceptsCore java  concepts
Core java conceptsRam132
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java ProgrammingRavi Kant Sahu
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Languagejaimefrozr
 
Java Presentation
Java PresentationJava Presentation
Java Presentationaitrichtech
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java SlidesVinit Vyas
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
What is Android OS in ppt ?
What is Android OS in ppt ? What is Android OS in ppt ?
What is Android OS in ppt ? SoonTips.com
 
Java multi threading
Java multi threadingJava multi threading
Java multi threadingRaja Sekhar
 
Database management system presentation
Database management system presentationDatabase management system presentation
Database management system presentationsameerraaj
 

Viewers also liked (20)

Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Core java slides
Core java slidesCore java slides
Core java slides
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Java basic
Java basicJava basic
Java basic
 
Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
What is Android OS in ppt ?
What is Android OS in ppt ? What is Android OS in ppt ?
What is Android OS in ppt ?
 
Android seminar ppt
Android seminar pptAndroid seminar ppt
Android seminar ppt
 
Java multi threading
Java multi threadingJava multi threading
Java multi threading
 
Database management system presentation
Database management system presentationDatabase management system presentation
Database management system presentation
 
Networking ppt
Networking ppt Networking ppt
Networking ppt
 

Similar to Seminar on java (20)

Chapter 3i
Chapter 3iChapter 3i
Chapter 3i
 
Chapter 9 java
Chapter 9 javaChapter 9 java
Chapter 9 java
 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
INHERITANCE
INHERITANCEINHERITANCE
INHERITANCE
 
Introduction to Inheritance
Introduction to InheritanceIntroduction to Inheritance
Introduction to Inheritance
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
9781439035665 ppt ch10
9781439035665 ppt ch109781439035665 ppt ch10
9781439035665 ppt ch10
 
C++ presentation
C++ presentationC++ presentation
C++ presentation
 
Oops
OopsOops
Oops
 
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
 
E -COMMERCE.ppt
E -COMMERCE.pptE -COMMERCE.ppt
E -COMMERCE.ppt
 
INHERITANCE IN JAVA.pptx
INHERITANCE IN JAVA.pptxINHERITANCE IN JAVA.pptx
INHERITANCE IN JAVA.pptx
 
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptxSodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
SodaPDF-converted-inheritanceinjava-120903114217-phpapp02-converted.pptx
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
Presentation 3.pdf
Presentation 3.pdfPresentation 3.pdf
Presentation 3.pdf
 
Chap3 inheritance
Chap3 inheritanceChap3 inheritance
Chap3 inheritance
 
Core java by amit
Core java by amitCore java by amit
Core java by amit
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxabhijeetpadhi001
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
MICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptxMICROBIOLOGY biochemical test detailed.pptx
MICROBIOLOGY biochemical test detailed.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 

Seminar on java

  • 3. THE MECHANISM OF DERIVING A NEW CLASS FROM AN OLD ONE IS CALLED INHERITANCE.
  • 4. •THE OLD CLASS IS KNOWN AS BASE CLASS OR SUPER CLASS OR PARENT CLASS THE NEW ONE IS CALLED THE SUB CLASS OR DERIVED CLASS OR CHILD CLASS
  • 6. SINGLE INHERITANCE •ONLY ONE BASE CLASS
  • 7. MULTILEVEL INHERITANCE GRAND FATHER SUPER CLASS FATHER INTERMEDIATE SUPERCLASS CHILD SUB CLASS
  • 8. A DERIVED CLASS WITH MULTILEVEL BASE CLASSES IS DECLARED AS FOLLOWS CLASS A { ………… ………… } CLASS B extends A // first level { …………. …………. } CLASS C //second level { …………. …………. }
  • 9.
  • 11. HERE CERTAIN FEATURES OF ONE LEVEL ARE SHARED BY MANY OTHER BELOW THE LEVEL.
  • 13. OVERRIDING CAN BE DONE BY DEFINING A METHOD IN THE SUB CLASS THAT HAS THE SAME NAME,SAME ARGUMENTS AND SAME RETURN TYPE AS A METHOD IN THE SUPER CLASS.  THIS IS KNOWN AS OVERRIDING.
  • 14. FINALIZER METHODS  FINILIZATION IS JUST OPPOSITE TO INITIALASATION.  JAVA RUN-TIME IS AN AUTOMATIC GARBAGE COLLECTING SYSTEM.  IT FREES THE MEMORY RESOURCES USED BY OBJECTS.  BUT OBJECTS MAY HOLD OTHER NON- OBJECT RESOURCES SUCH AS FILE DESCRIPTORS OR WINDOW SYSTEM FONTS.
  • 15.  THE GARBAGE COLLECTOR CANNOT FREE THESE RESOURCES.  IN ORDER TO FREE THIS WE USE FINALIZER METHOD.  THIS IS SIMILAR TO DESTRUCTORS.  THE FINALIZER METHOD IS SIMPLY FINALIZE()
  • 16. ABSTRACT METHODS  FINALIZER HELPS US NOT TO RE- DEFINE THE METHOD IN SUB CLASS.  BUT TO DO THE OPPOSITE, i.e. REDEFINE THE METHOD IN SUB CLASS,WE USE THE MODIFIER KEYWORD abstract IN THE METHOD DEFINITION
  • 17. EXAMPLE abstract class shape { …………. …………. abstract void draw(); …………. …………. }
  • 18. VISIBILITY CONTROL  IT IS ALSO KNOWN AS ACCESS MODIFIERS.THIS PROVIDES THREE TYPES OF MODIFIERS: PUBLIC PRIVATE PROTECTED
  • 19. By simply declaring the variable or method as public it is visible to entire class in which it is defined. A variable or method which is declared as public has the widest possible visibility and accessible everywhere.
  • 20.
  • 21. FRIENDLY ACCESS • When no access modifier is specified,the member defaults to a limited version of public accessibility known as “friendly” level of access. • this makes fields visible only in the same package,but not in other packages.
  • 22. The visibility lies in between the public access and friendly access.  The protected modifier makes the fields visible not only to all classes and sub classes in the same package but also to sub classes in other packages.
  • 23. PRIVATE ACCESS  They enjoy the highest degree of protection.  They are accessible only with their own class.  They cannot be accessed and inherited by sub classes.  The method declared as private behaves like a method declared as final.  It prevents the method from being sub classed.
  • 24. A field can be declared with two key words private and protected together like: Private protected int codenumber;  the visibility level is between the “protected” access and private access.  This makes the fields visible in all subclasses regardless of what package they are in
  • 25. USE PUBLIC IF THE FIELD IS TO BE VISIBLE EVERYWHERE.  USE PROTECTED IF THE FIELD IS TO BE VISIBLE EVERYWHERE IN THE CURRENT PACKAGE AND ALSO SUBCLASSES IN OTHER PACKAGES.  USE “DEFAULT” IF THE FIELD IS TO BE VISIBLE EVERYWHERE IN THE CURRENT PACKAGE ONLY.  USE PRIVATE PROTECTED IF THE FIELD IS
  • 26.