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 -
https://simplesnippets.tech/
simple snippets on facebook -
https://www.facebook.com/simplesnippets/
simple snippets on instagram -
https://www.instagram.com/simplesnippets/
simple snippets on twitter -
https://twitter.com/simplesnippet
simple snippets google plus page -
https://plus.google.com/+simplesnippets
simple snippets email id -
simplesnippetsinfo@gmail.com

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

upcasting vs downcasting in java with program example