InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
For Name () Method Of Class Class? |
Answer»
Let's SEE the SIMPLE example of forName () method. class Simple{} class Test{ public STATIC void main(String ARGS[]){ Class c=Class.forName("Simple"); System.out.println(c.getName()); } } Output: Simple Let's see the simple example of forName () method. class Simple{} class Test{ public static void main(String args[]){ Class c=Class.forName("Simple"); System.out.println(c.getName()); } } Output: Simple |
|
| 2. |
Determining The Class Object? |
|
Answer» Following methods of Class class is USED to DETERMINE the class object:
Let's see the SIMPLE example of reflection api to determine the object type. class Simple{} interface My{} class TEST{ public static void main(STRING args[]){ try{ Class c=Class.forName("Simple"); System.out.println(c.is Interface()); Class c2=Class.forName("My"); System.out.println(c2.is Interface()); }catch(Exception e){System.out.println(e);} } } Output: false true Following methods of Class class is used to determine the class object: Let's see the simple example of reflection api to determine the object type. class Simple{} interface My{} class Test{ public static void main(String args[]){ try{ Class c=Class.forName("Simple"); System.out.println(c.is Interface()); Class c2=Class.forName("My"); System.out.println(c2.is Interface()); }catch(Exception e){System.out.println(e);} } } Output: false true |
|
| 3. |
How To Get The Object Of Class Class? |
|
Answer» There are 3 WAYS to GET the instance of Class class. They are as FOLLOWS:
There are 3 ways to get the instance of Class class. They are as follows: |
|
| 4. |
Why Is Reflection Slower? |
|
Answer» Because it has to inspect the metadata in the Bytecode instead of just USING pre compiled addresses and CONSTANTS. Because it has to inspect the metadata in the Bytecode instead of just using pre compiled addresses and constants. |
|
| 5. |
What Is Performing Java.lang. Class Class? |
|
Answer» The java.lang. CLASS class performs mainly two tasks:
The java.lang. Class class performs mainly two tasks: |
|
| 6. |
Is It Good To Use Reflection In An Application? Why? |
|
Answer» No, It's LIKE CHALLENGING the DESIGN of APPLICATION. No, It's like challenging the design of application. |
|
| 7. |
What Is The Use Of System.reflection Namespace? |
|
Answer» The System.Reflection namespace contains types that retrieve information about assemblies, modules, members, parameters, and other entities in managed code by EXAMINING their METADATA. These types also can be used to manipulate instances of loaded types, for example to HOOK up events or to invoke methods. The System.Reflection namespace contains types that retrieve information about assemblies, modules, members, parameters, and other entities in managed code by examining their metadata. These types also can be used to manipulate instances of loaded types, for example to hook up events or to invoke methods. |
|
| 8. |
Which Name Space Contains The Classes That Are Used To Enables You To Build Types At Run Time? |
|
Answer» System.Reflection. EMIT System.Reflection. Emit |
|
| 9. |
Which Property Is Used To Determine Whether The Type Is Generic? |
|
Answer» USE the IsGenericType PROPERTY to DETERMINE WHETHER the type is generic, and use the IsGenericTypeDefinition property to determine whether the type is a generic type DEFINITION. Use the IsGenericType property to determine whether the type is generic, and use the IsGenericTypeDefinition property to determine whether the type is a generic type definition. |
|
| 10. |
How Do You Obtain Module Type Objects? |
|
Answer» USE MODULE.GetType and Module.GetType to OBTAIN module TYPE OBJECTS. Use Module.GetType and Module.GetType to obtain module Type objects. |
|
| 11. |
How Do You Get To Type Objects From An Assembly That Is Already Loaded? |
|
Answer» USE Type.GetType to get the Type OBJECTS from an assembly that is ALREADY LOADED Use Type. Get Type to get the Type objects from an assembly that is already loaded. Use Type.GetType to get the Type objects from an assembly that is already loaded Use Type. Get Type to get the Type objects from an assembly that is already loaded. |
|
| 12. |
How Do You Get Type Objects From Assemblies That Have Not Been Loaded? |
|
Answer» USE Assembly.GetType or Assembly.GetType to obtain Type objects from assemblies that have not been loaded, PASSING in the name of the type or types you WANT. Use Assembly.GetType or Assembly.GetType to obtain Type objects from assemblies that have not been loaded, passing in the name of the type or types you want. |
|
| 13. |
Which Class Has Significant Importance For Reflection? |
|
Answer» The System. Type class is CENTRAL to reflection. The COMMON language runtime creates the Type for a loaded type when reflection REQUESTS it. You can use a Type object's methods, fields, properties, and nested classes to FIND out EVERYTHING about that type. The System. Type class is central to reflection. The common language runtime creates the Type for a loaded type when reflection requests it. You can use a Type object's methods, fields, properties, and nested classes to find out everything about that type. |
|
| 14. |
What Is Custom Binding? |
|
Answer» The common language runtime supports multiple programming languages, and the binding rules of these languages differ. In the early-bound CASE, code generators can COMPLETELY control this binding. However, in late binding through reflection, binding must be controlled by customized binding. The Binder class provides custom control of member selection and invocation. Using custom binding, you can load an assembly at run time, obtain information about TYPES in that assembly, specify the type that you want, and then invoke methods or ACCESS FIELDS or properties on that type. This technique is useful if you do not know an object's type at compile time, such as when the object type is dependent on user input. The common language runtime supports multiple programming languages, and the binding rules of these languages differ. In the early-bound case, code generators can completely control this binding. However, in late binding through reflection, binding must be controlled by customized binding. The Binder class provides custom control of member selection and invocation. Using custom binding, you can load an assembly at run time, obtain information about types in that assembly, specify the type that you want, and then invoke methods or access fields or properties on that type. This technique is useful if you do not know an object's type at compile time, such as when the object type is dependent on user input. |
|
| 15. |
What Is Late Binding? |
|
Answer» BINDING is the PROCESS of locating the declaration that corresponds to a uniquely specified type. When this process occurs at RUN time rather than at compile time, it is called LATE binding. Binding is the process of locating the declaration that corresponds to a uniquely specified type. When this process occurs at run time rather than at compile time, it is called late binding. |
|
| 16. |
When Reflection Is Useful? |
|
Answer» Reflection is USEFUL in the following situations:
Reflection is useful in the following situations: |
|