Posted On: Dec 18, 2020
Upcasting and Downcasting are important parts of Java that allow us to build complicated programs using a simple syntax. Java permits an object of a subclass type to be treated as an object of any superclass type that is called upcasting. Downcasting can fail if the actual object type is not the target object type whereas Upcasting can not fail. Let’s see an example: Here, we cast the subject type to the Science type. As Science is a subclass of the Subject, this casting is called Downcasting.
Never Miss an Articles from us.