I want to know why the following code:
public class Vertebrate {
public Vertebrate() {
System.out.print("Vertebrate ");
}
public static void main(String[] args) {
Mammal rabbit = new Mammal();
System.out.println("Rabbit");
}
}
class Mammal extends Vertebrate {
public Mammal() {
System.out.print("Mammal ");
}
}
produces the output: Vertebrate Mammal Rabbit
.
I was asked to explain in detail, but I don't understand why the output is like it is. Please someone help me out.