class Super
{
Super()
{
System.out.println("Constructor for Super class");
}
}
public class Sub extends Super
{
Sub()
{
System.out.println("Constructor for Sub class");
}
public static void main(
String[] args)
{
Sub subObj=(Sub)new Super();
}
}
Hi,
The above program(Sub.java) is compiling but while running it is giving ClassCastException.. Why???