Search This Blog

Saturday, 1 February 2014

interface in java

/* program to illustrate the concept of interface in java */



interface FirstLetter
{
   public char First(char c);
}
interface SecondLetter
{
    public char Second(char c);
}
interface ThirdLetter
{
    public char Third(char c);
}
class Name implements FirstLetter,SecondLetter,ThirdLetter
{
    public char First(char c)
    {
        return c;
    }
     public char Second(char c)
    {
        return c;
    }
      public char Third(char c)
    {
        return c;
    }
}

class MainClass
{
    public static void main(String args[])
    {
        Name nm=new Name();
        nm.First('j');
        nm.Second('a');
        nm.Third('y');
        System.out.println("Name is :"+nm.First('j')+nm.Second('a')+nm.Third('y'));
    }
}

Output

Name is :jay

No comments:

Popular Posts