Interface Example - JAVA

        // INTERFACE PROGRAM IN JAVA

import java.io.*;
interface figure
{
    void read(int r);
    void display();
    void area();
}
    
class Circle implements figure
{
    double area;
    int radius;
    public void read( int r)
    {
        radius=r;
    }
    public void area()
    {
         area=3.14*radius*radius;
    }
    public void display()
    {
         System.out.print(area);
    }
    
}
class intrfce
{
    public static void main(String args[]) throws IOException
    {
        DataInputStream x= new DataInputStream(System.in);
        Circle circle=new Circle();
        System.out.print("Enter the radius of the circle:");
        circle.read(Integer.parseInt(x.readLine()));
        circle.area();
        System.out.print("Area of circle=");
        circle.display();
        
    }
}
 OUTPUT
students@ccflab-desktop:~$ javac intrfce.java
Note: intrfce.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
students@ccflab-desktop:~$ java intrfce
<<JAVA INTERFACE>>
Enter the radius of the circle:2
Area of circle=12.56                                            http://2k8618.blogspot.com
students@ccflab-desktop:~$

Download 

4 comments:

  1. I would like more information about this, because it is very nice., Thanks for sharing.

    http://lennyfacetext.com

    ReplyDelete
  2. I would like to thank you for the efforts you have made in writing this article.
    run3unblockedgame.com

    ReplyDelete
  3. I was very impressed by this post, this site has always been pleasant news. Thank you very much for such an interesting post. Keep working, great job! In my free time, I like play game: vex3game.com. What about you?

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...