New course! Every coder should learn Generative AI!
Try a free lesson+ 1
upcasting means casting the object to a supertype, while downcasting means casting to a subtype. In java, upcasting is not necessary as it's done automatically. And it's usually referred as implicit casting. ... Actually at runtime it could be different and java will throw a ClassCastException , would that happen
https://stackoverflow.com/questions/23414090/what-is-the-difference-between-up-casting-and-down-casting-with-respect-to-class
https://www.codejava.net/java-core/the-java-language/what-is-upcasting-and-downcasting-in-java