Upcasting vs Downcasting in Java With Program Example

preview_player
Показать описание
Support Simple Snippets by Donations -
--------------------------------------------------------------------------------------------- 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.

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 -

Рекомендации по теме
Комментарии
Автор

Hey Guys, if you want more such tech educational videos on this channel then please support me by subscribing to this channel & also share it with your friends as it helps me create more content just for you ✌

SimpleSnippets
Автор

after searching and watching more than .10 videos ..
Trust me
This is the best video i found who made me understood what is downcasting and upcasting as well as use of instanceOf..
Very nice bro ..
Thank you sooo much

govindmusic_
Автор

this is the best simplest upcasting and downcasting explanation in detail, thanx bro

kapilsharma
Автор

well explained brother. after wasting 3 days searching for casting videos. this is really helpful. finally i undestood the topic. thankyou :)

kiranmaiganapuram
Автор

Thanks a lot for explaining this dude. I've been super confused on this topic for a long time.

abbyboing
Автор

Hatts off to u . U cleared my doubt thank u

angulardesign
Автор

Thanks alot brother after watching many videos still have doubts which are clear now

pulkitsharma
Автор

The best guy in java. I can surely say.

programmingforfun
Автор

dude you explain better than my teacher

RahulTetwar
Автор

one of the best explanations seen for such concepts.. Nice one.

KG-vorg
Автор

Thanks for your good explanation. Perfect 👍.

zaur
Автор

It's very clear explanation. Thank you so much....

anithakota
Автор

Thank you so much...now my doubt is cleared

rupeshkumarpadhi
Автор

you are the best....
after this, i got a lot of clarity. thanks

amithghosh
Автор

thank you so muchh it was very clear and finallyy i understand it!!

salqarni
Автор

Best explanation of type casting thank u

nachiketjoshi
Автор

very nice website. fully user friendly love it..!

universalgamers
Автор

What's the difference between downcasting and directly creating child object in java?

ksdnsdkumar
Автор

great video... although I had to watch it twice bcz your last examples, whether where we can use up & down casting made my concepts clear .... so I hade to give it another look to get it on

Unknwn_Legend
Автор

But if I create a object of child class with reference of child class so why need to do down casting? i can access the overridden method & unique method of child by using that object

sanketpatil