Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class apples {
- public static void main(String[] args){
- Animal[] thelist = new Animal[2];
- Dog d = new Dog();
- Fish f = new Fish();
- thelist[0]=d;
- thelist[1]=f;
- for(Animal x: thelist){
- x.noise();
- }
- }
- }
- public class Dog extends Animal {
- public void noise(){
- System.out.println("Ruff");
- }
- }
- public class Fish extends Animal{
- public void noise(){
- System.out.println("Glurp Slurp");
- }
- }
- public class Animal {
- public void noise(){
- System.out.println("Animal don´t make noise");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement