title: how to invoke child class method to parent Object
body: <p>I want to invoke a child class method to a super class Object but since I declared another integer in child class it is giving me an exception, is there a workaround to make this happen?</p>
  
  <pre><code>public static void main(String[]args){
  
      A a = new A(2,3);
      B b = new B(3,5,6);
  
      System.out.println("A object: ");
      a.showij();
      System.out.print("sum = ");
      ((B) a).sum(); &lt; ==== this line gives me the error, can't cast
      System.out.println("B object: ");
      b.showij();
      System.out.print("sum = ");
      b.sum();
  
  }
  
  public class B extends A {
  
  int k;
  
  public B(){
      super();
  }
  
  public B(int a, int b, int c) {
      super(a, b);
      k = c;
  }
  
  public void sum(){
      System.out.println( i + j + k);
  }
  }
  
  
  public class A {
  
  int i,j;
  
  public A() {
  
  }
  
  public A( int a, int b){
      i = a;
      j = b;      
  }
  
  public void showij(){
      System.out.println("\ti: " + i + " j: " + j);
  }
  }
  </code></pre>
  
  <p>*edit: here is the whole thing</p>