Working with typecasting and polymorphism