SlideShare a Scribd company logo
1 of 32
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
HOW TO DECLARE JAVA INTERFACE?
DIFFERENCE BETWEEN INTERFACE AND CLASS
www.edureka.co
WHAT IS A JAVA INTERFACE?
WHAT IS AN INTERFACE?
ADVANTAGES AND DISADVANTAGES OF JAVA INTERFACE
WHY DO WE NEED A JAVA INTERFACE?
WHAT IS AN INTERFACE?
www.edureka.co
• An interface is a shared boundary across which
two or more separate components of a computer
system to exchange information.
• The exchange can be between software,
computer hardware, peripheral devices, humans,
and combinations of these.
www.edureka.co
WHAT IS AN INTERFACE?
WHAT IS A JAVA INTERFACE?
www.edureka.co
Interface is an abstract type that is used to specify a
behavior that all the classes must implement.
WHAT IS A JAVA INTERFACE?
www.edureka.co
WHY DO WE NEED A JAVA INTERFACE?
www.edureka.co
We need Java Interface to overcome the problem of
Multiple inheritance.
WHY DO WE NEED A JAVA INTERFACE?
Super Class
Class C
Class A Class B
www.edureka.co
WHY DO WE NEED A JAVA INTERFACE?
Airplane
Passenger Airplane Cargo Airplane
www.edureka.co
WHY DO WE NEED A JAVA INTERFACE?
Airplane
Passenger Airplane Cargo Airplane
Commercial Airplane
www.edureka.co
WHY DO WE NEED A JAVA INTERFACE?
Passenger Airplane Cargo Airplane
Commercial Airplane
www.edureka.co
WHY DO WE NEED A JAVA INTERFACE?
Passenger Airplane Cargo Airplane
Commercial Airplane
IMPLEMENTING
INTERFACES FOR
CARGO PLANE
www.edureka.co
HOW TO DECLARE A JAVA INTERFACE?
www.edureka.co
HOW TO DECLARE A JAVA INTERFACE?
interface <interface_name> {
// declare constant fields
// declare methods that abstract
// by default.
}
SYNTAX TO DECLARE AN INTERFACE?
www.edureka.co
CLASS V/S INTERFACE
www.edureka.co
Interface supports Multiple Inheritance
Class does not support to Multiple inheritance
Multiple Inheritance
www.edureka.co
Interface does not have Data Members
Class includes Data Members
Data Members
www.edureka.co
Interface does not have Constructors
Class includes Constructors
Constructors
www.edureka.co
Interfaces Includes Incomplete Member(Signature Member)
Class Includes both Complete(Abstract) and Incomplete
Members.
Complete and Incomplete Members
www.edureka.co
www.edureka.co
Interface does not have Access Modifiers
Class includes Access Modifiers
Access Modifiers
www.edureka.co
No member of an Interface is Static
Class has complete Members of the class as Static.
Static Members
ADVANTAGES AND DISADVANTAGES
www.edureka.co
ADVANTAGES AND DISADVANTAGES
• Through interfaces we can implement
multiple inheritance in java.
• Interfaces function to break up the
complex designs and clear the
dependencies between objects.
• Interfaces makes your application
loosely coupled.
ADVANTAGES
www.edureka.co
ADVANTAGES AND DISADVANTAGES
DISADVANTAGES
• Java interfaces are slower and more
limited than other ones.
• Interface should be used multiple
number of times else there is hardly any
use of having them.
• Through interfaces we can implement
multiple inheritance in java.
• Interfaces function to break up the
complex designs and clear the
dependencies between objects.
• Interfaces makes your application
loosely coupled.
ADVANTAGES
www.edureka.co
KEY POINTS
www.edureka.co
KEY POINTS
CAN WE INSTANTIATE AN INTERFACE?
We cannot create the object of an
interface. Hence, We can’t instantiate an
interface in Java.
www.edureka.co
KEY POINTS
ABSTRACTION
Interface provides full abstraction as none
of its methods have body.
www.edureka.co
KEY POINTS
IMPLEMENTING AN INTERFACE?
• The Keyword Implement is used by a class to implement
an Interface.
• The method in an Interface must be provided as Public
before implementing it in any Class.
• Class must implement all the methods declared in an
Interface, or else it must be declared as an Abstract Class.
www.edureka.co
KEY POINTS
ACCESS MODIFIERS IN AN INTERFACE
• Interface cannot be declared as private, protected or transient.
• All the interface methods are by default abstract and public.
• Variables declared in interface are public, static and final by
default.
• Interface variables must be initialized at the time of declaration
otherwise compiler will throw an error.
• Inside any implementation class, you cannot change the
variables declared in interface.
www.edureka.co
KEY POINTS
EXTENDING AN INTERFACE
• An interface can extend any interface but cannot implement it.
• A class can implement any number of interfaces.
• If there are two or more same methods in two interfaces and a
class implements both interfaces, implementation of the method
once is enough.
• A class cannot implement two interfaces that have methods with
same name but different return type.
• Variable names conflicts can be resolved by interface name.
www.edureka.co
Copyright © 2019, edureka and/or its affiliates. All rights reserved.
www.edureka.co

More Related Content

What's hot (20)

Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Access specifiers(modifiers) in java
Access specifiers(modifiers) in javaAccess specifiers(modifiers) in java
Access specifiers(modifiers) in java
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 
Friend function
Friend functionFriend function
Friend function
 
Java 8 - Features Overview
Java 8 - Features OverviewJava 8 - Features Overview
Java 8 - Features Overview
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
 
Spring annotation
Spring annotationSpring annotation
Spring annotation
 
Data Types & Variables in JAVA
Data Types & Variables in JAVAData Types & Variables in JAVA
Data Types & Variables in JAVA
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
 
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification...
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Java swing
Java swingJava swing
Java swing
 
Java DataBase Connectivity API (JDBC API)
Java DataBase Connectivity API (JDBC API)Java DataBase Connectivity API (JDBC API)
Java DataBase Connectivity API (JDBC API)
 
Java features
Java featuresJava features
Java features
 

Similar to What is Interface in Java | How to implement Multiple Inheritance Using Interface | Edureka

Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in javaShiv Mehmi
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singhdheeraj_cse
 
159747608 a-training-report-on
159747608 a-training-report-on159747608 a-training-report-on
159747608 a-training-report-onhomeworkping7
 
Interface in Java
Interface in JavaInterface in Java
Interface in JavaDucat India
 
Top 10 Interview Questions For Java
Top 10 Interview Questions For JavaTop 10 Interview Questions For Java
Top 10 Interview Questions For JavaEME Technologies
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Edureka!
 
Object Oriented Best Practices - Summary
Object Oriented Best Practices - SummaryObject Oriented Best Practices - Summary
Object Oriented Best Practices - SummaryGanesh Samarthyam
 
Java ocjp level_2
Java ocjp level_2Java ocjp level_2
Java ocjp level_2Sayed Ahmed
 
OOFeatures_revised-2.pptx
OOFeatures_revised-2.pptxOOFeatures_revised-2.pptx
OOFeatures_revised-2.pptxssuser84e52e
 
Automation Testing - Part 2 (Things to know in JAVA) - SLT
Automation Testing - Part 2 (Things to know in JAVA) - SLTAutomation Testing - Part 2 (Things to know in JAVA) - SLT
Automation Testing - Part 2 (Things to know in JAVA) - SLTAnkit Prajapati
 
Automation Testing - Part 2 (Things to know in JAVA) - SLT
Automation Testing - Part 2 (Things to know in JAVA) - SLTAutomation Testing - Part 2 (Things to know in JAVA) - SLT
Automation Testing - Part 2 (Things to know in JAVA) - SLTAnkit Prajapati
 

Similar to What is Interface in Java | How to implement Multiple Inheritance Using Interface | Edureka (20)

Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O
 
Core java questions
Core java questionsCore java questions
Core java questions
 
Java 6.pptx
Java 6.pptxJava 6.pptx
Java 6.pptx
 
The smartpath information systems java
The smartpath information systems javaThe smartpath information systems java
The smartpath information systems java
 
Java Interface
Java InterfaceJava Interface
Java Interface
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
 
Unit 4
Unit 4Unit 4
Unit 4
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
159747608 a-training-report-on
159747608 a-training-report-on159747608 a-training-report-on
159747608 a-training-report-on
 
Interface
InterfaceInterface
Interface
 
Interface in Java
Interface in JavaInterface in Java
Interface in Java
 
Top 10 Interview Questions For Java
Top 10 Interview Questions For JavaTop 10 Interview Questions For Java
Top 10 Interview Questions For Java
 
Java Jive 002.pptx
Java Jive 002.pptxJava Jive 002.pptx
Java Jive 002.pptx
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
 
Object Oriented Best Practices - Summary
Object Oriented Best Practices - SummaryObject Oriented Best Practices - Summary
Object Oriented Best Practices - Summary
 
Java ocjp level_2
Java ocjp level_2Java ocjp level_2
Java ocjp level_2
 
OOFeatures_revised-2.pptx
OOFeatures_revised-2.pptxOOFeatures_revised-2.pptx
OOFeatures_revised-2.pptx
 
Automation Testing - Part 2 (Things to know in JAVA) - SLT
Automation Testing - Part 2 (Things to know in JAVA) - SLTAutomation Testing - Part 2 (Things to know in JAVA) - SLT
Automation Testing - Part 2 (Things to know in JAVA) - SLT
 
Automation Testing - Part 2 (Things to know in JAVA) - SLT
Automation Testing - Part 2 (Things to know in JAVA) - SLTAutomation Testing - Part 2 (Things to know in JAVA) - SLT
Automation Testing - Part 2 (Things to know in JAVA) - SLT
 

More from Edureka!

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaEdureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaEdureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaEdureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaEdureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaEdureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaEdureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaEdureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaEdureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaEdureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaEdureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | EdurekaEdureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEdureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEdureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaEdureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaEdureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaEdureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaEdureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaEdureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | EdurekaEdureka!
 

More from Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 

What is Interface in Java | How to implement Multiple Inheritance Using Interface | Edureka

  • 1. Copyright © 2017, edureka and/or its affiliates. All rights reserved.
  • 2. HOW TO DECLARE JAVA INTERFACE? DIFFERENCE BETWEEN INTERFACE AND CLASS www.edureka.co WHAT IS A JAVA INTERFACE? WHAT IS AN INTERFACE? ADVANTAGES AND DISADVANTAGES OF JAVA INTERFACE WHY DO WE NEED A JAVA INTERFACE?
  • 3. WHAT IS AN INTERFACE? www.edureka.co
  • 4. • An interface is a shared boundary across which two or more separate components of a computer system to exchange information. • The exchange can be between software, computer hardware, peripheral devices, humans, and combinations of these. www.edureka.co WHAT IS AN INTERFACE?
  • 5. WHAT IS A JAVA INTERFACE? www.edureka.co
  • 6. Interface is an abstract type that is used to specify a behavior that all the classes must implement. WHAT IS A JAVA INTERFACE? www.edureka.co
  • 7. WHY DO WE NEED A JAVA INTERFACE? www.edureka.co
  • 8. We need Java Interface to overcome the problem of Multiple inheritance. WHY DO WE NEED A JAVA INTERFACE? Super Class Class C Class A Class B www.edureka.co
  • 9. WHY DO WE NEED A JAVA INTERFACE? Airplane Passenger Airplane Cargo Airplane www.edureka.co
  • 10. WHY DO WE NEED A JAVA INTERFACE? Airplane Passenger Airplane Cargo Airplane Commercial Airplane www.edureka.co
  • 11. WHY DO WE NEED A JAVA INTERFACE? Passenger Airplane Cargo Airplane Commercial Airplane www.edureka.co
  • 12. WHY DO WE NEED A JAVA INTERFACE? Passenger Airplane Cargo Airplane Commercial Airplane IMPLEMENTING INTERFACES FOR CARGO PLANE www.edureka.co
  • 13. HOW TO DECLARE A JAVA INTERFACE? www.edureka.co
  • 14. HOW TO DECLARE A JAVA INTERFACE? interface <interface_name> { // declare constant fields // declare methods that abstract // by default. } SYNTAX TO DECLARE AN INTERFACE? www.edureka.co
  • 16. Interface supports Multiple Inheritance Class does not support to Multiple inheritance Multiple Inheritance www.edureka.co
  • 17. Interface does not have Data Members Class includes Data Members Data Members www.edureka.co
  • 18. Interface does not have Constructors Class includes Constructors Constructors www.edureka.co
  • 19. Interfaces Includes Incomplete Member(Signature Member) Class Includes both Complete(Abstract) and Incomplete Members. Complete and Incomplete Members www.edureka.co
  • 20. www.edureka.co Interface does not have Access Modifiers Class includes Access Modifiers Access Modifiers
  • 21. www.edureka.co No member of an Interface is Static Class has complete Members of the class as Static. Static Members
  • 23. ADVANTAGES AND DISADVANTAGES • Through interfaces we can implement multiple inheritance in java. • Interfaces function to break up the complex designs and clear the dependencies between objects. • Interfaces makes your application loosely coupled. ADVANTAGES www.edureka.co
  • 24. ADVANTAGES AND DISADVANTAGES DISADVANTAGES • Java interfaces are slower and more limited than other ones. • Interface should be used multiple number of times else there is hardly any use of having them. • Through interfaces we can implement multiple inheritance in java. • Interfaces function to break up the complex designs and clear the dependencies between objects. • Interfaces makes your application loosely coupled. ADVANTAGES www.edureka.co
  • 26. KEY POINTS CAN WE INSTANTIATE AN INTERFACE? We cannot create the object of an interface. Hence, We can’t instantiate an interface in Java. www.edureka.co
  • 27. KEY POINTS ABSTRACTION Interface provides full abstraction as none of its methods have body. www.edureka.co
  • 28. KEY POINTS IMPLEMENTING AN INTERFACE? • The Keyword Implement is used by a class to implement an Interface. • The method in an Interface must be provided as Public before implementing it in any Class. • Class must implement all the methods declared in an Interface, or else it must be declared as an Abstract Class. www.edureka.co
  • 29. KEY POINTS ACCESS MODIFIERS IN AN INTERFACE • Interface cannot be declared as private, protected or transient. • All the interface methods are by default abstract and public. • Variables declared in interface are public, static and final by default. • Interface variables must be initialized at the time of declaration otherwise compiler will throw an error. • Inside any implementation class, you cannot change the variables declared in interface. www.edureka.co
  • 30. KEY POINTS EXTENDING AN INTERFACE • An interface can extend any interface but cannot implement it. • A class can implement any number of interfaces. • If there are two or more same methods in two interfaces and a class implements both interfaces, implementation of the method once is enough. • A class cannot implement two interfaces that have methods with same name but different return type. • Variable names conflicts can be resolved by interface name. www.edureka.co
  • 31. Copyright © 2019, edureka and/or its affiliates. All rights reserved.