This is a bloody good example! Thanks.
> take a look at this:
>
>
> public class
> Animal {
> public void makeNoise() {
> System.out.println("what am I supposed to say?");
> }
> }
>
> public class
> Dog extends Animal {
> public void makeNoise() {
> System.out.println("woof");
> }
> }
>
> public class
> Cat extends Animal {
> public void makeNoise() {
> System.out.println("meow");
> }
> }
>
> public class
> AnimalTest() {
> public static void
> main(String[] args) {
> Animal
> a1 = new Dog(),
> a2 = new Cat();
> a1.makeNoise();
> a2.makeNoise();
> }
> }
>
>
> The output, obviously is:
>
> woof
> meow
>
> This is polymorphism in action.
>
> You have 2 Animal references (a1 & a2). But the behavior of these objects
depends not on the declared type of the references (Animal), but upon the
actual type of the objects (Dog and Cat).
>
> That's polymorphism. So in a nutshell, polymorphism basically means that
objects of the same interface/type exhibit different behavior depending on
their actual subclass type.
>
> HTH.
>
>
> DR
>
>
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm
To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm