Interface # java
To implement a interface, a class must create the complete set of methods defined by the interface.
method of interface is implicit are abstract public
variable of interface is implicit are public. static and final means we cant change the value of interface variable value.
Variables as a object reference we can create which will be called at run time. using interface object we can methods and it will find definition at run time.
interface demo {
method ();
}
class test implements demo {
method ()
{
System.out.println("interface demo");
}
public static void main (String[] arg)
{
demo obj = new test();
obj.method();
}
}
Interface can access only these methods which is declare in interface interface variable cannot access the other methods and variables.
if class doesn't define methods of implemented interface then it should be define abstract( only abstract class can have abstract methods)
An Interface can extends another interface then implementing class should define all the methods which comes in chain of interface.
Class can inherit multiple interfaces and can extend a class.
class second extend test implement demo, demo2, demo3{}
interface method cannot be static it always be non-static .
method of interface is implicit are abstract public
variable of interface is implicit are public. static and final means we cant change the value of interface variable value.
Variables as a object reference we can create which will be called at run time. using interface object we can methods and it will find definition at run time.
interface demo {
method ();
}
class test implements demo {
method ()
{
System.out.println("interface demo");
}
public static void main (String[] arg)
{
demo obj = new test();
obj.method();
}
}
Interface can access only these methods which is declare in interface interface variable cannot access the other methods and variables.
if class doesn't define methods of implemented interface then it should be define abstract( only abstract class can have abstract methods)
An Interface can extends another interface then implementing class should define all the methods which comes in chain of interface.
Class can inherit multiple interfaces and can extend a class.
class second extend test implement demo, demo2, demo3{}
interface method cannot be static it always be non-static .
Comments
Post a Comment