HuntExams Academy logo
JavaAdvanced#jvm

What is reflection in Java?

Answer

API to inspect and modify classes, methods, and fields at runtime. Used by frameworks (Spring, Hibernate) and serializers. Comes with performance and security trade-offs.

Example

Class<?> clazz = Class.forName("java.util.ArrayList");
Method[] methods = clazz.getDeclaredMethods();
Object instance = clazz.getDeclaredConstructor().newInstance();

Related Interview Questions

1
JavaIntermediate#generics

What are Java generics?

Open
2
JavaAdvanced#generics

Difference between '? extends T' and '? super T'?

Open
3
JavaAdvanced#concurrency#jvm

What is the Java Memory Model (JMM)?

Open