<s>
An	O
interface	O
in	O
the	O
Java	B-Language
programming	I-Language
language	I-Language
is	O
an	O
abstract	O
type	O
that	O
is	O
used	O
to	O
declare	O
a	O
behavior	O
that	O
classes	O
must	O
implement	O
.	O
</s>
<s>
Interfaces	O
are	O
declared	O
using	O
the	O
interface	O
keyword	B-Language
,	O
and	O
may	O
only	O
contain	O
method	O
signature	O
and	O
constant	O
declarations	O
(	O
variable	O
declarations	O
that	O
are	O
declared	O
to	O
be	O
both	O
static	O
and	O
final	B-Language
)	O
.	O
</s>
<s>
All	O
methods	O
of	O
an	O
Interface	O
do	O
not	O
contain	O
implementation	O
(	O
method	O
bodies	O
)	O
as	O
of	O
all	O
versions	O
below	O
Java	B-Device
8	O
.	O
</s>
<s>
Starting	O
with	O
Java	B-Device
8	O
,	O
default	O
and	O
static	O
methods	O
may	O
have	O
implementation	O
in	O
the	O
interface	O
definition	O
.	O
</s>
<s>
Then	O
,	O
in	O
Java	B-Device
9	O
,	O
private	O
and	O
private	O
static	O
methods	O
were	O
added	O
.	O
</s>
<s>
At	O
present	O
,	O
a	O
Java	B-Language
interface	I-Language
can	O
have	O
up	O
to	O
six	O
different	O
types	O
.	O
</s>
<s>
A	O
class	O
that	O
implements	B-Language
an	O
interface	O
must	O
implement	O
all	O
of	O
the	O
non-default	O
methods	O
described	O
in	O
the	O
interface	O
,	O
or	O
be	O
an	O
abstract	O
class	O
.	O
</s>
<s>
Object	O
references	O
in	O
Java	B-Device
may	O
be	O
specified	O
to	O
be	O
of	O
an	O
interface	O
type	O
;	O
in	O
each	O
case	O
,	O
they	O
must	O
either	O
be	O
null	O
,	O
or	O
be	O
bound	O
to	O
an	O
object	O
that	O
implements	B-Language
the	O
interface	O
.	O
</s>
<s>
One	O
benefit	O
of	O
using	O
interfaces	O
is	O
that	O
they	O
simulate	O
multiple	B-Application
inheritance	I-Application
.	O
</s>
<s>
All	O
classes	O
in	O
Java	B-Device
must	O
have	O
exactly	O
one	O
base	B-Application
class	I-Application
,	O
the	O
only	O
exception	O
being	O
(	O
the	O
root	O
class	O
of	O
the	O
Java	B-Device
type	O
system	O
)	O
;	O
multiple	B-Application
inheritance	I-Application
of	O
classes	O
is	O
not	O
allowed	O
.	O
</s>
<s>
For	O
instance	O
,	O
a	O
human	O
and	O
a	O
parrot	B-Language
can	O
both	O
whistle	O
;	O
however	O
,	O
it	O
would	O
not	O
make	O
sense	O
to	O
represent	O
Humans	O
and	O
Parrots	B-Language
as	O
subclasses	O
of	O
a	O
Whistler	O
class	O
.	O
</s>
<s>
Another	O
use	O
of	O
interfaces	O
is	O
being	O
able	O
to	O
use	O
an	O
object	O
without	O
knowing	O
its	O
type	O
of	O
class	O
,	O
but	O
rather	O
only	O
that	O
it	O
implements	B-Language
a	O
certain	O
interface	O
.	O
</s>
<s>
For	O
instance	O
,	O
if	O
one	O
were	O
annoyed	O
by	O
a	O
whistling	O
noise	O
,	O
one	O
may	O
not	O
know	O
whether	O
it	O
is	O
a	O
human	O
or	O
a	O
parrot	B-Language
,	O
because	O
all	O
that	O
could	O
be	O
determined	O
is	O
that	O
a	O
whistler	O
is	O
whistling	O
.	O
</s>
<s>
The	O
call	O
whistler.whistle( )	O
will	O
call	O
the	O
implemented	O
method	O
whistle	O
of	O
object	O
whistler	O
no	O
matter	O
what	O
class	O
it	O
has	O
,	O
provided	O
it	O
implements	B-Language
Whistler	O
.	O
</s>
<s>
In	O
a	O
more	O
practical	O
example	O
,	O
a	O
sorting	B-Algorithm
algorithm	I-Algorithm
may	O
expect	O
an	O
object	O
of	O
type	O
.	O
</s>
<s>
Interfaces	O
are	O
defined	O
with	O
the	O
following	O
syntax	O
(	O
compare	O
to	O
Java	B-Device
's	O
class	O
definition	O
)	O
:	O
</s>
<s>
The	O
body	O
of	O
the	O
interface	O
contains	O
abstract	O
methods	O
,	O
but	O
since	O
all	O
methods	O
in	O
an	O
interface	O
are	O
,	O
by	O
definition	O
,	O
abstract	O
,	O
the	O
abstract	O
keyword	B-Language
is	O
not	O
required	O
.	O
</s>
<s>
The	O
member	O
type	O
declarations	O
in	O
an	O
interface	O
are	O
implicitly	O
static	O
,	O
final	B-Language
and	O
public	O
,	O
but	O
otherwise	O
they	O
can	O
be	O
any	O
type	O
of	O
class	O
or	O
interface	O
.	O
</s>
<s>
...	O
implements	B-Language
InterfaceName[ 	O
,	O
another	O
interface	O
,	O
another''	O
,	O
...	O
]	O
...	O
</s>
<s>
If	O
a	O
class	O
implements	B-Language
an	O
interface	O
and	O
does	O
not	O
implement	O
all	O
its	O
methods	O
,	O
it	O
must	O
be	O
marked	O
as	O
abstract	O
.	O
</s>
<s>
Interfaces	O
are	O
commonly	O
used	O
in	O
the	O
Java	B-Language
language	I-Language
for	O
callbacks	O
,	O
as	O
Java	B-Device
does	O
not	O
allow	O
multiple	B-Application
inheritance	I-Application
of	O
classes	O
,	O
nor	O
does	O
it	O
allow	O
the	O
passing	O
of	O
methods	O
(	O
procedures	O
)	O
as	O
arguments	O
.	O
</s>
<s>
It	O
allows	O
multiple	B-Application
inheritance	I-Application
,	O
unlike	O
classes	O
.	O
</s>
<s>
When	O
a	O
class	O
implements	B-Language
VenomousPredator	O
it	O
will	O
implement	O
both	O
methods	O
simultaneously	O
.	O
</s>
<s>
Some	O
common	O
Java	B-Language
interfaces	I-Language
are	O
:	O
</s>
<s>
Generics	B-Language
allow	O
implementing	O
classes	O
to	O
specify	O
which	O
class	O
instances	O
can	O
be	O
compared	O
to	O
them	O
.	O
</s>
<s>
is	O
a	O
marker	B-Language
interface	I-Language
with	O
no	O
methods	O
or	O
fields	O
-	O
it	O
has	O
an	O
empty	O
body	O
.	O
</s>
<s>
It	O
is	O
used	O
to	O
indicate	O
that	O
a	O
class	O
can	O
be	O
serialized	B-Application
.	O
</s>
