All fields

“Reflection” in Information Technology

32 questions across 5 technologies.

Information Technology

32 questions in 5 technologies

#QuestionTechnologyTopicLevel
1What is reflection in C#, and what are its most common practical uses and performance trade-offs? C# › Attributes & ReflectionC#Attributes & ReflectionIntermediate
2What is reflection, and what basic information can you retrieve from a Type object at runtime? C# › Attributes & ReflectionC#Attributes & ReflectionBeginner
3How do you use reflection to read a custom attribute's values off a property at runtime? C# › Attributes & ReflectionC#Attributes & ReflectionIntermediate
4How do you dynamically create an instance of a type and invoke a method on it using reflection, when the type isn't known at compile time? C# › Attributes & ReflectionC#Attributes & ReflectionIntermediate
5How does the .NET dependency injection container and ASP.NET Core's model binding use reflection and attributes together under the hood? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
6How would you write a simple reflection-based object mapper that copies matching property values from one object to another of a different type? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
7How do you use reflection to discover all types in an assembly that implement a specific interface, useful for plugin discovery? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
8Why is reflection generally slower than direct code, and what techniques (like caching or compiled expressions) mitigate this cost? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
9How would you use System.Reflection.Emit or source generators as faster, more modern alternatives to runtime reflection for code generation scenarios? C# › Attributes & ReflectionC#Attributes & ReflectionAdvanced
10What is the difference between compile-time annotation processing (via javax.annotation.processing.Processor) and runtime reflection-based annotation reading? Java › AnnotationsJavaAnnotationsIntermediate
11How would you use a Class<T> token parameter to work around type erasure when a generic method genuinely needs runtime access to the actual type argument, such as for deserialization or reflection-based instantiation? Java › GenericsJavaGenericsIntermediate
12What is the difference between 'exports' and 'opens' in a module-info.java file, and why does reflection-heavy code (like many dependency injection or serialization frameworks) specifically require the latter? Java › Java Platform Module System (JPMS)JavaJava Platform Module System (JPMS)Intermediate
13How would you read custom annotations at runtime using reflection to implement annotation-driven behavior, such as a simple dependency injection or validation framework? Java › AnnotationsJavaAnnotationsAdvanced
14How would you implement annotation-based validation (similar to Bean Validation's @NotNull, @Size) using a custom annotation and a reflection-based validator? Java › AnnotationsJavaAnnotationsAdvanced
15How would you design a custom annotation-driven caching mechanism (similar to Spring's @Cacheable) using a dynamic proxy combined with reflection? Java › AnnotationsJavaAnnotationsAdvanced
16How does JPMS's strong encapsulation interact with reflection-heavy frameworks and libraries that predate the module system, and what specific JVM flags (like --add-opens) exist as an escape hatch for cases where proper module declarations aren't feasible? Java › Java Platform Module System (JPMS)JavaJava Platform Module System (JPMS)Advanced
17How do you enable and use gRPC reflection for service discovery and debugging tools like grpcurl or Postman? ASP.NET Core › gRPC ServicesASP.NET CoregRPC ServicesIntermediate
18How can you convert an enum to a string (reflection limitations)? C++ › Enums & Enum ClassesC++Enums & Enum ClassesAdvanced
19How does reflection allow inspecting an assembly's types and metadata at runtime, and what are common uses? .NET › Assemblies & NuGet.NETAssemblies & NuGetAdvanced
20What is an attribute in C#, and how do you apply one to a class or method? C# › Attributes & ReflectionC#Attributes & ReflectionBeginner
21How do you create a custom attribute class, and what does AttributeUsage control? C# › Attributes & ReflectionC#Attributes & ReflectionIntermediate
22What are annotations in Java, and what purpose do they serve? Java › AnnotationsJavaAnnotationsBeginner
23What is the role of the ClassLoader in the JVM, and what are the three built-in bootstrap/platform/application class loaders? Java › Class Loading & Bytecode VerificationJavaClass Loading & Bytecode VerificationBeginner
24How do you programmatically load a class by its fully-qualified name at runtime using Class.forName(), and what is a common real-world use case for this? Java › Class Loading & Bytecode VerificationJavaClass Loading & Bytecode VerificationBeginner
25How do you create a 'flags' enum that supports combining multiple values using bitwise operations? C# › Enums & FlagsC#Enums & FlagsIntermediate
26How do you create a custom annotation in Java, and what role do @Retention and @Target play? Java › AnnotationsJavaAnnotationsIntermediate
27What are Java's meta-annotations (@Retention, @Target, @Documented, @Inherited), and what does each control? Java › AnnotationsJavaAnnotationsIntermediate
28How does the Java Platform Module System (JPMS, introduced in Java 9) change class loading and encapsulation compared to the traditional classpath model? Java › Class Loading & Bytecode VerificationJavaClass Loading & Bytecode VerificationIntermediate
29What is type erasure, and how does it explain why generic type information is unavailable at runtime (e.g., why you can't do `if (obj instanceof List<String>)`)? Java › GenericsJavaGenericsIntermediate
30How do generic attributes (introduced in C# 11) work, and what limitation did they finally remove compared to older attribute usage patterns? C# › GenericsC#GenericsAdvanced
31How does the 'file' access modifier (C# 11) create a type visible ONLY within its own source file, and what problem does this solve for source generators? C# › Modern C# Features (Global Usings, File-Scoped Namespaces, Top-Level Statements)C#Modern C# Features (Global Usings, File-Scoped Namespaces, Top-Level Statements)Advanced
32How do repeatable annotations work in Java (using @Repeatable), and what problem do they solve? Java › AnnotationsJavaAnnotationsAdvanced