Quick .NET Fundamentals: Easy Interview Prep Quiz Quiz

  1. Runtime Basics

    In the .NET platform, which statement best describes the Common Language Runtime (CLR) that executes your managed code when you press the run button in an IDE?

    1. It manages memory, enforces type safety, and executes managed code.
    2. It is a version control system for tracking code changes.
    3. It is a markup language used to design web pages.
    4. It only compiles native C++ code and ignores managed code.
    5. It is a relational database engine for storing tables.
  2. Exception Handling Keyword

    When reading a file that might not exist, which C# keyword pairs with a try block to handle any exception that could be thrown?

    1. catch
    2. throw
    3. final
    4. rescue
    5. except
  3. Boxing Definition

    In C#, what is the term for converting a value type such as int to an object reference, for example int x = 5; object o = x; ?

    1. Boxing
    2. Unboxing
    3. Casting
    4. Marshalling
    5. Pinning
  4. Generic List Characteristics

    Which generic collection in C# allows zero-based indexing, preserves insertion order, and allows duplicate items, for example storing [2, 2, 3] and accessing items by index?

    1. Listu003CTu003E
    2. HashSetu003CTu003E
    3. Dictionaryu003CTKey,TValueu003E
    4. SortedSetu003CTu003E
    5. Queueu003CTu003E
  5. Asynchronous Methods

    When creating an asynchronous method that returns Task, which C# keyword must be in the method signature to enable the use of await inside it?

    1. async
    2. await
    3. yield
    4. defer
    5. future
  6. Interfaces vs Abstract Classes

    When designing a plugin system where classes may already inherit from another base class, which statement about interfaces and abstract classes in C# is correct?

    1. A class can implement multiple interfaces, which only declare members without state.
    2. An abstract class can be instantiated directly if all abstract members are implemented.
    3. A class can inherit from multiple abstract classes.
    4. Interfaces can contain instance fields that hold state by default.
    5. Interfaces cannot be used as method parameter types.
  7. Access Modifiers

    Which access modifier in C# makes a field visible only within the class it is declared in, for example hiding a balance field from other classes?

    1. private
    2. protected
    3. internal
    4. public
    5. privet
  8. Using Statement Behavior

    When opening a file stream with using (var fs = ...), what does the using statement ensure even if an exception occurs?

    1. Dispose is called automatically on the object when the block exits.
    2. The object is pinned and cannot be moved by the garbage collector.
    3. All exceptions inside the block are ignored.
    4. The file is kept open after the block for reuse.
    5. The code inside the block runs on a background thread.
  9. Type Inference with var

    In the statement var count = 10;, which best describes what var means in C#?

    1. The compiler infers the specific type at compile time.
    2. The variable can change its type at runtime.
    3. It is always of type object regardless of the assigned value.
    4. It creates a dynamic type that bypasses compile-time checking.
    5. It automatically makes the variable nullable.
  10. LINQ Filtering

    Given an array numbers = new[] { 1, 2, 3, 4, 5 }, which LINQ method would you call to return only the even numbers?

    1. Where
    2. Select
    3. OrderBy
    4. GroupBy
    5. Join