public class InterfaceCasting { private static class A{} public static void main(String[] args) { A a = new A(); Serializable serializable
Serializable serializable; a = (A)serializable;
As for the compiler, the variable serializable can contain any object that implements Serializable, which includes subclasses of A. So it assumes that you know that the variables indeed contains an A object and allows that line.
Serializable
A