Error
Error Type
Compile Time
Cannot Cast from x to y
Error Type
Compile Time
Sample Code
class Car extends Vehicle {
public static void main(String[] args){
Vehicle v1 = new Vehicle();
String c1 = (String)v1;
c1.toString();
}
}
Cause
Casting Can be done only among related types.
Resolution
Either remove the cast or establish relationship among the classes.