MCQOPTIONS
Saved Bookmarks
This section includes 12 Mcqs, each offering curated multiple-choice questions to sharpen your Advanced Java knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What does foo.getClass().getMethod(“doSomething”, null) return? |
| A. | doSomething method instance |
| B. | Method is returned and we can call the method as method.invoke(foo,null); |
| C. | Class object |
| D. | Exception is thrown |
| Answer» C. Class object | |
| 2. |
What does Class.forName(“myreflection.Foo”).getInstance() return? |
| A. | An array of Foo objects |
| B. | class object of Foo |
| C. | Calls the getInstance() method of Foo class |
| D. | Foo object |
| Answer» E. | |
| 3. |
How to get the class object of associated class using Reflection? |
| A. | Class.forName(“className”) |
| B. | Class.name(“className”) |
| C. | className.getClass() |
| D. | className.getClassName() |
| Answer» B. Class.name(“className”) | |
| 4. |
How method can be invoked on unknown object? |
| A. | obj.getClass().getDeclaredMethod() |
| B. | obj.getClass().getDeclaredField() |
| C. | obj.getClass().getMethod() |
| D. | obj.getClass().getObject() |
| Answer» D. obj.getClass().getObject() | |
| 5. |
What is used to get class name in reflection? |
| A. | getClass().getName() |
| B. | getClass().getFields() |
| C. | getClass().getDeclaredFields() |
| D. | new getClass() |
| Answer» B. getClass().getFields() | |
| 6. |
How private field can be called using reflection? |
| A. | getDeclaredFields |
| B. | getDeclaredMethods |
| C. | getMethods |
| D. | getFields |
| Answer» B. getDeclaredMethods | |
| 7. |
How private method can be called using reflection? |
| A. | getDeclaredFields |
| B. | getDeclaredMethods |
| C. | getMethods |
| D. | getFields |
| Answer» C. getMethods | |
| 8. |
What is not the advantage of Reflection? |
| A. | Examine a class’s field and method at runtime |
| B. | Construct an object for a class at runtime |
| C. | Examine a class’s field at compile time |
| D. | Examine an object’s class at runtime |
| Answer» D. Examine an object’s class at runtime | |
| 9. |
Which of the following is not a marker interface? |
| A. | Serializable |
| B. | Cloneable |
| C. | Remote |
| D. | Reader |
| Answer» E. | |
| 10. |
WHAT_DOES_FOO.GETCLASS().GETMETHOD(‚ÄÖ√Ñ√∂‚ÀÖ√Ë‚ÀÖ‚À´DOSOMETHING‚ÄÖ√Ñ√∂‚ÀÖ√Ë‚ÀÖŒÄ,_NULL)_RETURN??$# |
| A. | doSomething method instance |
| B. | Method is returned and we can call the method as method.invoke(foo,null); |
| C. | Class object |
| D. | Exception is thrown |
| Answer» C. Class object | |
| 11. |
What does Class.forName(“myreflection.Foo”).getInstance() return?# |
| A. | An array of Foo objects |
| B. | class object of Foo |
| C. | Calls the getInstance() method of Foo class |
| D. | Foo object |
| Answer» E. | |
| 12. |
What are the components of a marker interface? |
| A. | Fields and methods |
| B. | No fields, only methods |
| C. | Fields, no methods |
| D. | No fields, No methods |
| Answer» E. | |