Practical 23


Aim:- Write a program to implement Interface in java.

JAVA Code :-

import java.lang.*;

interface Drawable
{
   void draw();
}
class Rectangle implements Drawable
{
   public void draw()
   {      
       System.out.println("Drawing Rectangle");
    }
}
class Circle implements Drawable
{
   public void draw()
   {      
       System.out.println("Drawing Circle");
    }
}

class TestInterface
{
   public static void main(String[] args)
   {
       Drawable c=new Circle();
       Drawable r=new Rectangle();
       c.draw();
       r.draw();
    }
}

     
Output:-



No comments:

Post a Comment

Programs

Home Aim:- Write a program to convert rupees to dollar. (60rupees=1 dollar). Aim:- Write a program that calculate percentage marks...