1Downcasting is casting to a subtype,
2going down in the inheritance tree.
3It is done to access sub class features.
4It has to be done manually
5
6(TakeScreenShot)driver).takeScreenShot();
7
1A 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.
2
1Downcasting is casting to a subtype,
2going down in the inheritance tree.
3It is done to access sub class features.
4It has to be done manually
5
6(TakeScreenShot)driver).takeScreenShot();
1Upcasting is casting a subtype to a supertype,
2going up in the inheritance tree.
3It is done implicitly
4 in order to use method available on any
5 interface/class, the object should be of
6 same class or of class implementing the interface.
7 WebDriver driver = new ChromeDriver();
8or
9 TakeScreenShot ts = new ChromeDriver();
1Upcasting is casting a subtype to a supertype,
2going up in the inheritance tree.
3It is done implicitly
4 in order to use method available on any
5 interface/class, the object should be of
6 same class or of class implementing the interface.
7 WebDriver driver = new ChromeDriver();
8or
9 TakeScreenShot ts = new ChromeDriver();
10
11Downcasting is casting to a subtype,
12going down in the inheritance tree.
13It is done to access sub class features.
14It has to be done manually
15
16(TakeScreenShot)driver).takeScreenShot();
17
18