Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What method do you use to get a Class object from its name?
Think about how we reference classes in Java.
How do you create an instance of a class using reflection?
Remember the method that allows constructor invocation.
How do you create an object of a class using reflection?
Focus on how constructors are called.
True or False: Reflection can access private members of a class.
Consider the permissions granted by reflection.
Create a Java program that uses reflection to instantiate an object of a class you define, accesses its private field, and prints its value.
Use `getDeclaredField` and `setAccessible(true)` for accessing the private field.
Write a code snippet that shows how to handle exceptions that may arise when using reflection to create an object.
Look at the exceptions that are thrown when construction fails.
4 more questions in this section. Enroll free to practise them all.
Enroll free