I have a class C. Class E extends it.
E e = new E();
C c = new C();
Why is
e = (E) c;
Upon further review
Just because E extends C, C doesn't become an E... E on the other hand is a C
Edit: To expand Mark's comment below... Just because every woman is a human, not all humans are women. All humans share the "human interface" with legs, hands, faces, etc. Women extends it with functionality that returns good feelings when you provide diamonds and gold.
The int => double conversion is not even related as it is not a class cast but a conversion telling the compiler to store whatever is in x in y (which happens to be a double).
((M) k).getClass() gives K.
because k is still a K even if you cast it to an M or an Object (or something else it happens to be).
Edit: I think the confusion here is because you consider k to "become" an M when you cast it, it doesn't. You are just treating it as an M. If you ask someone who is a "dog owner" what kind of breed it is he will not return "It's a dog", the reason is simply that the getBreedName() method is likely to have been overridden in the subclass LabradorOwner to return "Labrador". It is the same with getClass(), it will return the class of the implementation. It will not be an M but a K that happens to be an M as well just because K extends M.