

We can invoke a method through reflection if we know its name and parameter types. The getMethods() method is used to get the public methods of the class to which an object belongs. The getConstructors() method is used to get the public constructors of the class to which an object belongs. The getClass() method is used to get the name of the class to which an object belongs. Reflection can be used to get information about class, constructors, and methods as depicted below in tabular format as shown: Class Through reflection, we can invoke methods at runtime irrespective of the access specifier used with them.

Reflection gives us information about the class to which an object belongs and also the methods of that class that can be executed by using the object.Split() String method in Java with examples.Types of Exception in Java with Examples.Flow control in try catch finally in Java.Nested try blocks in Exception Handling in Java.Output of Java program | Set 12(Exception Handling).Infinity or Exception in Java when divide by 0?.Different Ways to Print Exception Messages in Java.

