SlideShare a Scribd company logo
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

PPTX
Abstraction in java
sawarkar17
 
PPTX
Presentation on-exception-handling
Nahian Ahmed
 
PPTX
Packages in java
Elizabeth alexander
 
PPTX
Features of java
WILLFREDJOSE W
 
PPTX
Method overloading
Lovely Professional University
 
PPT
Jsp ppt
Vikas Jagtap
 
PPT
Java Networking
Sunil OS
 
PPTX
Methods in java
chauhankapil
 
Abstraction in java
sawarkar17
 
Presentation on-exception-handling
Nahian Ahmed
 
Packages in java
Elizabeth alexander
 
Features of java
WILLFREDJOSE W
 
Method overloading
Lovely Professional University
 
Jsp ppt
Vikas Jagtap
 
Java Networking
Sunil OS
 
Methods in java
chauhankapil
 

What's hot (20)

PDF
Method Overloading In Java
CharthaGaglani
 
PPSX
JDBC: java DataBase connectivity
Tanmoy Barman
 
PPTX
Exception Handling in Java
lalithambiga kamaraj
 
PPT
Byte stream classes.49
myrajendra
 
PPTX
Exception handling
PhD Research Scholar
 
PPTX
Java exception handling
BHUVIJAYAVELU
 
PPTX
Interface in java
PhD Research Scholar
 
PPTX
Java History
Prionto Abdullah
 
PPT
Java-java virtual machine
Surbhi Panhalkar
 
PPTX
I/O Streams
Ravi Chythanya
 
PPT
Exception handling
Tata Consultancy Services
 
PPT
Introduction to method overloading &amp; method overriding in java hdm
Harshal Misalkar
 
PPT
Java packages
Raja Sekhar
 
PPT
Different approaches to software design
Sandeep Kumar Nayak
 
PPTX
Visibility control in java
Tech_MX
 
PPTX
Presentation on Core java
mahir jain
 
PPTX
Features of java
Hitesh Kumar
 
PPTX
A Bug Tracking System Is A Software Application
Abhishek Pasricha
 
Method Overloading In Java
CharthaGaglani
 
JDBC: java DataBase connectivity
Tanmoy Barman
 
Exception Handling in Java
lalithambiga kamaraj
 
Byte stream classes.49
myrajendra
 
Exception handling
PhD Research Scholar
 
Java exception handling
BHUVIJAYAVELU
 
Interface in java
PhD Research Scholar
 
Java History
Prionto Abdullah
 
Java-java virtual machine
Surbhi Panhalkar
 
I/O Streams
Ravi Chythanya
 
Exception handling
Tata Consultancy Services
 
Introduction to method overloading &amp; method overriding in java hdm
Harshal Misalkar
 
Java packages
Raja Sekhar
 
Different approaches to software design
Sandeep Kumar Nayak
 
Visibility control in java
Tech_MX
 
Presentation on Core java
mahir jain
 
Features of java
Hitesh Kumar
 
A Bug Tracking System Is A Software Application
Abhishek Pasricha
 
Ad

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

PDF
‏‏‏‏‏‏oop lecture 6_١٢٥٩٤٧taiz univercity.pdf
nabeehmohammedtaher
 
PPTX
Interfaces in java
Shiv Mehmi
 
PDF
JAVA PROGRAMMING – Packages - Stream based I/O
Jyothishmathi Institute of Technology and Science Karimnagar
 
PPTX
Unit II Inheritance ,Interface and Packages.pptx
pranalisonawane8600
 
DOCX
Core java questions
Pradheep Ayyanar
 
PPTX
Java 6.pptx
usmanusman720379
 
PPTX
The smartpath information systems java
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
PPTX
Java Interface
Pushpendra Tyagi
 
PPT
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
PDF
Interfaces in java
TharuniDiddekunta
 
DOCX
159747608 a-training-report-on
homeworkping7
 
PDF
Interface
Shantilal Bhayal
 
PPTX
Interface in Java
Ducat India
 
PPTX
java_unitffjfjfjjrdteszserfdffvjyurt_6.pptx
patilrohini0224
 
PPT
Top 10 Interview Questions For Java
EME Technologies
 
PPTX
Java Jive 002.pptx
AdarshSingh202130
 
PDF
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Edureka!
 
PDF
Object Oriented Best Practices - Summary
Ganesh Samarthyam
 
PPTX
Java ocjp level_2
Sayed Ahmed
 
‏‏‏‏‏‏oop lecture 6_١٢٥٩٤٧taiz univercity.pdf
nabeehmohammedtaher
 
Interfaces in java
Shiv Mehmi
 
JAVA PROGRAMMING – Packages - Stream based I/O
Jyothishmathi Institute of Technology and Science Karimnagar
 
Unit II Inheritance ,Interface and Packages.pptx
pranalisonawane8600
 
Core java questions
Pradheep Ayyanar
 
Java 6.pptx
usmanusman720379
 
The smartpath information systems java
The Smartpath Information Systems,Bhilai,Durg,Chhattisgarh.
 
Java Interface
Pushpendra Tyagi
 
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
Interfaces in java
TharuniDiddekunta
 
159747608 a-training-report-on
homeworkping7
 
Interface
Shantilal Bhayal
 
Interface in Java
Ducat India
 
java_unitffjfjfjjrdteszserfdffvjyurt_6.pptx
patilrohini0224
 
Top 10 Interview Questions For Java
EME Technologies
 
Java Jive 002.pptx
AdarshSingh202130
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Edureka!
 
Object Oriented Best Practices - Summary
Ganesh Samarthyam
 
Java ocjp level_2
Sayed Ahmed
 
Ad

More from Edureka! (20)

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

Recently uploaded (20)

PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PPT
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
DevOps & Developer Experience Summer BBQ
AUGNYC
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
This slide provides an overview Technology
mineshkharadi333
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Software Development Methodologies in 2025
KodekX
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
DevOps & Developer Experience Summer BBQ
AUGNYC
 
Doc9.....................................
SofiaCollazos
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 

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.