Object oriented programming concepts-Session 5
Object oriented programming concepts-Session 5
nl
O
se
U
tre
en
Session: 5 C
h
ec
Interfaces
Fo
O
se
List the problems associated with Multiple Inheritance
U
Describe Interface
tre
en
Explain Multiple Inheritance using Interfaces
C
Explain constructor execution in Multiple Inheritance
h
ec
pt
rA
Fo
se
relationships between classes
U
tre
en
Explains creation of a class by combination of other
classes
C
h
ec
pt
O
properties from more than one classes.
se
The figure shows an example of multiple inheritance.
U
tre
en
C
h
ec
pt
rA
Fo
O
hierarchy created by the three classes namely
se
Herbivore, Carnivore, and Omnivore.
U
tre
en
C
h
ec
pt
rA
Fo
O
parent classes each of which in turn inherit from a
se
common super class.
U
The figure depicts the diamond problem.
tre
en
C
h
ec
pt
rA
Fo
O
with the same name and signature.
se
The figure depicts the name ambiguity problem.
U
tre
en
C
h
ec
pt
rA
Fo
O
methods it wishes to expose.
se
Syntax
U
tre
<visibility-modifier> interface
en
<interface-name>
{
C
// abstract method declarations
h
ec
}
pt
rA
Fo
O
class and an interface.
se
Class Interface
U
A class can be instantiated An interface cannot be instantiated
tre
A class can have concreted methods, An interface cannot have concrete
that is, methods with a body methods
en
A child class may not override all A class implementing an Interface must
methods of a parent class
Multiple classes cannot be inherited by a
C implement all methods of an interface
Multiple interfaces can be implemented by
h
ec
Methods of an interface are implicitly Methods of a class can have any access
Fo
public modifier
O
se
Allows simulating multiple inheritance of classes
U
Helps to avoid ambiguity between the methods of the
tre
en
C
Allows combining features of two or more interfaces
h
such that a class needs to only implement the
ec
combined result
pt
rA
U
tre
No-argument constructor: Invoked in the sequence in
en
which the child class has inherited the parent classes
C
h
ec
O
properties from more than one classes.
se
Diamond Problem is a situation that arises when a class inherits
U
tre
common super class.
en
An interface is a type similar to a class that consists of only
C
multiple inheritance.
rA
Fo
O
the sequence in which the child class invokes them in its own
se
constructor.
U
Ambiguity of name is a condition in multiple inheritance
tre
wherein the base classes have a method with the same name
en
and signature.
C
h
ec
pt
rA
Fo