Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface Animal
- {
- public void eat();
- public void run();
- }
- public class Dog implements Animal {
- public void eat() {
- System.out.println("\nDog eats meat.");
- }
- public void run() {
- System.out.println("Dog can run.");
- }
- }
- public class Cat implements Animal {
- public void eat() {
- System.out.println("Cat eats meat.");
- }
- public void run() {
- System.out.println("Cat can run.");
- }
- }
- public class Main {
- public static void main(String[] args) {
- Animal c1 = new Cat();
- Animal d2 = new Dog();
- c1.eat();
- c1.run();
- d2.eat();
- d2.run();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement