Answers for "upcasting and downcasting in java javatpoint"

0

upcasting and downcasting in java

A process of converting one data type to another is known as Typecasting and Upcasting and Downcasting is the type of object typecasting. In Java, the object can also be typecasted like the datatypes. Parent and Child objects are two types of objects. So, there are two types of typecasting possible for an object, i.e., Parent to Child and Child to Parent or can say Upcasting and Downcasting.
Posted by: Guest on August-24-2021
2

upcasting vs downcasting in java

Upcasting is casting a subtype to a supertype, 
going up in the inheritance tree.
It is done implicitly
 in order to use method available on any
 interface/class, the object should be of
 same class or of class implementing the interface.  
   WebDriver driver = new ChromeDriver();
or
	TakeScreenShot ts = new ChromeDriver();
  
Downcasting is casting to a subtype, 
going down in the inheritance tree.
It is done to access sub class features.
It has to be done manually

(TakeScreenShot)driver).takeScreenShot();
Posted by: Guest on January-05-2021

Code answers related to "upcasting and downcasting in java javatpoint"

Browse Popular Code Answers by Language