Interface:-
It is
like as abstract class but one exception that in which all the methods cannot
have body.
All the
methods of an interface are public and abstract by default.
All the
methods of an interface should be defined(implemented) by its derived class.
All the
variables declared with in an interface are public,static and final by default.
Since
interface can not be instantiated,it should have atleast one derived class.
To
achieve "pure dynamic polymorphism".
A class
can inherit more than one interfaces using the keyword "implements".
An
interface can inherit another interface using the keyword "extends".
syntax to define an interface:-
<specifier> interface <interfacename>
{
methods
decl;
constant
fields decl&init;
}
<specifier>class childclassname implements
interfacename1,interfacename2
{
interface
method definition
class own method definition
}
No comments:
Post a Comment