Java casting resulting in run-time error instead of compilation error
<p>The following code snippet will result in a run-time:</p>

<pre><code>class Vehicle {
    public void printSound() {
        System.out.print("vehicle");
    }
}

class Car extends Vehicle {
    public void printSound() {
        System.out.print("car");
    }
}

class Bike extends Vehicle {
    public void printSound() {
        System.out.print("bike");
    }
}

public class Test {
    public static void main(String[] args) {
        Vehicle v = new Car();
        Bike b = (Bike) v;

        v.printSound();
        b.printSound();
    }   
}
</code></pre>

<p>My question is: why does that result in a run-time error but not a compilation error? Shouldn't the compiler know that 'v' is already a 'Car' and cannot be cast into a 'Bike'?</p>
