Interface in Java


Interface means only the method declaration will be available not a implementation part of the method.We can say interface methods are abstract method because it has only the method declaration part alone.

So, for implementing the method that are available in the interface. We have to implements interface to class which is having the implementation part of those methods.

File:ins.java

interface sam
{
public void show();
public void get();
}
class ins implements sam
{
public void show()
{
System.out.println(“First Statement”);
}
public void get()
{
System.out.println(“Second Statement”);
}
public static void main(String ar[])
{
ins a=new ins();
a.show();
a.get();
}
}

Output
First Statement
Second Statement

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s