Explain upcasting and downcasting in Java.
Upcasting: Java permits an object of a sub class can be referred by its super class. It is done automatically.
Downcasting: It is to be performed manually by the developers. Here explicit casting is to be done by the super class.
Example:Shape shape = new Shape() ;
Circle circ;
circ = (Circle) shape;
where shape is a super class object. Now the methods of Shape can be invoked by the reference variable circ.