SlideShare a Scribd company logo
1 of 19
Download to read offline
BABA GHULAM SHAH BADSHAH UNIVERSITY (RAJOURI)
AJEELA MUSHTAQ
BABA GHULAM SHAH BADSHAH
UNIVERSITY- RAJOURI (J&K).
DEPARTMENT OF COMPUTER
SCIENCES
PRESENTATION TOPIC:-
PRESENTED BY:-
Ajeela Mushtaq Roll NO:-13-Mcs-15
PRESENTED TO:-
MR MIRZA WASEEM
INTERFACES
OUTLINE :
• INHERITANCE
• TYPES
• INTERFACES
DEFINING AN INTERFACE
EXTENDING AN INTERFACE
IMPLEMENTING INTERFACES
Inheritance
• The mechanism of deriving a new class from an old one
is called inheritance.
• The old class is referred to as the base class and the
new one is called the derived class or sub-class.
• A derived class can inherits some or all of the traits
from the base class.
Types
• Single inheritance:
A derived class with only one base class is
called single inheritance.
• Multiple inheritance:
A derived class with several base classes is
called multiple inheritance.
• Multi-level inheritance:
The mechanism of deriving a class from
another ‘derived class’.
• Hierarchical inheritance:
A derived class in which the traits of one
class may be inherited by more than one class.
• This is combination of more than one inheritance.
• Hence, it may be a combination of Multilevel and
Multiple inheritance or Hierarchical and Multilevel
inheritance or Hierarchical , Multilevel and Multiple
inheritance.
Hybrid inheritance:
INTERFACE
• An interface can contain one or more
methods,properties,indexers and events but none of
them are implemented in the interface itself.
• It is the responsibility of the class that implements the
interface to define the code for implementation of these
members.
• Syntax
interface interfacename
member declarations
EXTENDING AN INTERFACE
• Like classes, interfaces can also be extended. That is,
an interface can be subinterfaced from other interfaces.
• The new subinterface will inherit all the members of the
superinterface in the manner similar to subclasses.
interface name2 : name1
members of name2
• Interfaces are allowed to extend other interfaces,
subinterfaces cannot define the methods declared in
the superinterfaces.
• It is the responsibility of the class that implements the
derived interface to define all the methods.
• It is important to remember that an interface cannot
extend classes.
IMPLEMENTING INTERFACES
• Interfaces are used as ‘superclasses’ whose properties
are inherited by classes.
• It is therefore necessary to create a class that inherits
the given interface.
class classname : interfacename
body of classname
• Here the class classname ‘implements’ the interface
interfacename. a more general form of
implementation may look like this :
class classname : superclass, interface1,
interface2….
body of class name
This shows that a class can extend another class while
using system;
interface Addition
int Add ();
interface Multiplication
int Mul ();
Class Computation : Addition, Multiplication
int x, y;
public Computation(int x, int y) //constructor
this.x = x;
this.y = y;
Public int Add () // implement Add ()
return (x + y);
Public int Mul () // implement Mul ()
return (x * y);
Class InterfaceTest1
public Static void Main()
computation com = new computation (10,20);
Addition add = (Addition) com;
//casting
Console.WriteLine (“Sum = “ + add.Add () );
Multiplication mul = (Multiplication) com;
//casting
Console.WriteLine(“Product = “ + mul.Mul () );
Output
sum = 30
product = 200
Properties….
• All the members of an interface are implicitly public
and abstract.
• An interface cannot contain constant fields ,constructors
and destructors.
• Its members cannot be declared static.
• Since the method in an interface are abstract, they do
not include implementation code.
• An interface can inherit multiple interfaces.
Thank you…!
Have a nice day
19

More Related Content

What's hot

Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaRahulAnanda1
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In JavaMD SALEEM QAISAR
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statementsKuppusamy P
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
Java script errors & exceptions handling
Java script  errors & exceptions handlingJava script  errors & exceptions handling
Java script errors & exceptions handlingAbhishekMondal42
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++Sujan Mia
 
Control structures in java
Control structures in javaControl structures in java
Control structures in javaVINOTH R
 

What's hot (20)

Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Java arrays
Java arraysJava arrays
Java arrays
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Inheritance and its types In Java
Inheritance and its types In JavaInheritance and its types In Java
Inheritance and its types In Java
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Java interface
Java interfaceJava interface
Java interface
 
Exception handling
Exception handlingException handling
Exception handling
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Delegates in C#
Delegates in C#Delegates in C#
Delegates in C#
 
Java script errors & exceptions handling
Java script  errors & exceptions handlingJava script  errors & exceptions handling
Java script errors & exceptions handling
 
Java IO
Java IOJava IO
Java IO
 
Interface
InterfaceInterface
Interface
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 

Similar to Interfaces .net (20)

Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
 
L7 inheritance
L7 inheritanceL7 inheritance
L7 inheritance
 
L7 inheritance
L7 inheritanceL7 inheritance
L7 inheritance
 
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
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Ch5 inheritance
Ch5 inheritanceCh5 inheritance
Ch5 inheritance
 
UNIT 5.pptx
UNIT 5.pptxUNIT 5.pptx
UNIT 5.pptx
 
Oops
OopsOops
Oops
 
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
 
Unit3 part2-inheritance
Unit3 part2-inheritanceUnit3 part2-inheritance
Unit3 part2-inheritance
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
Inheritance & Polymorphism - 1
Inheritance & Polymorphism - 1Inheritance & Polymorphism - 1
Inheritance & Polymorphism - 1
 
INHERITANCE.pptx
INHERITANCE.pptxINHERITANCE.pptx
INHERITANCE.pptx
 
lecture 6.pdf
lecture 6.pdflecture 6.pdf
lecture 6.pdf
 
Java - Inheritance Concepts
Java - Inheritance ConceptsJava - Inheritance Concepts
Java - Inheritance Concepts
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
 

More from ajeela mushtaq (12)

String.ppt
String.pptString.ppt
String.ppt
 
Sets automata
Sets automataSets automata
Sets automata
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Mail merge
Mail mergeMail merge
Mail merge
 
Linux hotspot
Linux hotspotLinux hotspot
Linux hotspot
 
Incremental
IncrementalIncremental
Incremental
 
Gprs
GprsGprs
Gprs
 
Graphics a buffer
Graphics a bufferGraphics a buffer
Graphics a buffer
 
Disk allocation methods
Disk allocation methodsDisk allocation methods
Disk allocation methods
 
Data com prsntation
Data com prsntationData com prsntation
Data com prsntation
 
Avl tree
Avl treeAvl tree
Avl tree
 
Dynamic routing
Dynamic routingDynamic routing
Dynamic routing
 

Recently uploaded

Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 

Recently uploaded (20)

Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in  Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Jamuna Vihar Delhi reach out to us at 🔝9953056974🔝
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 

Interfaces .net

  • 1. BABA GHULAM SHAH BADSHAH UNIVERSITY (RAJOURI) AJEELA MUSHTAQ
  • 2. BABA GHULAM SHAH BADSHAH UNIVERSITY- RAJOURI (J&K). DEPARTMENT OF COMPUTER SCIENCES PRESENTATION TOPIC:- PRESENTED BY:- Ajeela Mushtaq Roll NO:-13-Mcs-15 PRESENTED TO:- MR MIRZA WASEEM INTERFACES
  • 3. OUTLINE : • INHERITANCE • TYPES • INTERFACES DEFINING AN INTERFACE EXTENDING AN INTERFACE IMPLEMENTING INTERFACES
  • 4. Inheritance • The mechanism of deriving a new class from an old one is called inheritance. • The old class is referred to as the base class and the new one is called the derived class or sub-class. • A derived class can inherits some or all of the traits from the base class.
  • 5. Types • Single inheritance: A derived class with only one base class is called single inheritance.
  • 6. • Multiple inheritance: A derived class with several base classes is called multiple inheritance.
  • 7. • Multi-level inheritance: The mechanism of deriving a class from another ‘derived class’.
  • 8. • Hierarchical inheritance: A derived class in which the traits of one class may be inherited by more than one class.
  • 9. • This is combination of more than one inheritance. • Hence, it may be a combination of Multilevel and Multiple inheritance or Hierarchical and Multilevel inheritance or Hierarchical , Multilevel and Multiple inheritance. Hybrid inheritance:
  • 10. INTERFACE • An interface can contain one or more methods,properties,indexers and events but none of them are implemented in the interface itself. • It is the responsibility of the class that implements the interface to define the code for implementation of these members.
  • 12. EXTENDING AN INTERFACE • Like classes, interfaces can also be extended. That is, an interface can be subinterfaced from other interfaces. • The new subinterface will inherit all the members of the superinterface in the manner similar to subclasses. interface name2 : name1 members of name2
  • 13. • Interfaces are allowed to extend other interfaces, subinterfaces cannot define the methods declared in the superinterfaces. • It is the responsibility of the class that implements the derived interface to define all the methods. • It is important to remember that an interface cannot extend classes.
  • 14. IMPLEMENTING INTERFACES • Interfaces are used as ‘superclasses’ whose properties are inherited by classes. • It is therefore necessary to create a class that inherits the given interface. class classname : interfacename body of classname
  • 15. • Here the class classname ‘implements’ the interface interfacename. a more general form of implementation may look like this : class classname : superclass, interface1, interface2…. body of class name This shows that a class can extend another class while
  • 16. using system; interface Addition int Add (); interface Multiplication int Mul (); Class Computation : Addition, Multiplication int x, y; public Computation(int x, int y) //constructor this.x = x; this.y = y; Public int Add () // implement Add () return (x + y); Public int Mul () // implement Mul () return (x * y); Class InterfaceTest1 public Static void Main() computation com = new computation (10,20); Addition add = (Addition) com; //casting Console.WriteLine (“Sum = “ + add.Add () ); Multiplication mul = (Multiplication) com; //casting Console.WriteLine(“Product = “ + mul.Mul () );
  • 18. Properties…. • All the members of an interface are implicitly public and abstract. • An interface cannot contain constant fields ,constructors and destructors. • Its members cannot be declared static. • Since the method in an interface are abstract, they do not include implementation code. • An interface can inherit multiple interfaces.
  • 19. Thank you…! Have a nice day 19