SlideShare a Scribd company logo
1 of 15
Interface
- ABBHIRAMI.M
What is an interface?
• Fully abstract class
• It is syntactically similar to class. It contains only method declaration.
• Once it is defined, any number of classes can implement an interface.
• A class can implement any no of interface.
•A class which implements the interface must define all methods in
interface.
• Interface supports dynamic method resolution at run time.
Defining an interface
Access interface interface_name
{
return-type method-name(parameter);
return-type method-name(parameter);
type final-variable-name = 10;
}
Main concept
• Methods are abstract by default.
• Variables are final and static by default.
• If an interface is declared as public, then method and variables
inside the interface declaration are public.
Implementing Interface
Access class class_name [extends class] [implements interface1,in2,…n]
{
class body//
}
• Once an interface is defined, one or more class can implement it. Using the
keyword “implements”
• If a class implements more interfaces then they should be separated by
comma.
• Methods in the interface must be contained in the class. Methods used inside
the class should be defined with a keyword “public”.
• Method signature in declaration & definition must be same.
interface sample
{
void display(int q);
}
Class Demo implements sample
{
public void display(int x)
{
System.out.println(x);
}
void printDetail()
{
System.out.println(“class method”);
}
}
Class d
{
public static void main(String arg[])throws IOException
{
Demo s = new Demo();
s. display(10);
s. printDetail()
}
}
Class Demo implements sample
{
public void display(int x)
{
System.out.println(x);
}
}
Class Demo1 implements sample
{
public void display(int x)
{
System.out.println(“another : “ + x);
System.out.println(“===============“);
}
}
Class d
{
public static void main(String arg[])
{
sample s = new Demo();
Demo1 d1=new Demo1();
s. display(10); // method in demo
s=d1;
s. display(10); // method in demo1
}
}
Partial Implementation
• If a class doesn’t define all the methods in interface, then the class
must be declared as abstract.
Variable in an interface
• If we want to share constants to more classes, interface can be used.
Interface variable
Example
{
float pi=3.14;
int flag=1;
}
Interfaces can be extended
Interface A
{
void display();
}
Interface B extends A
{
void display2();
}
Conclusion
• So for now in these slides we have discussed about a small topic
named “interface”.
• Hope you get a little bit of what interface exactly is.

More Related Content

What's hot

Xamarin: Namespace and Classes
Xamarin: Namespace and ClassesXamarin: Namespace and Classes
Xamarin: Namespace and ClassesEng Teong Cheah
 
Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear ASHNA nadhm
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Nuzhat Memon
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methodsShubham Dwivedi
 
Java interfaces
Java interfacesJava interfaces
Java interfacesjehan1987
 
Classes, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with JavaClasses, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with JavaRadhika Talaviya
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in javaAhsan Raja
 
06 abstract-classes
06 abstract-classes06 abstract-classes
06 abstract-classesAnup Burange
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentationtigerwarn
 
Main method in java
Main method in javaMain method in java
Main method in javaHitesh Kumar
 

What's hot (20)

Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Xamarin: Namespace and Classes
Xamarin: Namespace and ClassesXamarin: Namespace and Classes
Xamarin: Namespace and Classes
 
Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear Inheritance and Polymorphism in java simple and clear
Inheritance and Polymorphism in java simple and clear
 
Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)Std 12 computer chapter 8 classes and object in java (part 2)
Std 12 computer chapter 8 classes and object in java (part 2)
 
Abstract classes
Abstract classesAbstract classes
Abstract classes
 
Java interface
Java interfaceJava interface
Java interface
 
Interfaces
InterfacesInterfaces
Interfaces
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Classes, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with JavaClasses, Objects and Method - Object Oriented Programming with Java
Classes, Objects and Method - Object Oriented Programming with Java
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
06 abstract-classes
06 abstract-classes06 abstract-classes
06 abstract-classes
 
Abstract Class Presentation
Abstract Class PresentationAbstract Class Presentation
Abstract Class Presentation
 
Main method in java
Main method in javaMain method in java
Main method in java
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Abstract method
Abstract methodAbstract method
Abstract method
 
Java Interface
Java InterfaceJava Interface
Java Interface
 
Inheritance
InheritanceInheritance
Inheritance
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 

Viewers also liked

Online show ppt
Online show pptOnline show ppt
Online show pptvikasdenim
 
Introducing Kolaboraksi.com
Introducing Kolaboraksi.comIntroducing Kolaboraksi.com
Introducing Kolaboraksi.comkolaboraksicom
 
[Lecture]ux_business*design(in english)
[Lecture]ux_business*design(in english)[Lecture]ux_business*design(in english)
[Lecture]ux_business*design(in english)Yuichi Inobori
 
How to setup facebook ad manager account?
How to setup facebook ad manager account?How to setup facebook ad manager account?
How to setup facebook ad manager account?PPC TAG
 
Albert Einstein-By: U San Lwin
Albert Einstein-By: U San LwinAlbert Einstein-By: U San Lwin
Albert Einstein-By: U San LwinLehkhabu Khawvel
 
Goal setting
Goal settingGoal setting
Goal settingxeef
 
Lesson plan (ancy joy)
Lesson plan (ancy joy)Lesson plan (ancy joy)
Lesson plan (ancy joy)ganga124
 
Ehab Mahmoud El Maadawi 2013
Ehab Mahmoud El Maadawi 2013Ehab Mahmoud El Maadawi 2013
Ehab Mahmoud El Maadawi 2013ehab l maadawi
 
Державна підтримка термомодернізацій житлових будівель в Україні
Державна підтримка термомодернізацій житлових будівель в УкраїніДержавна підтримка термомодернізацій житлових будівель в Україні
Державна підтримка термомодернізацій житлових будівель в УкраїніOleg Tymchenko
 

Viewers also liked (16)

Online show ppt
Online show pptOnline show ppt
Online show ppt
 
Introducing Kolaboraksi.com
Introducing Kolaboraksi.comIntroducing Kolaboraksi.com
Introducing Kolaboraksi.com
 
[Lecture]ux_business*design(in english)
[Lecture]ux_business*design(in english)[Lecture]ux_business*design(in english)
[Lecture]ux_business*design(in english)
 
How to setup facebook ad manager account?
How to setup facebook ad manager account?How to setup facebook ad manager account?
How to setup facebook ad manager account?
 
28 10 2015
28 10 201528 10 2015
28 10 2015
 
Albert Einstein-By: U San Lwin
Albert Einstein-By: U San LwinAlbert Einstein-By: U San Lwin
Albert Einstein-By: U San Lwin
 
OAuth
OAuthOAuth
OAuth
 
Goal setting
Goal settingGoal setting
Goal setting
 
Організація та проведення Всеукраїнського конкурсу “УЧИТЕЛЬ РОКУ - 2016”
Організація  та проведення Всеукраїнського конкурсу “УЧИТЕЛЬ РОКУ - 2016”Організація  та проведення Всеукраїнського конкурсу “УЧИТЕЛЬ РОКУ - 2016”
Організація та проведення Всеукраїнського конкурсу “УЧИТЕЛЬ РОКУ - 2016”
 
Lesson plan (ancy joy)
Lesson plan (ancy joy)Lesson plan (ancy joy)
Lesson plan (ancy joy)
 
PROFILE
PROFILEPROFILE
PROFILE
 
Ehab Mahmoud El Maadawi 2013
Ehab Mahmoud El Maadawi 2013Ehab Mahmoud El Maadawi 2013
Ehab Mahmoud El Maadawi 2013
 
Climate change
Climate changeClimate change
Climate change
 
Profile
ProfileProfile
Profile
 
Державна підтримка термомодернізацій житлових будівель в Україні
Державна підтримка термомодернізацій житлових будівель в УкраїніДержавна підтримка термомодернізацій житлових будівель в Україні
Державна підтримка термомодернізацій житлових будівель в Україні
 
SITAN_Bdos copy
SITAN_Bdos copySITAN_Bdos copy
SITAN_Bdos copy
 

Similar to Interface

Interface
InterfaceInterface
Interfacevvpadhu
 
21UCAC31 Java Programming.pdf(MTNC)(BCA)
21UCAC31 Java Programming.pdf(MTNC)(BCA)21UCAC31 Java Programming.pdf(MTNC)(BCA)
21UCAC31 Java Programming.pdf(MTNC)(BCA)ssuser7f90ae
 
oops with java modules i & ii.ppt
oops with java modules i & ii.pptoops with java modules i & ii.ppt
oops with java modules i & ii.pptrani marri
 
12.2 Abstract class and Interface.ppt
12.2 Abstract class and Interface.ppt12.2 Abstract class and Interface.ppt
12.2 Abstract class and Interface.pptVISHNUSHANKARSINGH3
 
Abstraction in Java: Abstract class and Interfaces
Abstraction in  Java: Abstract class and InterfacesAbstraction in  Java: Abstract class and Interfaces
Abstraction in Java: Abstract class and InterfacesJamsher bhanbhro
 
Exception handling and packages.pdf
Exception handling and packages.pdfException handling and packages.pdf
Exception handling and packages.pdfKp Sharma
 
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...yazad dumasia
 
2CPP14 - Abstraction
2CPP14 - Abstraction2CPP14 - Abstraction
2CPP14 - AbstractionMichael Heron
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
Unit3 packages & interfaces
Unit3 packages & interfacesUnit3 packages & interfaces
Unit3 packages & interfacesKalai Selvi
 
Java class 4
Java class 4Java class 4
Java class 4Edureka!
 
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
 
8abstact class in c#
8abstact class in c#8abstact class in c#
8abstact class in c#Sireesh K
 
abstract,final,interface (1).pptx upload
abstract,final,interface (1).pptx uploadabstract,final,interface (1).pptx upload
abstract,final,interface (1).pptx uploaddashpayal697
 

Similar to Interface (20)

Interface
InterfaceInterface
Interface
 
21UCAC31 Java Programming.pdf(MTNC)(BCA)
21UCAC31 Java Programming.pdf(MTNC)(BCA)21UCAC31 Java Programming.pdf(MTNC)(BCA)
21UCAC31 Java Programming.pdf(MTNC)(BCA)
 
oops with java modules i & ii.ppt
oops with java modules i & ii.pptoops with java modules i & ii.ppt
oops with java modules i & ii.ppt
 
12.2 Abstract class and Interface.ppt
12.2 Abstract class and Interface.ppt12.2 Abstract class and Interface.ppt
12.2 Abstract class and Interface.ppt
 
Interface
InterfaceInterface
Interface
 
Java interface
Java interfaceJava interface
Java interface
 
Abstraction in Java: Abstract class and Interfaces
Abstraction in  Java: Abstract class and InterfacesAbstraction in  Java: Abstract class and Interfaces
Abstraction in Java: Abstract class and Interfaces
 
Exception handling and packages.pdf
Exception handling and packages.pdfException handling and packages.pdf
Exception handling and packages.pdf
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Abstraction
AbstractionAbstraction
Abstraction
 
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
 
Packaes & interfaces
Packaes & interfacesPackaes & interfaces
Packaes & interfaces
 
2CPP14 - Abstraction
2CPP14 - Abstraction2CPP14 - Abstraction
2CPP14 - Abstraction
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Unit3 packages & interfaces
Unit3 packages & interfacesUnit3 packages & interfaces
Unit3 packages & interfaces
 
Java class 4
Java class 4Java class 4
Java class 4
 
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
 
8abstact class in c#
8abstact class in c#8abstact class in c#
8abstact class in c#
 
abstract,final,interface (1).pptx upload
abstract,final,interface (1).pptx uploadabstract,final,interface (1).pptx upload
abstract,final,interface (1).pptx upload
 
Lecture 18
Lecture 18Lecture 18
Lecture 18
 

More from Muthiah Abbhirami

Blockchain in adminstration muthiah abbhirami
Blockchain in adminstration   muthiah abbhiramiBlockchain in adminstration   muthiah abbhirami
Blockchain in adminstration muthiah abbhiramiMuthiah Abbhirami
 
Holistic utilization managment muthiah abbhirami
Holistic utilization managment  muthiah abbhiramiHolistic utilization managment  muthiah abbhirami
Holistic utilization managment muthiah abbhiramiMuthiah Abbhirami
 
Entrepreneurial resilience what makes entreprenuer start another business aft...
Entrepreneurial resilience what makes entreprenuer start another business aft...Entrepreneurial resilience what makes entreprenuer start another business aft...
Entrepreneurial resilience what makes entreprenuer start another business aft...Muthiah Abbhirami
 
Impact Of Demonetization in IT sector - India
Impact Of Demonetization in IT sector - India Impact Of Demonetization in IT sector - India
Impact Of Demonetization in IT sector - India Muthiah Abbhirami
 
Data structures and Big O notation
Data structures and Big O notationData structures and Big O notation
Data structures and Big O notationMuthiah Abbhirami
 

More from Muthiah Abbhirami (6)

Blockchain in adminstration muthiah abbhirami
Blockchain in adminstration   muthiah abbhiramiBlockchain in adminstration   muthiah abbhirami
Blockchain in adminstration muthiah abbhirami
 
Holistic utilization managment muthiah abbhirami
Holistic utilization managment  muthiah abbhiramiHolistic utilization managment  muthiah abbhirami
Holistic utilization managment muthiah abbhirami
 
Entrepreneurial resilience what makes entreprenuer start another business aft...
Entrepreneurial resilience what makes entreprenuer start another business aft...Entrepreneurial resilience what makes entreprenuer start another business aft...
Entrepreneurial resilience what makes entreprenuer start another business aft...
 
Impact Of Demonetization in IT sector - India
Impact Of Demonetization in IT sector - India Impact Of Demonetization in IT sector - India
Impact Of Demonetization in IT sector - India
 
Data structures and Big O notation
Data structures and Big O notationData structures and Big O notation
Data structures and Big O notation
 
Cloud and only cloud
Cloud and only cloudCloud and only cloud
Cloud and only cloud
 

Recently uploaded

KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
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
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
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
 
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
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
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.
 
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
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 

Recently uploaded (20)

KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
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
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
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
 
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
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
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
 
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
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
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...
 

Interface

  • 2. What is an interface? • Fully abstract class • It is syntactically similar to class. It contains only method declaration. • Once it is defined, any number of classes can implement an interface.
  • 3. • A class can implement any no of interface. •A class which implements the interface must define all methods in interface. • Interface supports dynamic method resolution at run time.
  • 4. Defining an interface Access interface interface_name { return-type method-name(parameter); return-type method-name(parameter); type final-variable-name = 10; }
  • 5. Main concept • Methods are abstract by default. • Variables are final and static by default. • If an interface is declared as public, then method and variables inside the interface declaration are public.
  • 6. Implementing Interface Access class class_name [extends class] [implements interface1,in2,…n] { class body// }
  • 7. • Once an interface is defined, one or more class can implement it. Using the keyword “implements” • If a class implements more interfaces then they should be separated by comma. • Methods in the interface must be contained in the class. Methods used inside the class should be defined with a keyword “public”. • Method signature in declaration & definition must be same.
  • 8. interface sample { void display(int q); } Class Demo implements sample { public void display(int x) { System.out.println(x); } void printDetail() { System.out.println(“class method”); } }
  • 9. Class d { public static void main(String arg[])throws IOException { Demo s = new Demo(); s. display(10); s. printDetail() } }
  • 10. Class Demo implements sample { public void display(int x) { System.out.println(x); } } Class Demo1 implements sample { public void display(int x) { System.out.println(“another : “ + x); System.out.println(“===============“); } }
  • 11. Class d { public static void main(String arg[]) { sample s = new Demo(); Demo1 d1=new Demo1(); s. display(10); // method in demo s=d1; s. display(10); // method in demo1 } }
  • 12. Partial Implementation • If a class doesn’t define all the methods in interface, then the class must be declared as abstract.
  • 13. Variable in an interface • If we want to share constants to more classes, interface can be used. Interface variable Example { float pi=3.14; int flag=1; }
  • 14. Interfaces can be extended Interface A { void display(); } Interface B extends A { void display2(); }
  • 15. Conclusion • So for now in these slides we have discussed about a small topic named “interface”. • Hope you get a little bit of what interface exactly is.