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.
If you compile your code with these lines your code will run fine at runtime.
In your case new parent() object has the no knowledge of child class that's why at run time it just broke down. (cast) operator is used for asking compiler to skip checking the compatibilty of the the two operands on either side of = operator, that is why it was fine at compile time.