Hello,
Would someone kindly look at the code below and explain why a class cast exception is thrown at runtime. Thank you!!
class SuperTest {
}
class SubTest extends SuperTest {
}
public class Inheritance {
public static void main(
String[] args) {
SubTest subRef = (SubTest) new SuperTest();
// THE ABOVE LINE CAUSES A ClassCastException AT RUNTIME
}
}