1public class Fruit{} // parent class
2public class Apple extends Fruit{} // child class
3
4public static void main(String args[]) {
5 // The following is an implicit upcast:
6 Fruit parent = new Apple();
7 // The following is a downcast. Here, it works since the variable `parent` is
8 // holding an instance of Apple:
9 Apple child = (Apple)parent;
10}