title: Invoke Super class methods using Reflection
body: <p>I have 2 classes, say A &amp; B:</p>
  
  <pre><code>Class A extends B {
      public void subClassMthd(){
          System.out.println("Hello");
      }
  }
  
  Class B {
      public void printHelloWorld {
          System.out.println("Hello");
      }
  }
  </code></pre>
  
  <p>Now, I am using reflection to invoke the methods on Class A. I would also like to invoke the printHelloWorld method present in Class B. </p>
  
  <p>I tried using </p>
  
  <pre><code>Class clazz = Class.forName("com.test.ClassA");
  Object classAInstance= clazz.newInstance();
  Method superClassmthd = classAInstance.getClass()
      .getSuperclass().getMethod("printHelloWorld", null);
  superClassmthd.invoke(classAInstance);
  </code></pre>
  
  <p>Also tried as</p>
  
  <pre><code>Class clazz = Class.forName("com.test.ClassA");
  Object classAInstance= clazz.newInstance();
  Class superClazz = Class.forName(classAInstance.getClass().getSuperclass().getName());
  Object superclassInstance = superClazz.newInstance();
  Method superClassmthd = superclassInstance.getMethod("printHelloWorld", null);
  superClassmthd.invoke(superclassInstance );
  </code></pre>
  
  <p>But none of them work; they throw an <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/InstantiationException.html">InstantiationException</a>.</p>
  
  <p>What am I doing wrong here?</p>