Suppose that X and Y are classes such that Y extends X. Also, let method(X xObj) be a method of X. Why does the following code compile?
X xObj = new X();
Y yObj = new Y();
xObj.method(yObj);
Also, are there other similar cases in which code that seems incorrect compiles?