Answers for "what is upcasting & Downcasting in java"

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 "what is upcasting & Downcasting in java"

Browse Popular Code Answers by Language