All fields

“Exceptions” in Information Technology

61 questions across 7 technologies.

Information Technology

61 questions in 7 technologies

#QuestionTechnologyTopicLevel
1What is the difference between checked and unchecked exceptions in Java, and how does the compiler treat each differently? Java › ExceptionsJavaExceptionsBeginner
2What is a common anti-pattern with catching exceptions too broadly (catch (Exception e) or worse, catch (Throwable t)), and why is it generally discouraged? Java › ExceptionsJavaExceptionsIntermediate
3What is the purpose of the addSuppressed() mechanism and getSuppressed() method on Throwable, and in what specific scenario does the JVM automatically populate suppressed exceptions? Java › ExceptionsJavaExceptionsIntermediate
4How would you convert a checked-exception-throwing method into a lambda usable with a standard functional interface (which doesn't declare any checked exceptions), given standard interfaces like Function don't permit checked exceptions in their abstract method signature? Java › Functional Interfaces & Method ReferencesJavaFunctional Interfaces & Method ReferencesIntermediate
5How should exceptions be handled inside a BackgroundService's ExecuteAsync loop to prevent the entire service from crashing silently? .NET › Background Services.NETBackground ServicesIntermediate
6How do you handle exceptions specifically within minimal API endpoints, given they don't use the traditional MVC exception filter pipeline? .NET › Global Exception Handling & Middleware.NETGlobal Exception Handling & MiddlewareIntermediate
7What is the difference between handling exceptions with middleware versus using try/catch blocks directly in controller actions? .NET › Global Exception Handling & Middleware.NETGlobal Exception Handling & MiddlewareIntermediate
8How should a global exception handler differentiate between exceptions that should return specific client-facing details versus exceptions that should always show a generic message? .NET › Global Exception Handling & Middleware.NETGlobal Exception Handling & MiddlewareIntermediate
9How should exceptions be handled inside a BackgroundService's work loop to prevent one failure from silently stopping all future processing? ASP.NET Core › Background Tasks & Hosted ServicesASP.NET CoreBackground Tasks & Hosted ServicesIntermediate
10How do you handle exceptions specifically within minimal API endpoints, given they don't use the traditional MVC exception filter pipeline? ASP.NET Core › Error HandlingASP.NET CoreError HandlingIntermediate
11How should a global exception handler differentiate between exceptions meant for client-facing details versus exceptions that should always show a generic message? ASP.NET Core › Error HandlingASP.NET CoreError HandlingIntermediate
12How do you configure PDO's error handling mode to ensure database errors are properly reported as catchable exceptions rather than silently failing? PHP › PDO & DatabasesPHPPDO & DatabasesIntermediate
13When should you create custom exceptions vs use built-in ones? C# › Exception HandlingC#Exception HandlingAdvanced
14What is the recommended strategy for exceptions in a layered/enterprise app? C# › Exception HandlingC#Exception HandlingAdvanced
15How do you write a generic Result<T, E> discriminated union type for functional-style error handling, and why is it preferred over throwing exceptions in some codebases? TypeScript › Discriminated Unions & Exhaustiveness CheckingTypeScriptDiscriminated Unions & Exhaustiveness CheckingAdvanced
16How does exception handling interact with async/await, and how are exceptions from an async Task propagated to the awaiting caller? C# › Exception HandlingC#Exception HandlingAdvanced
17How does AggregateException work with Task.WhenAll() when multiple concurrent tasks throw exceptions? C# › Exception HandlingC#Exception HandlingAdvanced
18How would you design a robust global exception handling middleware in ASP.NET Core to convert unhandled exceptions into consistent API error responses? C# › Exception HandlingC#Exception HandlingAdvanced
19How does exception performance (throwing/catching) compare to normal control flow, and why should exceptions generally NOT be used for expected, routine control flow? C# › Exception HandlingC#Exception HandlingAdvanced
20How does the C# 'nameof' operator work, and why is it preferred over hardcoding a string literal for things like argument names in exceptions? C# › FundamentalsC#FundamentalsAdvanced
21How does Python 3.11's exception groups (ExceptionGroup) and the 'except*' syntax let you handle MULTIPLE unrelated exceptions raised together? Python › Exception HandlingPythonException HandlingAdvanced
22How would you implement a retry-with-backoff decorator that catches specific transient exceptions and retries with increasing delays? Python › Exception HandlingPythonException HandlingAdvanced
23How does exception performance (raising/catching) compare to normal control flow, and why does Python's EAFP style still encourage using exceptions for routine control flow, unlike some other languages? Python › Exception HandlingPythonException HandlingAdvanced
24How does the CLR handle exceptions at a low level, and what is the performance implication of throwing exceptions frequently? .NET › CLR & Runtime.NETCLR & RuntimeAdvanced
25How would you implement custom middleware to catch and log unhandled exceptions before they reach the exception handler, adding request-specific context? .NET › Global Exception Handling & Middleware.NETGlobal Exception Handling & MiddlewareAdvanced
26How do you handle exceptions that occur during response streaming, after the response has already partially started sending to the client? .NET › Global Exception Handling & Middleware.NETGlobal Exception Handling & MiddlewareAdvanced
27How do you handle exceptions that occur during response streaming, after the response has already partially started sending to the client? ASP.NET Core › Error HandlingASP.NET CoreError HandlingAdvanced
28How do you set a global exception handler and error handler in PHP to consistently catch and log any uncaught exceptions or errors across an entire application? PHP › Error & Exception HandlingPHPError & Exception HandlingAdvanced
29What best practices should guide how an application logs, reports, and responds to exceptions differently across development and production environments? PHP › Error & Exception HandlingPHPError & Exception HandlingAdvanced
30What is the basic syntax and control flow of a try-catch-finally block, and what determines which catch block (if multiple exist) handles a thrown exception? Java › ExceptionsJavaExceptionsBeginner
31What is the correct usage of try-with-resources, and how does it automatically ensure a resource's close() method is called even if an exception occurs? Java › ExceptionsJavaExceptionsIntermediate
32What is the finally block's execution guarantee, and what are the specific edge cases where a finally block might NOT execute? Java › ExceptionsJavaExceptionsIntermediate
33What is the multi-catch syntax (catch (IOException | SQLException e)) introduced in Java 7, and what restriction applies to the exception types combined in a single multi-catch block? Java › ExceptionsJavaExceptionsIntermediate
34What is the difference between Error and Exception in Java's Throwable hierarchy, and why should application code generally avoid catching Error subclasses like OutOfMemoryError or StackOverflowError? Java › ExceptionsJavaExceptionsIntermediate
35How do you create and throw a custom exception class, and what constructors should a well-designed custom exception typically provide? Java › ExceptionsJavaExceptionsIntermediate
36How does exception chaining (via the cause mechanism, initCause() or a constructor accepting a Throwable) preserve the original root-cause exception when wrapping and rethrowing a different exception type, and why does this matter for debugging? Java › ExceptionsJavaExceptionsAdvanced
37How would you design a custom exception hierarchy for an application, deciding when to create new exception classes versus reusing existing ones, and what fields/context should a well-designed custom exception carry? Java › ExceptionsJavaExceptionsAdvanced
38How does exception handling interact with performance, particularly regarding the cost of filling in a stack trace, and how would you optimize exception usage in a performance-critical hot path? Java › ExceptionsJavaExceptionsAdvanced
39How would you implement a custom checked exception that requires additional context to be attached as the exception propagates up multiple layers of a call stack, without losing information at each layer? Java › ExceptionsJavaExceptionsAdvanced
40How does exception handling interact with generics and type erasure, specifically regarding why you cannot catch a generic type parameter as an exception type (catch (T e))? Java › ExceptionsJavaExceptionsAdvanced
41How would you design and implement a global, centralized exception-handling strategy for a Java application (such as a top-level handler in main(), or an uncaught exception handler for background threads), ensuring no exception silently crashes the application without being logged? Java › ExceptionsJavaExceptionsAdvanced
42How do you apply multiple different annotations to the same element, and does their order matter? Java › AnnotationsJavaAnnotationsBeginner
43How do you declare and initialize an array of objects (reference types) versus an array of primitives, and what is the key difference in their default values? Java › Arrays & Multidimensional ArraysJavaArrays & Multidimensional ArraysBeginner
44What is the difference between the @Nullable/@NonNull annotations (from libraries like JetBrains or JSR-305) and Java's built-in Optional type for expressing nullability? Java › AnnotationsJavaAnnotationsIntermediate
45How does Java handle array bounds checking, and what exception is thrown when accessing an invalid index? Java › Arrays & Multidimensional ArraysJavaArrays & Multidimensional ArraysIntermediate
46What causes a ClassNotFoundException versus a NoClassDefFoundError, and how do you distinguish and diagnose each? Java › Class Loading & Bytecode VerificationJavaClass Loading & Bytecode VerificationIntermediate
47What is the difference between fail-fast and fail-safe iterators in the Collections Framework, and which collections use each? Java › Collections FrameworkJavaCollections FrameworkIntermediate
48What is a race condition, and how does it differ conceptually from a deadlock as two distinct categories of concurrency bugs? Java › Concurrency & ThreadsJavaConcurrency & ThreadsIntermediate
49What is the valueOf() method on an enum, and what happens when you pass a name that doesn't match any declared constant? Java › EnumsJavaEnumsIntermediate
50How does Objects.equals() and Objects.hash() from java.util.Objects simplify writing correct equals() and hashCode() implementations, particularly regarding null-safety? Java › equals(), hashCode() & toString() ContractsJavaequals(), hashCode() & toString() ContractsIntermediate
51What is the purpose of overriding toString(), and what's the difference between Object's default implementation and a well-designed custom one? Java › equals(), hashCode() & toString() ContractsJavaequals(), hashCode() & toString() ContractsIntermediate
52How would you write a unit test that thoroughly verifies a custom equals() and hashCode() implementation satisfies its contract, and what testing libraries exist specifically for this purpose? Java › equals(), hashCode() & toString() ContractsJavaequals(), hashCode() & toString() ContractsIntermediate
53What is the purpose of the PrintStream and PrintWriter classes (like System.out), and how do they differ from lower-level OutputStream/Writer in their exception-handling behavior? Java › I/O & NIOJavaI/O & NIOIntermediate
54How does Java's operator precedence and associativity determine the evaluation order of a complex expression, and what are some common precedence-related mistakes? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsIntermediate
55What is the difference between the ++ (increment) and -- (decrement) operators used in prefix versus postfix position, and what subtle bug can arise from using them within a complex expression? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsIntermediate
56How does Java's short-circuit evaluation for && and || operators differ from the non-short-circuiting & and | operators when applied to boolean operands, and why does this distinction matter for avoiding NullPointerException? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsIntermediate
57How would you implement annotation-based validation (similar to Bean Validation's @NotNull, @Size) using a custom annotation and a reflection-based validator? Java › AnnotationsJavaAnnotationsAdvanced
58How does Java implement covariant array typing, and why is this considered a design flaw that can lead to runtime ArrayStoreException? Java › Arrays & Multidimensional ArraysJavaArrays & Multidimensional ArraysAdvanced
59How does the Collections Framework's fail-fast modCount mechanism actually work internally, and why is it described as "best-effort" rather than a strict guarantee? Java › Collections FrameworkJavaCollections FrameworkAdvanced
60How would you implement a custom enum that also functions as a lookup table (mapping an external code to a constant), such as parsing an HTTP status code string into an enum constant, handling unknown values gracefully? Java › EnumsJavaEnumsAdvanced
61How does Java's implicit numeric type promotion and narrowing/widening conversion rules work, and what specific data-loss or precision risks does an implicit narrowing conversion (requiring an explicit cast) guard against? Java › Java Fundamentals: Syntax, Data Types & OperatorsJavaJava Fundamentals: Syntax, Data Types & OperatorsAdvanced