Visual Basic interviews should reveal whether a candidate understands the behavior behind familiar syntax. Recruiters need to assess types and conversions, object identity, resource lifetime, deferred queries, and asynchronous control flow. These details matter in systems where an apparently small change can alter financial calculations, retain a file handle, or leave background work unobserved.
This guide to 100+ Visual Basic Interview Questions and Answers contains 120 questions across beginner, intermediate, and experienced levels. Its primary scope is modern VB.NET and the .NET ecosystem. VBA and VB6 are identified explicitly when discussing legacy or host-specific differences; they are not treated as interchangeable environments.
How can recruiters assess genuine Visual Basic expertise when interview assistance can conceal gaps in conversion rules, object lifetime, and asynchronous behavior?
Give the candidate a short method that mutates an object passed ByVal or returns a deferred query. Ask them to predict the behavior and identify a meaningful test, then introduce cancellation or a missing value. Their explanation should distinguish language rules, runtime behavior, and the business contract.
Sherlock AI helps hiring teams assess signals of potential AI cheating, deepfakes, impersonation, and unauthorized assistance during interviews.
Interpret those signals alongside practical work and the candidate’s reasoning, not as conclusive proof of misconduct. A useful exercise rewards precise assumptions and honest validation rather than a memorized answer translated from another language.
Visual Basic Interview Questions
The complete question bank appears first so interviewers can select prompts without exposing the answers. Match the questions to the role’s responsibilities and state the target framework, compiler options, platform, and dependency assumptions.
Visual Basic Interview Questions for Beginners
Establish the language and runtime fundamentals, including types, control flow, object contracts, and resource ownership. Ask candidates to explain observable behavior.
What is Visual Basic .NET?
How does VB.NET differ from VBA and VB6?
What is the role of the .NET runtime?
How do a Module and a Class differ?
What do Sub and Function mean?
What does Option Explicit control?
What does Option Strict control?
What does Option Infer control?
How do value types and reference types differ?
What does Nothing mean in VB.NET?
What is a nullable value type?
How do Integer, Long, Decimal, and Double differ?
What is the difference between widening and narrowing conversions?
How do parsing and casting differ?
How do CType, DirectCast, and TryCast differ?
How do ByVal and ByRef differ?
How do arrays and List(Of T) differ?
What are generics useful for?
When would you use Dictionary(Of TKey, TValue)?
How do For and For Each differ?
How do AndAlso and OrElse differ from And and Or?
How do the If operator and IIf function differ?
How do equality and reference identity differ?
What does Option Compare affect?
Why are strings described as immutable?
What is a property used for?
What is a constructor?
How does inheritance work in VB.NET?
What is an interface?
What does Shared mean?
What do Public, Private, Friend, and Protected mean?
How do exceptions work in VB.NET?
What is Finally used for?
What does Using do?
How does garbage collection differ from disposal?
What is a delegate?
What are events used for?
What is LINQ in VB.NET?
What does Async and Await provide?
How would you approach a small new VB.NET application?
Visual Basic Interview Questions for Intermediate
Explore conversion boundaries, query execution, asynchronous operations, synchronization, testing, and interoperability. Strong answers include concrete assumptions and failure cases.
How would you parse a decimal amount safely?
How would you avoid confusing Nothing with an empty string?
How does integer division differ from ordinary division?
What should you know about CInt and rounding?
How do overloaded methods differ from overridden methods?
How do Shadows and Overrides differ?
When would you choose a Structure instead of a Class?
How would you implement value equality correctly?
What are extension methods?
How do anonymous types help LINQ projections?
What is deferred execution in LINQ to Objects?
When should you materialize a LINQ query?
How do IEnumerable(Of T) and IQueryable(Of T) differ?
How do Where and Select differ?
How do First, Single, and their default-returning variants differ?
How would you handle duplicate keys when building a dictionary?
What are iterator functions useful for?
How do closures affect lambdas?
When should you remove an event handler?
How would you rethrow an exception without losing its original context?
How would you design an exception-handling boundary?
How do Task and Task(Of T) differ?
Why should Async Sub usually be limited to event handlers?
How does cooperative cancellation work?
How does Task.WhenAll differ from awaiting operations one at a time?
Why can blocking on Result or Wait cause problems?
When is Task.Run appropriate?
What does ConfigureAwait(False) change?
How would you update a Windows Forms control from background work?
What does SyncLock protect?
When would you use Interlocked or a concurrent collection?
How do optional parameters and overloads affect API design?
How do Imports and assembly references differ?
What should you consider when reading and writing files?
How would you access a database safely from VB.NET?
How would you test code that depends on time or external services?
How would you use XML literals responsibly?
What should you check before using COM interoperability?
How would you choose a string comparer for identifiers?
How would you review a VB.NET method before merging it?
Visual Basic Interview Questions for Experienced
Use these scenarios to assess modernization, concurrency, security, deployment, and operational judgment. Look for evidence, ownership, and realistic recovery plans.
How would you migrate a VB6 application to modern VB.NET?
How would you move a VB.NET application from .NET Framework to modern .NET?
How would you decide whether to retain or rewrite a large VB.NET codebase?
How would you introduce Option Strict into a legacy project?
How would you investigate a production-only conversion failure?
How would you design a reusable VB.NET library for other .NET languages?
How would you evolve a public API without breaking callers?
How would you diagnose memory growth in a long-running application?
How would you distinguish a managed-memory leak from a resource leak?
How would you implement IDisposable in a class that owns resources?
How would you handle asynchronous disposal from VB.NET?
How would you investigate an asynchronous deadlock?
How would you bound concurrent asynchronous work?
How would you make a background task observable and stoppable?
How would you design retries around a remote write?
How would you prevent race conditions in a shared cache?
How would you choose between locks and immutable state?
How would you review a LINQ query for unexpected repeated work?
How would you avoid returning a sequence tied to a disposed resource?
How would you reason about performance before replacing LINQ with loops?
How would you design deterministic tests for concurrent code?
How would you design cancellation across several layers?
How would you handle multiple failures from parallel tasks?
How would you secure serialization boundaries?
How would you handle secrets in a desktop or service application?
How would you design safe diagnostic logging?
How would you diagnose a culture-dependent production bug?
How would you handle time and time zones in an application?
How would you design a robust file-processing job?
How would you make a database operation idempotent?
How would you diagnose a deployment that works on the developer machine only?
How do framework-dependent and self-contained deployment differ?
What should you assess before enabling trimming or ahead-of-time compilation?
How would you isolate a legacy COM dependency during modernization?
How would you review generated or translated VB.NET code?
How would you prioritize technical debt in a mature VB.NET system?
How would you investigate a performance regression after a framework upgrade?
How would you design a practical Visual Basic interview exercise?
What evidence would you collect before accepting a modernization release?
What does maintainable production VB.NET code look like?
Visual Basic Interview Questions and Answers
The answers follow the exact wording, numbering, and order of the bank. Examples target modern VB.NET, with Option Strict On, Option Explicit On, and Option Infer On assumed; relevant Imports and containing code are shown. No suitable installed VB.NET compiler or runtime was available for execution, so all examples received static review only. No compilation, concurrency run, COM activation, or deployed application test is claimed. Check target-framework and platform support before adopting a library or deployment feature.
Visual Basic Interview Questions and Answers for Beginners
Establish the language and runtime fundamentals, including types, control flow, object contracts, and resource ownership. Ask candidates to explain observable behavior.
1. What is Visual Basic .NET?
Visual Basic .NET is a statically typed language that targets the .NET runtime and libraries. It supports object-oriented design, generics, LINQ, and task-based asynchronous programming. A VB.NET application can share libraries with other .NET languages when their public APIs are compatible. I would identify the target framework and application type before discussing deployment, because a console library and a Windows Forms application have different platform requirements. The familiar Visual Basic name does not make VB.NET interchangeable with VBA or VB6.
2. How does VB.NET differ from VBA and VB6?
VB.NET uses the .NET type system, runtime, and libraries. VBA is primarily a host-embedded automation language, such as the language used in Office applications, while VB6 belongs to an earlier application development environment. Their object models, deployment, error handling conventions, and language features differ. I would not paste a VB.NET async example into a VBA module or assume a legacy ActiveX dependency runs cross-platform. Migration requires examining actual behavior and dependencies rather than changing file extensions.
3. What is the role of the .NET runtime?
The runtime provides services such as managed execution, garbage collection, exception handling, and type safety. VB.NET compiles to an assembly that is executed within the selected .NET environment, with compilation details depending on deployment choices. The runtime does not eliminate resource leaks, race conditions, or business errors. For example, a managed object can still hold an open file until it is disposed. I would distinguish language syntax from runtime and library behavior when investigating an application.
4. How do a Module and a Class differ?
A Module groups members that are implicitly shared and is not instantiated like a class. A Class defines a reference type whose instances can hold independent state, though it can also declare Shared members. I use a class when behavior belongs to a particular object or needs a replaceable dependency. A module can suit small stateless helpers, but putting mutable application state in one creates global coupling. Neither construct by itself provides thread safety or a good ownership model.
5. What do Sub and Function mean?
A Sub performs an operation without returning a value through its return type; a Function returns a value. The distinction should reflect the API contract rather than whether the implementation happens to modify state. For example, a parsing function can return a result while a logging procedure may only record an event. Async methods add another consideration: an Async Function returning Task can be awaited, whereas Async Sub has special exception and completion behavior and should normally be reserved for event handlers.
6. What does Option Explicit control?
Option Explicit On requires variables to be declared before use, catching accidental names that might otherwise become implicitly declared variables. It reduces errors from misspellings and makes scope easier to understand. It does not require every declaration to spell out its type, because local type inference is a separate feature. I would normally keep it enabled and also review Option Strict and Option Infer. Those settings address related but different aspects of compile-time checking.
7. What does Option Strict control?
Option Strict On rejects implicit narrowing conversions, late binding, and implicit typing that results in Object. It encourages explicit type decisions and moves certain failures to compilation. It does not forbid all conversions or all uses of Object: a deliberate Object declaration is still possible, and explicit conversions can still fail at runtime. I would enable it for new code and test conversion boundaries rather than assuming a successful compilation proves every input fits the chosen numeric or reference type.
8. What does Option Infer control?
Option Infer On lets the compiler infer a local variable's type from its initializer. A declaration initialized with an integer literal remains statically typed; it is not a dynamically changing variable. This can improve readability when the initializer makes the type clear, especially with LINQ projections. I would still use explicit types where they clarify a public contract or a conversion. Option Infer is distinct from Option Strict, so its interaction with missing type declarations should be understood rather than guessed.
9. How do value types and reference types differ?
A value-type variable contains its value, while a reference-type variable contains a reference to an object. Assignment of a structure copies its value; assignment of a class reference can make two variables refer to the same object. A structure can itself contain references, so copying it does not necessarily clone the referenced objects. I avoid reducing the distinction to a universal stack-versus-heap rule because storage depends on context. The practical questions are copying, identity, mutation, and lifetime.
10. What does Nothing mean in VB.NET?
Nothing represents the default value of the destination type. For a reference type it is a null reference, for a non-nullable Integer it becomes zero, and for a nullable value type it represents no value. That differs from assuming Nothing is always an invalid object or always equivalent to C# null in every assignment. I would inspect the declared type when reasoning about it and use appropriate null or HasValue checks rather than treating zero as evidence that a value was supplied.
VB.NET example: Option Strict On, Option Explicit On, and Option Infer On; modern .NET context as shown.
This standalone console example is expected to print 0, False, and True. Each assignment uses the destination type’s default, so Nothing does not mean the same stored value in every declaration. The example was reviewed statically, not executed.
11. What is a nullable value type?
Nullable(Of T), often written with a question mark such as Integer?, represents either a value of a value type or no value. It is useful when missing differs from zero, such as an optional measurement. Check HasValue or use an intentional fallback before accessing Value, which throws when no value exists. Nullable operations can propagate missing values, so comparison and Boolean behavior need care. I would preserve the distinction through serialization and database boundaries instead of silently replacing every missing value with a default.
12. How do Integer, Long, Decimal, and Double differ?
Integer and Long are fixed-width signed integral types in VB.NET, while Decimal and Double represent different kinds of fractional numeric values. Decimal offers decimal arithmetic useful for many financial quantities; Double offers binary floating-point behavior suited to many scientific calculations. Neither is universally exact or immune to overflow and rounding issues. I would choose from the required range, precision, and calculation rules, then test boundaries. VB6 type names and widths should not be assumed to match modern VB.NET.
13. What is the difference between widening and narrowing conversions?
A widening conversion is classified as preserving the relevant range or type relationship, while a narrowing conversion can lose information or fail. Option Strict restricts implicit narrowing, prompting an explicit decision. The language's classification still has subtleties, such as precision loss when some numeric values are represented in floating point. I would not equate widening with exact decimal preservation. Validate untrusted input and use the intended conversion or parsing API, with tests for values outside the target's useful range.
14. How do parsing and casting differ?
Parsing interprets an external representation such as text according to a format and culture. Casting converts or reinterprets a value within the type system using the permitted conversion rules. A numeric string from a file needs a deliberate parsing policy; a reference known to implement an interface needs a type conversion. I prefer TryParse for expected invalid user input and explicit culture where the data format requires it. Catching every cast exception is not a substitute for defining the input contract.
15. How do CType, DirectCast, and TryCast differ?
CType supports language conversions, including applicable user-defined conversions. DirectCast is for conversions based on a type relationship and does not serve as a general numeric conversion operation. TryCast attempts a reference-type conversion and returns Nothing when it fails, rather than throwing for an incompatible object. I choose according to the actual contract: an optional interface check can use TryCast, while required conversion failure should remain visible. TryCast cannot be used as a universal safe conversion for value types.
16. How do ByVal and ByRef differ?
ByVal passes a copy of the argument's value; ByRef permits the procedure to work through a reference to the caller's variable, subject to the language's argument rules. For an object passed ByVal, the copied value is still an object reference, so the procedure can mutate that object while being unable to replace the caller's variable directly. I use ByRef when updating the variable is an intentional API contract, not as a general performance shortcut. Argument conversions and properties introduce additional copy-back subtleties.
VB.NET example: Option Strict On, Option Explicit On, and Option Infer On; modern .NET context as shown.
The expected output is 1,2. Adding changes the shared list object. Reassigning the local parameter changes only its copied reference; the caller’s variable still points to the original list. This is not a demonstration of thread safety or deep copying.
17. How do arrays and List(Of T) differ?
An array has a fixed length once created, while List(Of T) manages a resizable sequence using an internal storage strategy. In VB.NET, the number in an array bound declaration is the upper index, so a bound of four creates five elements. ReDim replaces or resizes an array variable rather than making each array instance intrinsically resizable. I choose based on the contract and access pattern, and avoid assuming that either collection permits safe concurrent mutation without coordination.
18. What are generics useful for?
Generics let types and methods operate with type parameters while retaining compile-time information. List(Of Integer), for example, expresses an integer collection without making callers repeatedly cast Object values. Generic constraints can state required capabilities, but they should be no stronger than the implementation needs. Generics improve reusable contracts; they do not automatically make an algorithm efficient or thread-safe. I would compare the actual API, boxing behavior, and data access pattern rather than treating generic syntax alone as a performance guarantee.
19. When would you use Dictionary(Of TKey, TValue)?
A dictionary associates keys with values and is useful for lookups such as locating a customer by identifier. Its behavior depends on key equality and hashing, so choose the comparer deliberately, particularly for strings. Duplicate key insertion and a missing lookup need an explicit policy; TryGetValue is often appropriate for expected absence. I would not rely on dictionary enumeration order as a business contract unless the selected API documents the needed guarantee, and would avoid mutating keys in ways that change their equality behavior.
20. How do For and For Each differ?
For expresses iteration using a control variable and bounds, while For Each traverses an enumerable sequence. For Each is often clearer when positions are irrelevant, but the sequence may execute code or fetch data during enumeration. A numeric loop is useful when indexes are part of the problem. I would inspect whether the collection can change during traversal and whether enumeration has side effects. Neither loop form automatically makes modifying the underlying collection safe.
21. How do AndAlso and OrElse differ from And and Or?
AndAlso and OrElse short-circuit Boolean evaluation: the second operand is evaluated only when needed. This is useful for guarding an object access or avoiding unnecessary work. And and Or evaluate both operands in ordinary Boolean expressions and also have bitwise uses. I would not replace one with the other solely for style when the second expression has side effects. A null guard followed by a member access typically needs short-circuit behavior to prevent evaluating the unsafe access.
22. How do the If operator and IIf function differ?
The If operator supports short-circuit selection, while IIf evaluates its argument expressions before choosing a result. Consequently, an IIf expression can fail while evaluating a branch that is not ultimately returned. The two-argument form of If also provides a null-coalescing-style choice for supported reference or nullable operands. I would use the appropriate If form for guarded access and state the expected type behavior. Similar-looking syntax does not mean evaluation order and conversions are identical.
VB.NET example: Option Strict On, Option Explicit On, and Option Infer On; modern .NET context as shown.
The expected output is 0. The short-circuit If operator does not evaluate text.Length when text is Nothing. Replacing it with IIf would evaluate that unsafe argument and can throw. This example is a complete console module.
23. How do equality and reference identity differ?
Equality asks whether values are considered equivalent under the selected operator or comparer; reference identity asks whether two references point to the same object. VB.NET uses Is for reference identity checks, including checking a reference against Nothing. The equals operator can have type-specific or overloaded behavior. Two different objects can compare equal while still being distinct instances. I would define the intended meaning before implementing Equals or using an object as a dictionary key.
24. What does Option Compare affect?
Option Compare influences certain Visual Basic string comparison behavior, with Binary and Text selecting different comparison conventions. It should not be treated as a global switch governing every .NET API or collection comparer. For identifiers and protocol tokens, I prefer an explicitly chosen ordinal comparison where appropriate. Human-language sorting may need culture-sensitive behavior instead. I would test case, accents, and locale assumptions and avoid letting a file-level setting silently determine a security-sensitive or cross-system identity rule.
25. Why are strings described as immutable?
A String object's content does not change after creation. Operations that appear to modify a string return a new string or assign a different reference. This supports predictable sharing but can create allocations when building large text through repeated concatenation. StringBuilder can help in suitable repeated construction scenarios, although it is not automatically faster for every short expression. I would measure meaningful workloads and remember that immutable string contents do not make every object holding strings immutable.
26. What is a property used for?
A property provides controlled access to an object's state through getter and setter semantics. It can enforce an invariant, expose a computed value, or provide a stable public contract while hiding storage. I would avoid surprising expensive work or hidden external side effects in a property that callers expect to be simple. ReadOnly restricts assignment through that property, but does not automatically make a returned mutable object immutable. The property's accessibility and behavior should match its intended ownership.
27. What is a constructor?
A constructor initializes a new instance and establishes the conditions under which it is valid to use. In VB.NET, an instance constructor is declared as Sub New. I would validate required arguments and initialize essential dependencies rather than expose a partially usable object that requires an undocumented second setup call. Constructors should avoid unnecessary external work that makes creation unpredictable. Shared initialization has different lifetime and failure considerations from constructing each individual instance.
28. How does inheritance work in VB.NET?
A class can inherit from one base class and reuse or specialize its behavior, while implementing multiple interfaces. The relationship should express substitutability rather than merely saving a few lines of code. Overrides require an appropriate overridable base member and preserve the intended contract. I would prefer composition when behavior changes independently or a subtype would need to reject ordinary base operations. Deep inheritance hierarchies can make state and initialization behavior harder to reason about and test.
29. What is an interface?
An interface expresses a contract that implementing types must satisfy according to the supported language and runtime features. It lets callers depend on a capability rather than one concrete implementation. For example, a service can depend on a repository interface that is replaced during tests. An interface alone does not ensure sensible behavior, transactionality, or performance; those expectations need documentation and tests. I would design small, cohesive contracts and avoid exposing implementation details that force every implementation to mimic one storage technology.
30. What does Shared mean?
Shared members belong to the type rather than a particular instance. They are useful for genuinely type-wide behavior or state, but shared mutable state introduces lifetime, testing, and concurrency concerns. A Shared method is not automatically pure, and a Shared collection is not automatically protected from concurrent access. I would use explicit ownership and synchronization where necessary, and avoid using Shared as a substitute for passing dependencies. Process-wide state also differs from state shared across several deployed processes.
31. What do Public, Private, Friend, and Protected mean?
These access modifiers control where members or types can be used. Public exposes broadly, Private restricts to its containing context, Friend generally exposes within the assembly, and Protected supports access through inheritance. Combined modifiers provide additional rules that should be checked when designing a library. I use the narrowest practical visibility to keep contracts manageable, but accessibility is not a substitute for runtime authorization. A private field can still hold sensitive data that leaks through logging or serialization.
32. How do exceptions work in VB.NET?
Exceptions represent exceptional failures and propagate until handled by a compatible Catch or an outer boundary. Try, Catch, and Finally structure recovery and cleanup. I catch exceptions where I can add useful context, recover, or translate the failure meaningfully, rather than swallowing every exception and continuing with invalid state. Expected invalid input often fits a TryParse-style result. A successful catch does not prove the operation left no partial side effects, so recovery must consider what happened before the exception.
33. What is Finally used for?
Finally contains cleanup that runs when control leaves the associated Try under normal exception-handling flow. It is useful for releasing resources or restoring temporary state whether the main operation succeeds or fails. It is not an absolute guarantee against process termination, power loss, or every catastrophic failure. I avoid throwing from cleanup when it would obscure the original error, and prefer Using for straightforward IDisposable ownership. Cleanup should not silently commit a failed business operation.
34. What does Using do?
Using establishes a scope that disposes an owned IDisposable resource when the block exits through ordinary control flow, including exceptions. This is appropriate for files, streams, and similar resources. Disposal is different from garbage collection: the object can remain allocated while its resource has already been released. I would not dispose an object merely because I can access it; ownership matters when callers share or supply it. Asynchronous disposal has separate language and API support considerations.
35. How does garbage collection differ from disposal?
Garbage collection reclaims managed memory for objects that are no longer reachable. Disposal explicitly releases resources or completes cleanup according to the object's contract. A reachable object can retain a file handle indefinitely, and setting a variable to Nothing does not synchronously dispose the object it previously referenced. I would use deterministic disposal for owned resources and investigate retained references for memory growth. Forcing garbage collection routinely is not a general remedy for poor resource ownership or event-subscription leaks.
36. What is a delegate?
A delegate is a type-safe reference to a compatible method or callable target. It allows behavior to be passed to another operation, such as a predicate or callback. Lambdas can create delegate instances concisely, but captured variables can extend object lifetimes and create shared-state surprises. I would document when and on which thread a callback is invoked. A delegate's type describes its signature; it does not establish that the callback is pure, fast, or safe to invoke concurrently.
37. What are events used for?
Events let an object notify interested subscribers while controlling how the notification is raised. VB.NET provides constructs such as Event, RaiseEvent, Handles, and AddHandler for this pattern. I would define subscriber lifetime and threading expectations, because a long-lived publisher can retain subscribers through event handlers. Events are useful for notifications, but they are not automatically durable messages or isolated asynchronous operations. A subscriber failure can affect the raising code depending on how the event is invoked.
38. What is LINQ in VB.NET?
LINQ provides query expressions and extension methods for selecting, filtering, grouping, and transforming data. The same surface syntax can operate over local enumerable sequences or provider-backed query sources with different execution rules. I would identify the provider and execution boundary before reasoning about performance or supported expressions. A query definition often does not execute immediately, so errors and side effects may appear during enumeration. LINQ improves expression of intent but does not remove the need to understand the underlying data access.
39. What does Async and Await provide?
Async and Await let task-based asynchronous operations be composed without blocking a thread while waiting for incomplete work. They do not automatically create a new thread or make CPU-heavy code parallel. An asynchronous method executes synchronously until it reaches an await that actually suspends. I would return Task or Task(Of T) for operations callers need to observe, propagate cancellation, and handle failures at the appropriate boundary. The selected UI or application context affects continuation behavior.
40. How would you approach a small new VB.NET application?
I would identify the supported target framework, platform, input contracts, and deployment environment before choosing libraries or UI technology. Enable useful compile-time checking, separate business logic from external dependencies, and define error and resource ownership policies. Start with a representative end-to-end path and tests for invalid input rather than building a large abstraction hierarchy first. For an existing team, compatibility and maintainability matter more than using every language feature or copying conventions from VBA or another .NET language without review.
Visual Basic Interview Questions and Answers for Intermediate
Explore conversion boundaries, query execution, asynchronous operations, synchronization, testing, and interoperability. Strong answers include concrete assumptions and failure cases.
41. How would you parse a decimal amount safely?
I would define the accepted numeric format and culture, then use Decimal.TryParse with explicit styles when input can be invalid. A failed parse should produce a clear validation result rather than silently becoming zero. Decimal does not establish currency, rounding policy, or business validity, so those checks remain separate. For example, a correctly parsed negative amount may still be prohibited for a particular operation. Tests should cover separators, whitespace, overflow, and the application's permitted precision.
VB.NET example: Option Strict On, Option Explicit On, and Option Infer On; modern .NET context as shown.
The style deliberately accepts a decimal point without accepting grouping separators, signs, or arbitrary whitespace. Broaden it only if the format contract requires that behavior. Invalid input must remain distinguishable from a valid zero amount; business range and currency validation are separate.
42. How would you avoid confusing Nothing with an empty string?
I would distinguish a missing reference from a string containing zero characters and use Is Nothing when reference absence matters. VB string equality has special behavior involving Nothing and an empty string, so an equals comparison is not a reliable substitute for a null-reference check. String.IsNullOrEmpty deliberately combines the two cases when that is the required policy. Whitespace is a third concern. I would preserve distinctions needed by persistence or validation instead of normalizing everything without a business reason.
43. How does integer division differ from ordinary division?
VB.NET uses the backslash operator for integer division and the slash operator for ordinary division. Operand conversion and result types matter, so I would not assume that dividing two integer variables with slash reproduces C# integer-division behavior. Mod supplies a remainder operation with its own signed behavior. Choose the operation that matches the requirement and test negative values and zero divisors. An explicit mathematical example is more useful than relying on conventions remembered from another language.
44. What should you know about CInt and rounding?
CInt is a conversion with defined rounding behavior, not simply a request to discard the fractional part. Midpoint conversions use the documented rounding rule, which can differ from an application's desired monetary or display convention. I would specify the rounding policy explicitly when it is a business requirement and verify that the rounded result fits the destination range. Converting a number to an integer also differs from formatting it for display; a formatted string should not become the authoritative numeric value.
45. How do overloaded methods differ from overridden methods?
Overloading provides multiple members with the same name but different applicable signatures. Overriding replaces an inherited overridable implementation for polymorphic dispatch. I would use overloads for meaningful alternate ways to call one operation and overrides to preserve a base contract with specialized behavior. Implicit conversions, optional parameters, and type inference can influence overload resolution, so ambiguous APIs deserve redesign. Merely choosing a familiar name does not mean the compiler or runtime selects the implementation a caller expects.
46. How do Shadows and Overrides differ?
Overrides participates in polymorphic replacement of an inherited overridable member. Shadows hides a name in a derived context and can produce different behavior depending on the compile-time type used to access the object. I would not use Shadows as a workaround for an unsuitable inheritance design without documenting the consequences. A test should call through both base and derived references. When clients require substitutable behavior, proper overriding or composition is usually clearer than hiding an inherited member.
47. When would you choose a Structure instead of a Class?
I would consider a structure for a small value-like concept whose copying and equality semantics are appropriate, such as a coordinate. A class is more suitable when identity, shared mutation, or inheritance is central. Large mutable structures can create surprising copies and costs, especially when accessed through properties or collections. A structure containing reference fields is not automatically deeply immutable. I would define its invariants and test assignment behavior rather than selecting it solely because someone described value types as faster.
48. How would you implement value equality correctly?
I would identify the fields that define logical equality and implement a consistent Equals and GetHashCode contract, often with IEquatable(Of T). Equal values must produce equal hash codes, but matching hashes do not prove equality. Avoid mutating equality-defining fields while an object is used as a dictionary key or set member. String fields need an intentional comparer. I would test reflexivity, symmetry, transitivity, null handling, and collection behavior instead of verifying only one successful equals comparison.
49. What are extension methods?
Extension methods let a shared method be called using instance-style syntax for a compatible type. In VB.NET they are declared in a module with the appropriate Extension attribute. They do not actually add stored members to the extended type or override its instance methods. I use them for cohesive operations that improve readability without obscuring dependencies. The apparent receiver can be Nothing, depending on the call and implementation, so an extension method should document and handle its input contract.
50. How do anonymous types help LINQ projections?
Anonymous types provide compiler-generated types for local shaped results, such as selecting a name and total from a query. Type inference makes them convenient without defining a public class for every intermediate projection. VB's Key properties influence equality and read-only behavior, which should not be generalized from another language's anonymous types. I would use named types for stable public contracts or serialization boundaries where explicit versioning and discoverability matter. A local projection should not accidentally become an opaque application-wide interface.
51. What is deferred execution in LINQ to Objects?
Many LINQ operators return a query that runs when enumerated rather than immediately at declaration. If the source changes before enumeration, the query can observe the changed data. Exceptions and side effects can also occur later than the line that defines it. I would materialize deliberately when a stable result is needed, while recognizing that a list of object references is not a deep snapshot. Deferred execution is operator-specific; immediate terminal operations and buffering operators have different behavior.
VB.NET example: Option Strict On, Option Explicit On, and Option Infer On; modern .NET context as shown.
The expected lines are 2,3 and 2. The query is enumerated after the addition, while ToList already stored the earlier results. Integer values make this a straightforward snapshot example; a list of mutable object references would not deeply freeze those objects.
52. When should you materialize a LINQ query?
I would materialize when the result must be reused predictably, when the source lifetime is about to end, or when a deliberate execution boundary simplifies ownership. ToList and ToArray enumerate and store results, which costs time and memory and can trigger source exceptions. They do not automatically make referenced objects immutable. I would avoid materializing an unbounded or very large sequence without limits. Repeated enumeration may also be acceptable when the source is cheap and the intended behavior is to observe current data.
53. How do IEnumerable(Of T) and IQueryable(Of T) differ?
IEnumerable describes enumeration, commonly used for in-process sequences. IQueryable adds an expression-tree-based query abstraction that a provider can interpret, for example by translating operations to a database query. Supported expressions, null semantics, collation, and execution costs depend on that provider. I would inspect the boundary where query composition becomes local work, because an innocent conversion can cause excessive data transfer. Similar LINQ syntax does not imply identical behavior or that arbitrary VB methods can be translated remotely.
54. How do Where and Select differ?
Where filters elements using a predicate, while Select projects each element into a result shape. In LINQ to Objects both commonly use deferred execution, but their meaning is different: selecting a Boolean does not filter out false values. I would keep projections narrow when they clarify a contract and avoid hidden side effects in either delegate. For provider-backed queries, the available translation and execution plan must be checked rather than inferred solely from the local LINQ implementation.
55. How do First, Single, and their default-returning variants differ?
First chooses the first element and requires at least one; Single requires exactly one. Their default-returning variants permit an empty sequence but do not erase every cardinality error: SingleOrDefault still rejects multiple matches. A default value can also be a legitimate element, so absence may need a separate representation. I choose the operator to express the invariant and define ordering when first has business meaning. Using First merely to hide duplicate records can conceal a data-quality problem.
56. How would you handle duplicate keys when building a dictionary?
I would decide whether duplicates are invalid, should be grouped, or should be resolved by a defined winner before calling ToDictionary. The standard operation rejects duplicate keys under its comparer rather than choosing an arbitrary value. A case-insensitive comparer can reveal duplicates that appear distinct as raw text. I would test the actual identity rules and avoid silently taking the last encountered item without a stable ordering and business justification. Duplicate handling belongs in the contract, not just an exception handler.
VB.NET example: Option Strict On, Option Explicit On, and Option Infer On; modern .NET context as shown.
The expected output is 2. This explicitly groups case-insensitive identifiers and avoids relying on Option Compare. It is a single-threaded example: the lookup followed by assignment is not an atomic compound operation for concurrent callers.
57. What are iterator functions useful for?
Iterator functions use Yield to produce sequence elements incrementally while preserving execution state between requests. They can express a traversal without building the entire result up front. The caller controls enumeration, so resource lifetime and exceptions extend across that boundary. I would ensure cleanup works when enumeration stops early and avoid returning a sequence whose required external resource has already been disposed. Iteration is not automatically asynchronous, parallel, or safe to enumerate simultaneously from several consumers.
58. How do closures affect lambdas?
A lambda can capture variables from its enclosing scope, and the resulting closure keeps the required state alive. It captures variables rather than promising an immutable copy of every value at creation. Later mutation or shared access can therefore change behavior and introduce races. I would make captured state explicit when callbacks outlive the method that created them. Tests should include delayed invocation and multiple callbacks rather than only immediate invocation in the same loop or request.
59. When should you remove an event handler?
I would unsubscribe when the subscriber's intended lifetime ends and the publisher may outlive it. An event subscription can keep the subscriber reachable, causing retained memory or unexpected callbacks even though the UI element or operation seems finished. With AddHandler and lambdas, retain the delegate instance when it must later be removed reliably. Subscription ownership should be explicit and cleanup idempotent. I would not assume garbage collection discovers that the application no longer wants a still-referenced subscriber.
60. How would you rethrow an exception without losing its original context?
Inside a Catch, a bare Throw rethrows the current exception while preserving its stack context. Throwing the caught variable again can reset relevant stack information at the new throw point. If translating to a more meaningful exception, preserve the original as the inner exception and add useful, non-sensitive context. I would avoid wrapping every exception unnecessarily, because callers need stable categories and actionable diagnostics. Logging the same failure at every layer can also obscure the actual origin.
VB.NET example: Option Strict On, Option Explicit On, and Option Infer On; modern .NET context as shown.
This class intentionally demonstrates a failure and is not a standalone executable. The bare Throw preserves the caught exception’s context. In a real application, log useful safe context at the responsible boundary and avoid duplicate logging at every layer.
61. How would you design an exception-handling boundary?
I would catch specific failures where the application can recover or translate them, and place a top-level boundary around a request, job, or UI operation for consistent reporting. Cleanup and cancellation should remain distinguishable from unexpected defects. A broad catch that returns a normal-looking default can corrupt downstream decisions. I would include correlation information without leaking secrets and test partial failures. The boundary should define whether an operation is retryable, already committed, or requires reconciliation.
62. How do Task and Task(Of T) differ?
Task represents asynchronous completion without a result value, while Task(Of T) also supplies a result of type T. Both can complete successfully, fault, or be canceled. They are not necessarily dedicated threads, and a completed task may be returned without scheduling new work. I would await the task to observe completion and failures rather than discard it. An API returning Task should document cancellation and side effects just as carefully as a synchronous API.
63. Why should Async Sub usually be limited to event handlers?
Async Sub cannot be awaited by an ordinary caller through a returned Task, making completion and failure composition difficult. Its exceptions follow synchronization-context handling rather than being stored in a task returned to that caller. Event signatures sometimes require a Sub, so an async event handler can be appropriate, with explicit boundary handling. Reusable asynchronous work should usually return Task or Task(Of T). A fire-and-forget requirement needs deliberate ownership, monitoring, and shutdown behavior, not simply Async Sub syntax.
64. How does cooperative cancellation work?
A CancellationToken communicates a request to stop; the operation must observe it or pass it to APIs that do. Cancellation is not forced thread termination and does not roll back side effects already committed. I would check at meaningful boundaries, preserve cleanup, and distinguish requested cancellation from an unrelated failure. The caller owns the cancellation source and should dispose it appropriately. Tests should cover cancellation before starting, during a wait, and after an irreversible action has already completed.
VB.NET example: Option Strict On, Option Explicit On, and Option Infer On; modern .NET context as shown.
This library method illustrates cooperative cancellation using an asynchronous delay and returns a Task that the caller must observe. The delay is illustrative, not a timing guarantee. No external I/O or background business write occurs, and the example was not executed.
65. How does Task.WhenAll differ from awaiting operations one at a time?
WhenAll represents the completion of a set of tasks and can be used after independent operations have been started. Awaiting each operation before starting the next serializes that sequence. WhenAll does not itself guarantee a bounded number of concurrent operations or make shared state safe. I would define failure and cancellation handling, retain the aggregate task when all failures need inspection, and avoid launching an unbounded set against a limited service. Independence of the business operations must be established first.
66. Why can blocking on Result or Wait cause problems?
Blocking occupies a thread and can deadlock when an awaited continuation needs a context that the blocked thread is preventing from running. It can also reduce throughput even where a particular deadlock does not occur. I would generally propagate asynchronous calls with Await instead of converting them back to synchronous waits. The exact risk depends on the application context, so I would diagnose the actual call chain rather than assert that every use always deadlocks. Exception presentation also differs across blocking APIs.
67. When is Task.Run appropriate?
Task.Run schedules work on the thread pool and can help keep a UI responsive during suitable CPU-bound work. It is not normally needed to wrap an API that already performs asynchronous I/O, and it does not make the underlying operation cancelable or thread-safe by itself. I would consider thread-pool pressure and the application's hosting model before using it broadly. Passing a cancellation token to scheduling does not automatically interrupt a delegate that has already begun and ignores cancellation.
68. What does ConfigureAwait(False) change?
For the relevant task awaiter, it avoids requesting continuation on the captured synchronization context or scheduler in the usual way. It does not guarantee execution on a particular thread or force an asynchronous hop when the awaited operation is already complete. Library code may use it when it does not need the caller's context, while UI code must still marshal UI access appropriately. I would reason about the complete call path rather than treat it as a universal deadlock cure.
69. How would you update a Windows Forms control from background work?
I would marshal the update through the supported UI-thread mechanism for the target Windows Forms version, or structure an async UI handler so its continuation resumes appropriately. Controls generally have thread-affinity requirements, and disabling cross-thread diagnostics does not make access safe. Avoid holding locks while synchronously invoking the UI, which can create deadlocks. I would also handle form disposal and cancellation so work finishing after the window closes does not attempt to update an invalid control.
70. What does SyncLock protect?
SyncLock provides mutual exclusion for code using the same stable lock object within the process. It is appropriate for short critical sections protecting a shared invariant. Use a private dedicated object rather than a publicly accessible object or a changing reference. It does not coordinate different processes or automatically protect code that ignores the lock. Await cannot appear inside a SyncLock block, so asynchronous coordination needs an appropriate alternative and a carefully defined ownership scope.
VB.NET example: Option Strict On, Option Explicit On, and Option Infer On; modern .NET context as shown.
All accesses to this state must follow the same locking policy. The example protects a small synchronous operation using a private stable object; it does not coordinate multiple processes. Integer range limits still apply, and no Await belongs inside the SyncLock block.
71. When would you use Interlocked or a concurrent collection?
Interlocked provides atomic operations for supported individual values, while concurrent collections provide particular thread-safe operations on their data structures. They can reduce the need for a coarse lock, but several individually safe operations do not automatically form one atomic business transaction. For example, checking a count and then adding may still race. I would select an API that expresses the required compound action or protect the wider invariant explicitly, and test contention rather than assuming a concurrent type solves every race.
72. How do optional parameters and overloads affect API design?
Optional parameters simplify common calls, while overloads can expose distinct supported call shapes. Too many combinations can make resolution and intended behavior unclear, especially with implicit conversions. Default argument values also have versioning implications for compiled callers, so changing a library's default is not equivalent to updating every caller's behavior. I would keep public contracts explicit and test both source compatibility and existing consumers. A convenient signature should not hide a required security or transaction decision.
73. How do Imports and assembly references differ?
Imports makes names available without repeated namespace qualification; it does not add a missing assembly or package dependency. The project still needs an appropriate reference containing the types and targeting a compatible framework. I would diagnose an unresolved name by checking both namespace visibility and dependency availability. The VB root namespace can also affect the emitted full names, which matters when integrating with other languages or reflection. A name that compiles locally is not proof the deployment contains its required dependency.
74. What should you consider when reading and writing files?
I would define encoding, newline behavior, path ownership, size limits, and error handling, then dispose owned streams deterministically. External paths need validation appropriate to the application rather than naive string concatenation. A successful write does not always mean a multi-file business operation is atomic or durable against every failure. I would test missing directories, permissions, partial input, and concurrent access. For asynchronous APIs, propagate cancellation while accounting for any bytes already written before cancellation is observed.
75. How would you access a database safely from VB.NET?
I would use a supported data provider, parameterized commands, and explicit connection and transaction ownership. Parameterization separates values from command text but does not allow arbitrary user-supplied identifiers to become safe automatically. Dispose resources, use appropriate asynchronous APIs where available, and avoid keeping transactions open during unrelated work. Test null handling, timeouts, and rollback behavior. A timeout after a write can leave its outcome uncertain, so retries must account for whether the database committed the operation.
76. How would you test code that depends on time or external services?
I would separate the business decision from the dependency and supply a controlled clock or service abstraction in tests. This allows boundary cases to be exercised without waiting or making live requests. The abstraction should represent the behavior the application needs, not reproduce every method of a large framework. Unit tests complement integration tests rather than prove a real service's configuration. I would include failure, cancellation, and duplicate-response scenarios when those affect the correctness of the decision.
77. How would you use XML literals responsibly?
VB.NET XML literals can make constructing or querying XML with LINQ to XML readable. Embedded expressions should supply values through the structured API rather than manually concatenate markup. I would still define namespace handling and validate the expected document shape. Parsing untrusted XML introduces separate concerns such as resource limits and resolver settings, which are not solved by convenient literal syntax. XML support also does not imply that every serializer or provider accepts every constructed value unchanged.
78. What should you check before using COM interoperability?
I would identify the COM component, supported Windows environment, process architecture, registration requirements, threading model, and ownership expectations. A .NET reference to a COM object does not remove those deployment constraints. Office automation, for example, has host and support limitations that differ from a normal managed library. I would avoid copying manual release patterns without understanding reference ownership, since prematurely releasing a shared wrapper can break other code. Test the actual deployment and failure paths with approved tooling.
79. How would you choose a string comparer for identifiers?
I would decide whether identifiers are case-sensitive and whether linguistic rules are appropriate. Machine identifiers often need explicit ordinal or ordinal-ignore-case comparison rather than current-culture behavior, while user-facing sorting may require culture-aware rules. Use the same equality policy for lookups, duplicate detection, and persistence reconciliation. A file-level Option Compare setting does not configure every collection. I would test characters and case combinations relevant to the actual contract instead of assuming that lowercasing all text is universally safe.
80. How would you review a VB.NET method before merging it?
I would check the contract, type conversions, null and missing-value behavior, resource ownership, and failure boundaries before focusing on style. For LINQ or asynchronous code, inspect when work executes, whether tasks are observed, and whether shared state is safe. Tests should demonstrate meaningful outcomes and edge cases rather than mirror every implementation line. I would also verify the target framework and deployment assumptions, especially if the change was translated from C#, VBA, or a legacy VB6 sample.
Visual Basic Interview Questions and Answers for Experienced
Use these scenarios to assess modernization, concurrency, security, deployment, and operational judgment. Look for evidence, ownership, and realistic recovery plans.
81. How would you migrate a VB6 application to modern VB.NET?
I would inventory business behavior, forms, COM dependencies, file formats, database access, deployment assumptions, and supported environments before choosing a migration strategy. Syntax similarity is not behavioral compatibility: type widths, default properties, lifetime, error handling, and framework APIs differ. Build characterization tests around important workflows and migrate bounded components with reconciliation. Some UI or dependency choices require redesign rather than mechanical translation. I would preserve a recovery path and judge success by verified user outcomes, not merely by whether the converted project compiles.
82. How would you move a VB.NET application from .NET Framework to modern .NET?
I would assess target-platform support, libraries, configuration, serialization, remoting or other legacy APIs, and deployment requirements. A project compiling against a new target does not prove every dependency or runtime behavior is supported. Upgrade a representative slice, run compatibility and integration tests, and measure operational behavior. Windows-specific desktop technologies remain platform-specific even when the language itself can target other environments. I would document unsupported features and decide explicitly whether to replace, isolate, or retain them in a separate component.
83. How would you decide whether to retain or rewrite a large VB.NET codebase?
I would compare business risk, defect patterns, supported dependencies, team capability, test coverage, and the cost of preserving behavior. A rewrite can remove some technical constraints while recreating years of hidden business rules and introducing new defects. Incremental modernization may deliver value sooner when boundaries can be isolated. I would use a representative experiment and measurable goals rather than language preference alone. The decision should include maintenance and operational ownership, not just how attractive the replacement looks in a prototype.
84. How would you introduce Option Strict into a legacy project?
I would identify the implicit conversions and late-bound paths, then enable stricter checking in manageable areas while adding behavior-preserving tests. Each compiler finding needs interpretation: replacing it with an arbitrary cast can preserve the compile but change runtime meaning. Establish explicit parsing and conversion policies at boundaries and isolate genuinely required dynamic interoperability. Track remaining exceptions with owners. The goal is clearer contracts and fewer surprises, not merely silencing warnings or changing every Object declaration without understanding its purpose.
85. How would you investigate a production-only conversion failure?
I would capture the non-sensitive input shape, declared types, culture, framework version, and execution path involved. Production data may contain a separator, missing value, range, or subtype absent from local fixtures. Reproduce the smallest failing case and inspect implicit conversions or late binding. I would not solve the incident by globally disabling Option Strict or swallowing the exception. Correct the input contract or conversion and add a regression test that represents the actual boundary without storing sensitive production data unnecessarily.
86. How would you design a reusable VB.NET library for other .NET languages?
I would expose explicit, well-named types and predictable contracts that ordinary consumers in the supported languages can use. Avoid leaking anonymous types, surprising optional-parameter behavior, or VB-specific conveniences that obscure the emitted API. Consider CLS compatibility where required, null and exception contracts, cancellation, and resource ownership. Test from at least one representative consumer language and verify binary compatibility expectations. Shared runtime access does not mean every language feature or overload set has equally clear semantics for every caller.
87. How would you evolve a public API without breaking callers?
I would distinguish source, binary, and behavioral compatibility and test the actual supported consumers. Removing a member, changing a signature, or altering a default parameter can affect callers differently. Add a deliberate migration path and deprecate old behavior with documentation rather than silently changing semantics. Exceptions, ordering, and timing can also be part of the effective contract. Versioning should account for deployment realities: not every client recompiles or upgrades at the same moment as the library.
88. How would you diagnose memory growth in a long-running application?
I would measure retained memory and allocation patterns over representative workload cycles, then inspect which objects remain reachable and why. Common causes include caches without bounds, event subscriptions, queued tasks, and unintended references to large graphs. A rising working set alone is not proof of a managed leak because runtime and native memory behavior also matter. I would use appropriate profiling evidence and verify improvement after a targeted fix. Repeatedly forcing garbage collection can obscure symptoms without correcting ownership.
89. How would you distinguish a managed-memory leak from a resource leak?
I would examine both object retention and external resource counts such as handles, connections, or native allocations. A small managed wrapper can retain an expensive external resource, while a large reachable cache may consume memory without any missing Dispose call. The diagnostic tools and remedies differ. Define ownership, instrument disposal and lifetime where appropriate, and reproduce sustained load. Garbage collection activity does not prove resources are released promptly, and calling Dispose does not necessarily remove every managed reference to the object.
90. How would you implement IDisposable in a class that owns resources?
I would identify exactly which resources the class owns and release them according to their contracts, making repeated disposal safe where appropriate. Managed disposable fields usually need deterministic disposal; unmanaged resource ownership may justify a SafeHandle-based design and the documented disposal pattern. I would not add a finalizer to every class by habit, because it increases complexity and has restrictions. Define behavior after disposal and test partial construction or cleanup failures. Borrowed dependencies should not be disposed without an ownership agreement.
91. How would you handle asynchronous disposal from VB.NET?
VB.NET does not allow Await inside Catch or Finally, so I would not translate a C# asynchronous-disposal pattern literally. For IAsyncDisposable, use a supported helper or explicitly capture the operation outcome, await DisposeAsync outside those blocks, and preserve or rethrow the original failure with an explicit policy for cleanup failures. ExceptionDispatchInfo can preserve captured exception context where appropriate. Ownership and cancellation still require design. Ordinary Using is suitable for owned IDisposable resources, but does not itself perform asynchronous disposal.
92. How would you investigate an asynchronous deadlock?
I would capture the blocked threads or tasks, synchronization context, locks, and continuation dependencies. Look for synchronous waits on async work, lock-order cycles, or a UI thread waiting for work that needs that same UI thread. Reproduce a minimal case and remove the dependency cycle rather than adding arbitrary delays. ConfigureAwait choices can matter but are not a universal cure. I would verify shutdown and cancellation paths too, because deadlocks often occur only during failure or application closure.
93. How would you bound concurrent asynchronous work?
I would choose an explicit concurrency limit based on the downstream resource and use a supported coordination mechanism, such as SemaphoreSlim, with guaranteed release after acquisition. Starting every task and awaiting WhenAll does not impose that bound. Cancellation must be handled correctly when waiting for admission, and release must not occur if acquisition failed. I would test failures and cancellation under contention. The limit should protect both throughput and memory, and may need adjustment based on measured service behavior.
VB.NET example: Option Strict On, Option Explicit On, and Option Infer On; modern .NET context as shown.
The caller supplies a shared semaphore with a chosen positive concurrency limit and keeps it alive until all operations finish. Acquisition occurs before Try, so a canceled acquisition does not release a permit it never obtained. Work failures still release the acquired permit. This coordinates only callers using that same semaphore; inputs are assumed non-null, and no concurrency runtime test was performed.
94. How would you make a background task observable and stoppable?
I would assign an owner that retains its Task, supplies cancellation, observes failures, and participates in application shutdown. Define whether unfinished work can be abandoned or needs persistence and recovery. A discarded task or Async Sub hides important lifecycle information from ordinary callers. I would include bounded shutdown and failure reporting without silently swallowing exceptions. For business-critical work, an in-memory background task may be insufficient; durability requirements can require a queue or job system beyond the process.
95. How would you design retries around a remote write?
I would classify failures and determine whether the previous operation may already have committed before retrying. A timeout is an observation failure, not proof that no write occurred. Use a supported idempotency or correlation mechanism and reconcile uncertain results. Apply bounded backoff only to appropriate transient failures, honoring service guidance. Cancellation and authentication failures should not become endless retry loops. I would test duplicate delivery and failure after commit, because a happy-path retry test misses the most consequential risk.
96. How would you prevent race conditions in a shared cache?
I would define atomic operations, expiration, update ownership, and the behavior when several callers request the same missing key. A concurrent dictionary protects its documented operations but does not automatically ensure that a value factory runs once or that external side effects are unique. Avoid performing uncoordinated expensive or irreversible work inside assumptions about cache insertion. Test concurrent misses, failures, and eviction. The cache should be a performance aid with clear correctness rules, not an undocumented source of business truth.
97. How would you choose between locks and immutable state?
I would consider the invariant, update frequency, contention, and cost of copying. A private lock can make a small mutable state transition straightforward, while immutable snapshots can simplify readers and ownership. Immutability must be genuine across relevant nested objects, and publishing a new snapshot still needs an appropriate synchronization strategy. Neither approach is universally faster. I would measure realistic workloads and prefer a design whose correctness can be explained, especially when asynchronous operations or callbacks complicate lock ownership.
98. How would you review a LINQ query for unexpected repeated work?
I would locate every enumeration and determine whether the source is a cheap collection, a stateful iterator, or an external provider. Calling Count and then iterating may repeat work or observe different data. Materialization can establish one evaluation but changes memory and timing, so it should be deliberate. Check side effects, exceptions, and source lifetime as well as performance. I would test with an instrumented sequence or provider diagnostics rather than assuming query syntax is evaluated only once.
99. How would you avoid returning a sequence tied to a disposed resource?
I would make the resource lifetime and enumeration contract explicit. Returning a deferred query from inside a Using block can leave the caller enumerating after the resource has been disposed. Depending on the requirements, materialize within the scope or return a carefully designed enumerable whose enumerator owns and disposes the resource. The latter needs early-exit and exception tests. I would not hide the issue by catching ObjectDisposedException and returning an empty result, because that masks incomplete data as success.
100. How would you reason about performance before replacing LINQ with loops?
I would measure the relevant workload and identify whether time is spent in allocation, enumeration, database access, sorting, or another operation. A loop can reduce overhead in a hot path, but it can also make a correct algorithm harder to maintain without addressing the true bottleneck. Compare equivalent semantics and representative sizes, including empty and failure cases. I would avoid universal claims about operator complexity across providers. Optimization should preserve order, equality, and execution behavior that callers rely on.
101. How would you design deterministic tests for concurrent code?
I would use controlled coordination points to expose important interleavings instead of relying only on arbitrary sleeps. Define the invariant and test cancellation, failure, and simultaneous access around it. Stress tests can reveal problems but do not prove all interleavings correct, so combine them with design review and focused assertions. Keep test hooks narrow and avoid making production timing depend on them. A test that passes repeatedly on one machine is useful evidence, not a guarantee that a race cannot occur.
102. How would you design cancellation across several layers?
I would pass the caller's token through operations that support cancellation and define which layers may introduce their own timeouts. Linked tokens can combine policies, but their sources need proper ownership and disposal. Cancellation should remain distinguishable from a service failure and should not imply rollback of completed writes. Check before starting expensive work and at meaningful boundaries. I would test that intermediate layers do not discard the token or convert an expected cancellation into a misleading successful default result.
103. How would you handle multiple failures from parallel tasks?
I would retain the task representing the whole group and inspect its failure information when every exception matters. Awaiting a faulted WhenAll surfaces an exception, but the group task can retain multiple failures for diagnosis. Define whether partial success is acceptable and whether remaining operations should receive cancellation. Do not assume that the first observed exception describes all side effects. I would report useful correlated outcomes and avoid launching corrective retries before reconciling which individual operations actually completed.
104. How would you secure serialization boundaries?
I would choose a supported serializer and explicit data contract, validate size and shape, and avoid unsafe deserialization patterns that can instantiate arbitrary types or execute unexpected behavior. Type safety inside the application does not make untrusted serialized input safe. Version fields and missing-value handling should be deliberate. I would test malformed and oversized input, and avoid exposing internal object graphs or secrets by default. Legacy serialization mechanisms need current security guidance rather than assumptions based on old sample code.
105. How would you handle secrets in a desktop or service application?
I would minimize stored secrets and use an approved platform-specific secret mechanism or service identity where available. Configuration files, source code, logs, and exception messages should not contain reusable credentials. A desktop application distributed to users cannot reliably hide a shared embedded secret from those users. I would define rotation and access ownership and test failure without revealing the value. Encryption is useful only with a sound key-management model; encoding or obfuscation is not equivalent to protecting a secret.
106. How would you design safe diagnostic logging?
I would record the operation, correlation identifier, outcome, and useful non-sensitive context while controlling volume and retention. Avoid logging passwords, access tokens, or full personal records merely because they are available in an exception or request. Structured fields improve investigation, but untrusted values still need appropriate handling by the logging system. I would test failure paths and redaction. Logging should support diagnosis without becoming a second uncontrolled copy of sensitive data or a source of performance collapse during an incident.
107. How would you diagnose a culture-dependent production bug?
I would compare the cultures used for parsing, formatting, sorting, and equality at each boundary. A value written using one locale and read using another can change meaning or fail, while a culture-sensitive identifier comparison can produce unexpected matches. Use explicit invariant formats for machine interchange where appropriate and culture-aware behavior for user-facing presentation. I would test the relevant cultures and preserve raw evidence safely. Changing the process culture globally may fix one path while breaking another.
108. How would you handle time and time zones in an application?
I would distinguish an instant, a local wall-clock time, and a date-only business value. Choose representations and timezone conversions that preserve that meaning, and avoid assuming every day is exactly twenty-four local hours. Daylight-saving ambiguity and invalid local times need an explicit policy. Use a controllable clock in tests and verify boundary cases. A formatted DateTime string without offset or timezone context may be insufficient for interchange, even if it looks clear to a local user.
109. How would you design a robust file-processing job?
I would define input completeness, encoding, record identity, validation, output atomicity, and restart behavior before optimizing throughput. A job that crashes after writing half the output must not blindly duplicate completed work on restart. Use appropriate temporary-output or checkpoint mechanisms and reconcile counts with identifiers and important values. Bound memory and handle malformed records according to a stated policy. I would test failures at commit boundaries, not only a small valid file that fits entirely in memory.
110. How would you make a database operation idempotent?
I would identify a stable business or request key and enforce the intended uniqueness or state transition within the database's transaction model. A client-side check followed by an insert can race, so the database constraint and conflict handling matter. Retries must return or reconcile the existing result rather than create a duplicate. I would test concurrent requests and uncertain responses after commit. Idempotency applies to the complete operation, including external effects, not just the method returning the same value twice.
111. How would you diagnose a deployment that works on the developer machine only?
I would compare runtime and architecture, dependency versions, native components, configuration, permissions, culture, and environment assumptions. The developer machine may contain SDKs or registered COM components absent from the target. Capture the actual failure and verify the published artifact in a representative clean environment. Avoid fixing deployment by copying random binaries until it launches. The solution should be reproducible and documented, with clear runtime requirements and a rollback path for production releases.
112. How do framework-dependent and self-contained deployment differ?
A framework-dependent application relies on a compatible installed runtime, while a self-contained deployment includes the runtime components for its selected target. Self-contained does not make every dependency portable or eliminate native operating-system requirements. Updates and security maintenance also differ because bundled runtimes need an application deployment strategy. I would choose based on operational ownership and supported environments, then test the actual publish output. Single-file packaging and trimming are separate options with their own compatibility constraints.
113. What should you assess before enabling trimming or ahead-of-time compilation?
I would verify current target-framework, language, application-type, and library support, then examine reflection, dynamic loading, serialization, and native dependencies. These features can depend on members not obvious to static analysis. Warnings require investigation rather than blanket suppression, and compatibility is not guaranteed merely because ordinary compilation succeeds. Test the actual published configuration with representative workflows. I would avoid promising that every VB.NET project supports every deployment optimization or achieves a specific performance improvement without evidence.
114. How would you isolate a legacy COM dependency during modernization?
I would define a narrow boundary around the required operations and data, then keep platform and threading assumptions inside that boundary. Depending on support and risk, isolation may be within a process or through a separate Windows-hosted component. Preserve error and lifetime semantics and test the actual COM registration and architecture. An adapter does not remove the dependency's limitations, but it can prevent them from spreading. The migration plan should include operational ownership and a realistic replacement or retention decision.
115. How would you review generated or translated VB.NET code?
I would treat it as untrusted implementation output that needs compilation, tests, and semantic review. Translation can mishandle Nothing, integer division, default properties, ByRef arguments, event lifetimes, or asynchronous behavior even when the result looks familiar. Start from required behavior and compare representative inputs and side effects. I would avoid approving code solely because a converter reports success. Generated code also needs a sustainable update process so manual fixes are not silently overwritten by the next generation run.
116. How would you prioritize technical debt in a mature VB.NET system?
I would rank work by business risk, frequency of change, operational incidents, unsupported dependencies, and the ability to reduce uncertainty. A stable unattractive module may be less urgent than a small untested component handling critical writes or credentials. Establish tests and observability before broad refactoring, then improve bounded areas with measurable outcomes. I would avoid treating language age as a sufficient reason for replacement. The goal is safer change and reliable operation rather than a cosmetic reduction in old-looking code.
117. How would you investigate a performance regression after a framework upgrade?
I would compare equivalent builds, inputs, configuration, and deployment modes, then profile the changed workload. Runtime, library, JIT, globalization, and dependency changes can all influence behavior. Separate startup, allocation, CPU, I/O, and contention before selecting a remedy. I would also verify correctness because an apparent slowdown may expose work that was previously skipped incorrectly. Use a reproducible benchmark and operational evidence, and retain a rollback option rather than applying unrelated micro-optimizations to every method.
118. How would you design a practical Visual Basic interview exercise?
I would provide a small VB.NET routine with a realistic contract and a few deliberate issues, such as a ByVal object mutation, deferred query, or unobserved asynchronous operation. Ask the candidate to explain behavior, propose a correction, and identify meaningful tests before running it. State the framework and compiler options so the exercise is not a guessing game. Strong candidates distinguish language semantics from runtime and business rules, and explain uncertainty rather than translating a memorized C# answer mechanically.
119. What evidence would you collect before accepting a modernization release?
I would compare critical workflows, data transformations, integration behavior, error handling, security, resource usage, and deployment against agreed acceptance criteria. Run representative user and failure scenarios in the target environment, not only unit tests on a developer machine. Document intentional changes and unresolved limitations, with responsible owners and recovery procedures. Compilation and passing happy-path tests are necessary but insufficient evidence. The release should demonstrate that the business can continue operating reliably through normal work, failures, and support handovers.
120. What does maintainable production VB.NET code look like?
It has explicit contracts, understandable type and conversion choices, deliberate resource ownership, observable asynchronous work, and tests around meaningful behavior. Dependencies and platform assumptions are documented rather than hidden in global state or developer-machine setup. I would favor simple cohesive modules and classes over clever syntax that obscures execution or failure. Maintainability is demonstrated when another engineer can safely diagnose and change the system, including its cancellation, concurrency, deployment, and recovery paths, without relying on undocumented knowledge held by one person.
Visual Basic Documentation and Further Reading
Use these Microsoft references to verify the applicable language rules, runtime contracts, and deployment restrictions. Legacy VBA and VB6 environments require their own documentation; similar names do not establish equivalent behavior.
Similar Posts
