This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Since static methods are class members and not instance members, the method that is corresponding to the type of the type of the reference variable will be called.
In your example,
is equivalent to converting the object of class Animal to object of class Dog and then calling the method on it. This works because the class that the compiler sees is Dog class and hence invoke the method corresponding to Dog class.
In the next case, since a is an array that holds Animal objects, the method corresponding to Animal class is invoked.