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