title: Java Polymorphism and casting
body: <p>In this code, shouldn't <code>(A) obj).test()</code> call the test method of class A? What am I missing?</p>
  
  <pre><code>class Main {
    public static void main(String[] args) {
      B obj = new B();
      obj.test();
  
      ((A) obj).test();
    }
  }
  
  class A {
  
      public void test() {
          System.out.println("Called in A!");
      }
  }
  
  class B extends A {
  
      public void test() {
          System.out.println("Called in B!"); 
  
      }
  }
  </code></pre>