Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (2.6k points)

What is the reflection in JAVA, and why is it useful?

I'm particularly interested in Java, but I assume the principles are the same in any language.

1 Answer

0 votes
by (46k points)

  • Reflection is an API and used to examine or modify the behavior of methods, classes, interfaces at runtime.

  • It gives us information about the class to which an object belongs and also tells us about the methods of that class which can be executed by using the object.


Usage of Reflection:

  • It's an Extensibility feature so it offers an application to use external, user-defined classes by creating instances of extensibility objects using their fully-qualified names.

  • They brake the abstractions and hence may change behavior with upgrades of the platform.

 For more details and examples click here.

Related questions

Browse Categories