public class ShapeTest2 {
public static void main(String[] args) {
Circle c = new Circle();
Rectangle r = new Rectangle();
c.draw();
r.draw();
}
}
interface Shape {
void draw();
void erase();
}
class Circle implements Shape {
public void draw() {
System.out.println("Circle.draw()");
}
public void erase() {
System.out.println("Circle.erase()");
}
}
class Rectangle implements Shape {
public void draw() {
System.out.println("Rectangle.draw()");
}
public void erase() {
System.out.println("Rectangle.erase()");
}
}
ShapeTest2.java output
Circle.draw()
Rectangle.draw()
Tag: Study Code Program Java
No comments:
Post a Comment