And in java
class Person{}
class Student extends Person{}
public class Test {
public static void main(String[] args) {
Person person = new Person();
Student student = (Student)person;
}
}
There is a "Exception in thread "main" java.lang.ClassCastException: Person cannot be cast to Student"