filmov
tv
Upcasting vs Downcasting in Java With Program Example
Показать описание
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 -
--------------------------------------------------------------------------------------------- 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 -
Комментарии