Invoke Super class methods using Reflection
<p>I have 2 classes , say A &amp; B where in </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, it throws an Instantiation Exception. What am I doing wrong here</p>
