class cast exception java
<pre><code>interface Foo { 

}
class Beta implements Foo { 

}
public class Main extends Beta{
    public static void main(String[] args) {
        Beta x = new Beta();
        Foo f= (Main)x;
        }
}
</code></pre>

<p>output <code>java.lang.ClassCastException</code>.
Why it is happening please xplain?</p>
