upcasting vs downcasting in java with program example

support simple snippets by donations -
google pay upi id - tanmaysakpal11@okicici
paypal - paypal.me/tanmaysakpal11
- in this java programming video tutorial we will study and understand the concept of upcasting and downcasting. we will also understand the difference between upcasting and downcasting in java.
upcasting in java -
upcasting is casting a subtype to a supertype, upward to the inheritance tree. upcasting happens automatically and we don’t have to explicitly do anything.

downcasting in java -
when subclass type refers to the object of parent class, it is known as downcasting. if we perform it directly, compiler gives compilation error. if you perform it by typecasting, classcastexception is thrown at runtime.

for more details checkout this website link - https://simplesnippets.tech/upcasting-vs-downcasting-in-java/

core java programming playlist - https://www.youtube.com/watch?v=qakx6sju1vg&list=pliy8endw5tw_uajgi-fl9qwins9jxkkg2

download the free java programming android app from google playstore - https://play.google.com/store/apps/details?id=com.intelisenze.java.learnjavaprogramming

simple snippets official website -
simple snippets on facebook -
simple snippets on instagram -
simple snippets on twitter -
simple snippets google plus page -
simple snippets email id -

for more technology news, latest updates and blog articles visit our official website - https://simplesnippets.tech/

upcasting vs downcasting in java with program example