What is Upcasting and Downcasting in Java
In your daily coding, you will see (and use) upcasting and downcasting occasionally. You may hear the terms ‘casting’, ‘upcasting’, ‘downcasting’ from someone or somewhere, and you may be confused about them.As you read on, you will realize that upcasting and downcasting are really simple. Before we go into the details, suppose that we have the following class hierarchy: Mammal > Animal > Dog, Cat Mammal is the super interface: