SlideShare a Scribd company logo
1 of 24
Download to read offline
Inheritance and Interface
New Wave Analytica
We Find Solutions in Data
Outline
▪ Inheritance
▪Method Overriding
▪Constructors During Inheritance
▪SuperClass Methods
▪Information Hiding
▪Non-overriden Methods
▪Creating and Using Interfaces
New Wave Analytica
Intended Learning Outcomes (ILOs)
▪ Inherit properties of classes in other classes.
▪ Apply user-defined constructors during class inheritance.
▪ Apply appropriate access modifies of class methods in hiding
information.
▪ Identify and set non-overriden methods of a class.
▪ Create, implement and reuse an interface.
▪ Create a Java project that exhibit the use of class
inheritance, method overriding, and interfaces
New Wave Analytica
Teaching and Learning Activities (TLAs)
▪ Lecture
▪ Assignment
▪ Program Simulation and Demonstration
▪ Group Discussion
▪ Exercise
New Wave Analytica
Assessment Tasks (ATs)
▪ Quiz
▪ Exercises
▪ Assignment
New Wave Analytica
Inheritance
▪ Java / Other OOP Languages
▪Inheritance is a mechanism that enables one class to inherit, or assume,
both the behavior and the attributes of another class.
▪Inheritance is the principle that allows you to apply your knowledge of a
general category to more specific objects.
New Wave Analytica
Genetic Inheritance
▪ Genetic
▪Facts / Attributes
▪ Blood type
▪ Eye Color
▪Behavior
▪ Attitude for saving money
▪ Pulling ears when tired
New Wave Analytica
Termonologies
▪ Base Class / SuperClass / Parent Class
▪Class that is used as basis for inheritance
▪ Derived Class / SubClass / Child Class
▪Class that inherits from a base class
New Wave Analytica
SuperClass vs SubClass
▪ Size
▪Sublclass is larger that the SuperClass
▪Contains all the fields and methods of the SuperClass
▪Additional fields and methods
New Wave Analytica
Extending Classes
▪ extends
▪use to achieve inheritance in Java
▪Example
▪EmployeeWithBenefits extends Employee
New Wave Analytica
Overriding SuperClass Methods
▪ SubClass contains data and methods defined in the
SuperClass
▪Any Child Class has all the attributes of its parent.
▪ SuperClass data fields are not entirely appropriate for the
SubClass objects.
▪ Override the parent class members
New Wave Analytica
Calling Constructors During Inheritance
▪ When you instantiate an object that is a member of a
subclass, you are actually calling at least two
constructors
▪Constructor for the base class
▪Constructor for the derived class
▪When you create any subclass object, the superclass
constructor must execute first, and then the subclass
constructor executes
New Wave Analytica
SuperClass Constructors that Require Arguments
▪ When you create a class that do not have a
Constructor, Java automatically supplies a default
constructor – one that never requires argument.
▪ When you write your own constructor, you replace the
automatically supplied version.
New Wave Analytica
SuperClass Constructors that Require Arguments
▪ Your subclass constructors can contain any number of
statements, but if all superclass constructors require
arguments, then the first statement within each
subclass constructor must call the superclass
constructor.
New Wave Analytica
Format of statement that calls a SuperClass Constructor
▪ super(list of arguments);
New Wave Analytica
Types of Non-Overriden Methods
▪ static methods
▪ final methods
▪ methods with final class
New Wave Analytica
Example
New Wave Analytica
Abstract Class
▪ Abstraction refers to the ability to make a class abstract in OOP.
▪An abstract class is one that cannot be instantiated.
▪ All other functionality of the class still exists, and its fields,
methods, and constructors are all accessed in the same manner.
▪You just cannot create an instance of the abstract class.
New Wave Analytica
Extending Two or More Classes
▪ Extending two or more classes is not allowed
▪ Example
public class EmployeeWithBenefits extends EmployeeA, EmployeeB
New Wave Analytica
Information Hiding
▪ Private field data cannot be directly altered by an instance of a
class (in another Class)
▪ Example
Employee newEmployee = new Employee();
newEmployee.empNumber = 123;
▪ Only methods that are part of the class are allowed to alter a
private data.
New Wave Analytica
Information Hiding
▪ When a class serves as a superclass of other classes, the
subclass inherits (use) all the data and methods of the
superclass with one exception
▪Private members of a parent class are not accessible within a
child’s class methods.
New Wave Analytica
Information Hiding : Protected
▪ Provides an immediate level of security between public and
private access.
▪ Protected fields and methods can only be accessed by its own
class and its descendant (subclass)
New Wave Analytica
Interface
▪ A Java interface is an abstract type used to designate a set of
abstract methods for classes to implement.
▪ When a class implements an interface, it must inherit all of the
abstract methods declared within, as though signing into a
contract and carrying out the agreement.
▪ An interface is a completely abstract class that is used to group
related methods with empty bodies.
New Wave Analytica
Example
interface Animal {
public void animalSound(); // interface method (does not have a body)
public void run(); // interface method (does not have a body)
}
New Wave Analytica

More Related Content

Similar to Inheritance and interface

Abstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and InterfacesAbstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and InterfacesAhmed Nobi
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingNithyaN19
 
Abstraction in java.pptx
Abstraction in java.pptxAbstraction in java.pptx
Abstraction in java.pptxAsifMulani17
 
chapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programmingchapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programmingWondimuBantihun1
 
Oriented Programming Concepts and Principles
Oriented Programming Concepts and PrinciplesOriented Programming Concepts and Principles
Oriented Programming Concepts and PrinciplesRosmina Joy Cabauatan
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
 
Classes in Java great learning.pdf
Classes in Java great learning.pdfClasses in Java great learning.pdf
Classes in Java great learning.pdfSHASHIKANT346021
 
5. OBJECT ORIENTED PROGRAMMING USING JAVA - INHERITANCE.ppt
5. OBJECT ORIENTED PROGRAMMING USING JAVA - INHERITANCE.ppt5. OBJECT ORIENTED PROGRAMMING USING JAVA - INHERITANCE.ppt
5. OBJECT ORIENTED PROGRAMMING USING JAVA - INHERITANCE.pptAshwathGupta
 
More oop in java
More oop in javaMore oop in java
More oop in javaSAGARDAVE29
 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in javaElizabeth alexander
 
ABAP Object oriented concepts
ABAP Object oriented conceptsABAP Object oriented concepts
ABAP Object oriented conceptsDharmeshKumar49
 

Similar to Inheritance and interface (20)

Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
Abstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and InterfacesAbstraction in java [abstract classes and Interfaces
Abstraction in java [abstract classes and Interfaces
 
PPT Lecture-1.4.pptx
PPT Lecture-1.4.pptxPPT Lecture-1.4.pptx
PPT Lecture-1.4.pptx
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overriding
 
Chap02
Chap02Chap02
Chap02
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in Java
 
Unit 4
Unit 4Unit 4
Unit 4
 
Abstraction in java.pptx
Abstraction in java.pptxAbstraction in java.pptx
Abstraction in java.pptx
 
chapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programmingchapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programming
 
Unit 3
Unit 3Unit 3
Unit 3
 
Oriented Programming Concepts and Principles
Oriented Programming Concepts and PrinciplesOriented Programming Concepts and Principles
Oriented Programming Concepts and Principles
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
 
Classes in Java great learning.pdf
Classes in Java great learning.pdfClasses in Java great learning.pdf
Classes in Java great learning.pdf
 
5. OBJECT ORIENTED PROGRAMMING USING JAVA - INHERITANCE.ppt
5. OBJECT ORIENTED PROGRAMMING USING JAVA - INHERITANCE.ppt5. OBJECT ORIENTED PROGRAMMING USING JAVA - INHERITANCE.ppt
5. OBJECT ORIENTED PROGRAMMING USING JAVA - INHERITANCE.ppt
 
More oop in java
More oop in javaMore oop in java
More oop in java
 
OOPS Characteristics
OOPS CharacteristicsOOPS Characteristics
OOPS Characteristics
 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in java
 
ABAP Object oriented concepts
ABAP Object oriented conceptsABAP Object oriented concepts
ABAP Object oriented concepts
 
javainheritance
javainheritancejavainheritance
javainheritance
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 

Recently uploaded

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Recently uploaded (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 

Inheritance and interface

  • 1. Inheritance and Interface New Wave Analytica We Find Solutions in Data
  • 2. Outline ▪ Inheritance ▪Method Overriding ▪Constructors During Inheritance ▪SuperClass Methods ▪Information Hiding ▪Non-overriden Methods ▪Creating and Using Interfaces New Wave Analytica
  • 3. Intended Learning Outcomes (ILOs) ▪ Inherit properties of classes in other classes. ▪ Apply user-defined constructors during class inheritance. ▪ Apply appropriate access modifies of class methods in hiding information. ▪ Identify and set non-overriden methods of a class. ▪ Create, implement and reuse an interface. ▪ Create a Java project that exhibit the use of class inheritance, method overriding, and interfaces New Wave Analytica
  • 4. Teaching and Learning Activities (TLAs) ▪ Lecture ▪ Assignment ▪ Program Simulation and Demonstration ▪ Group Discussion ▪ Exercise New Wave Analytica
  • 5. Assessment Tasks (ATs) ▪ Quiz ▪ Exercises ▪ Assignment New Wave Analytica
  • 6. Inheritance ▪ Java / Other OOP Languages ▪Inheritance is a mechanism that enables one class to inherit, or assume, both the behavior and the attributes of another class. ▪Inheritance is the principle that allows you to apply your knowledge of a general category to more specific objects. New Wave Analytica
  • 7. Genetic Inheritance ▪ Genetic ▪Facts / Attributes ▪ Blood type ▪ Eye Color ▪Behavior ▪ Attitude for saving money ▪ Pulling ears when tired New Wave Analytica
  • 8. Termonologies ▪ Base Class / SuperClass / Parent Class ▪Class that is used as basis for inheritance ▪ Derived Class / SubClass / Child Class ▪Class that inherits from a base class New Wave Analytica
  • 9. SuperClass vs SubClass ▪ Size ▪Sublclass is larger that the SuperClass ▪Contains all the fields and methods of the SuperClass ▪Additional fields and methods New Wave Analytica
  • 10. Extending Classes ▪ extends ▪use to achieve inheritance in Java ▪Example ▪EmployeeWithBenefits extends Employee New Wave Analytica
  • 11. Overriding SuperClass Methods ▪ SubClass contains data and methods defined in the SuperClass ▪Any Child Class has all the attributes of its parent. ▪ SuperClass data fields are not entirely appropriate for the SubClass objects. ▪ Override the parent class members New Wave Analytica
  • 12. Calling Constructors During Inheritance ▪ When you instantiate an object that is a member of a subclass, you are actually calling at least two constructors ▪Constructor for the base class ▪Constructor for the derived class ▪When you create any subclass object, the superclass constructor must execute first, and then the subclass constructor executes New Wave Analytica
  • 13. SuperClass Constructors that Require Arguments ▪ When you create a class that do not have a Constructor, Java automatically supplies a default constructor – one that never requires argument. ▪ When you write your own constructor, you replace the automatically supplied version. New Wave Analytica
  • 14. SuperClass Constructors that Require Arguments ▪ Your subclass constructors can contain any number of statements, but if all superclass constructors require arguments, then the first statement within each subclass constructor must call the superclass constructor. New Wave Analytica
  • 15. Format of statement that calls a SuperClass Constructor ▪ super(list of arguments); New Wave Analytica
  • 16. Types of Non-Overriden Methods ▪ static methods ▪ final methods ▪ methods with final class New Wave Analytica
  • 18. Abstract Class ▪ Abstraction refers to the ability to make a class abstract in OOP. ▪An abstract class is one that cannot be instantiated. ▪ All other functionality of the class still exists, and its fields, methods, and constructors are all accessed in the same manner. ▪You just cannot create an instance of the abstract class. New Wave Analytica
  • 19. Extending Two or More Classes ▪ Extending two or more classes is not allowed ▪ Example public class EmployeeWithBenefits extends EmployeeA, EmployeeB New Wave Analytica
  • 20. Information Hiding ▪ Private field data cannot be directly altered by an instance of a class (in another Class) ▪ Example Employee newEmployee = new Employee(); newEmployee.empNumber = 123; ▪ Only methods that are part of the class are allowed to alter a private data. New Wave Analytica
  • 21. Information Hiding ▪ When a class serves as a superclass of other classes, the subclass inherits (use) all the data and methods of the superclass with one exception ▪Private members of a parent class are not accessible within a child’s class methods. New Wave Analytica
  • 22. Information Hiding : Protected ▪ Provides an immediate level of security between public and private access. ▪ Protected fields and methods can only be accessed by its own class and its descendant (subclass) New Wave Analytica
  • 23. Interface ▪ A Java interface is an abstract type used to designate a set of abstract methods for classes to implement. ▪ When a class implements an interface, it must inherit all of the abstract methods declared within, as though signing into a contract and carrying out the agreement. ▪ An interface is a completely abstract class that is used to group related methods with empty bodies. New Wave Analytica
  • 24. Example interface Animal { public void animalSound(); // interface method (does not have a body) public void run(); // interface method (does not have a body) } New Wave Analytica