title: Getting sub class fields using super class using reflection?
body: <p>I have a class as below.</p>
  
  <pre><code>public class Emp{
  
   private String name;
   private String age;
  
   //setters and getters
  
  }
  </code></pre>
  
  <p>Have one more class below.</p>
  
  <pre><code>public class Student extends Emp{
   private int marks;
   //setters and getters
  }
  </code></pre>
  
  <p>is there anyway to get the fields of a subclass using super class using java Reflection?
  I need to get Student fields using Emp instance.</p>
  
  <p>we can get super class fields as below:</p>
  
  <pre><code>subClass.getClass().getSuperclass().getDeclaredFields();
  </code></pre>
  
  <p>similarly can i get sub class fields using super class?</p>
  
  <p>Is it possible?</p>
  
  <p>Thanks!</p>