Reflection API

Retrieve fields with data type Reflection Java

It is advised to read the notes on Java Reflection API before attempting the programs on this Retrieve fields with data type. import java.lang.reflect.Field; public class Demo extends Test { public int price; public double rate; public String name; public static void main(String args[]) { Demo d1 = new Demo(); Class c = d1.getClass(); Field …

Retrieve fields with data type Reflection Java Read More »

Retrieve methods of current class and super classes

It is advised to read the notes on Java Reflection API before attempting the programs. Example on Retrieve methods of class import java.lang.reflect.Method; class Test { public void display() { } protected void exhibit() { } } public class Demo extends Test { public void show() { } protected void calculate() { } public static …

Retrieve methods of current class and super classes Read More »

Retrieve fields of a class Reflection Java

It is advised to read the notes on Java Reflection API before attempting the programs. Example on Retrieve fields of a class import java.lang.reflect.Field; public class Demo { public int price; public double rate; public String name; public static void main(String args[]) { Demo d1 = new Demo(); Class c = d1.getClass(); Field f[] = …

Retrieve fields of a class Reflection Java Read More »

Get interfaces implemented by a class Reflection Java

It is advised to read the notes on Java Reflection API before attempting the programs. Example to get interfaces implemented by a class interface Hello { } interface Test { } interface Sample extends Test, Hello{ } public class Demo implements Hello, Test, Sample { public static void main(String args[]) { Demo d1 = new …

Get interfaces implemented by a class Reflection Java Read More »

Get Super classes of a Class Java Reflection API

It is advised to read the notes on Java Reflection API before attempting the programs. Example to get super classes of a class with Java Reflection API import java.awt.Button; import java.lang.reflect.Modifier; class Test { } class Hello extends Test { } public class Demo extends Hello { public static void main(String [] args) { Demo …

Get Super classes of a Class Java Reflection API Read More »

Get Access Specifiers and Modifiers of a Class

It is advised to read the notes on Java Reflection API before attempting the programs. Example to get Access Specifiers and modifiers of a class. import java.awt.Button; import java.lang.reflect.Modifier; public final class Demo { public static void main(String [] args) { Demo d1 = new Demo(); System.out.println(“Object d1 belongs to ” + d1.getClass()); // prints …

Get Access Specifiers and Modifiers of a Class Read More »