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 

2 comments:

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

    http://lennyfacetext.com

    ReplyDelete
  2. Great tips and very easy to understand. This will definitely be very useful for me when I get a chance to start my blog. PLease visit picbear

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...