Hi guys today we are going to see some of the indeapth concept of Java, That is Interface , This are used to overcome the multiple inheritance in java. Interface can be access by using the implementation keyword in java.
By default inside interface all methods are abstract and all variables are final. Interface does not have objects . The method which declare inside the interface must be defined by the implemented class.
Syntax:
interface interface_name
{
}
This is the basic syntax for interface
Example:
interface inter1
{
void a();
}
interface inter2
{
void b();
}
public class inerfaceClassA implements iner1, iner2
{
@override
public void b();
{
//TODO Auto-generated method stub
system.out.println(interface 1 value);
}
@override
public void a();
{
//TODO Auto-generated method stub
system.out.println(interface 2 value);
}
public static void main(String args[])
{
interfaceClassA obj=new interfaceClassA();
obj.a();
obj.b();
}
}
In java one interface can be extended to another interface.
interface inter1
{
void a();
}
interface inter2 extends inter1
{
void b();
}
Then both the methods must define in the implemented class.
This is the basic definition of what interface actually does, Now from this we move into the next concept , its about keywords
Please do comments for my post and let me know about how you like this java tutorial.. and its also be helpful for me to get updated for further post....
COMMENTS PLS.............
By default inside interface all methods are abstract and all variables are final. Interface does not have objects . The method which declare inside the interface must be defined by the implemented class.
Syntax:
interface interface_name
{
}
This is the basic syntax for interface
Example:
interface inter1
{
void a();
}
interface inter2
{
void b();
}
public class inerfaceClassA implements iner1, iner2
{
@override
public void b();
{
//TODO Auto-generated method stub
system.out.println(interface 1 value);
}
@override
public void a();
{
//TODO Auto-generated method stub
system.out.println(interface 2 value);
}
public static void main(String args[])
{
interfaceClassA obj=new interfaceClassA();
obj.a();
obj.b();
}
}
In java one interface can be extended to another interface.
interface inter1
{
void a();
}
interface inter2 extends inter1
{
void b();
}
Then both the methods must define in the implemented class.
This is the basic definition of what interface actually does, Now from this we move into the next concept , its about keywords
Please do comments for my post and let me know about how you like this java tutorial.. and its also be helpful for me to get updated for further post....
COMMENTS PLS.............
No comments:
Post a Comment