
what is the ClassCastException and exp?

ClassCastException occurs, when you try to assign a reference variable of a class to an incompatible reference variable of another class.
Example
import java.util.Vector;
public class CastException {
public static void main(String[] args) {
Vector v = new Vector();
int i = 10;
Object obj = v.add(i);
try {
String y = (String)obj;
v.add(y);
} catch (ClassCastException e) {
System.out.println("Class is really: " + obj.getClass().getName());
e.printStackTrace();
}
}
}