Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication9;
- public class JavaApplication9 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Cat c=new Cat();
- c.meow();
- c.eat();
- }
- }
- abstract class Animal {
- abstract public void eat();
- }
- class Dog extends Animal {
- @Override
- public void eat() {
- System.out.println("Eating dog food");
- }
- public void bark() {
- System.out.println("barking...");
- }
- }
- class Cat extends Animal {
- @Override
- public void eat() {
- System.out.println("Eating cat food");
- }
- public void meow() {
- System.out.println("meowing...");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement