arrow_back Back to Curriculum
terminal

.NET / C#

Enterprise application development concepts covering CLR, LINQ, and Memory Management.

Interview Questions

26 Total
Q1.

What is the Common Language Runtime (CLR)?

Medium

The CLR is the execution engine of the .NET framework that manages running code. It provides memory management (Garbage Collection), thread management, exception handling, and security.

Q2.

Explain the difference between `IEnumerable` and `IQueryable` in LINQ.

Hard

`IEnumerable` executes queries in-memory on the client side, while `IQueryable` translates queries into SQL and executes them on the database server side. `IQueryable` is used to filter data BEFORE it reaches the application.

Q3.

What is a Garbage Collector (GC) in .NET?

Easy

The GC automatically manages the allocation and release of memory for an application. Developers don't have to write code to perform memory management tasks, preventing memory leaks.

Q4.

What are the main differences between a Class and a Struct in C#?

Medium

Classes are Reference Types allocated on the Heap. Structs are Value Types typically allocated on the Stack. Structs do not support inheritance like Classes do.

Q5.

What is the difference between 'continue' and 'break' statements in C#?

Easy

The 'continue' statement skips the rest of the code in the current iteration and moves to the next iteration, while the 'break' statement terminates the loop entirely.

Q6.

How does the 'using' statement in C# ensure resource cleanup?

Medium

The 'using' statement ensures that the Dispose method of an IDisposable object is called, even if an exception occurs, thus ensuring resource cleanup.

Q7.

What is the purpose of the 'sealed' keyword in C#?

Medium

The 'sealed' keyword prevents a class from being inherited, thus restricting its use as a base class.

Q8.

Can you explain the concept of 'covariance' and 'contravariance' in C#?

Hard

Covariance refers to the ability of a generic type to be used as a more specific type, while contravariance refers to the ability of a generic type to be used as a less specific type.

Q9.

How does the 'async/await' syntax in C# simplify asynchronous programming?

Medium

The 'async/await' syntax allows developers to write asynchronous code that is easier to read and maintain, by avoiding the need for explicit callback methods and thread management.

Q10.

What is the difference between 'typeof' and 'GetType()' in C#?

Easy

The 'typeof' operator returns the Type object for a given type, while the 'GetType()' method returns the Type object for the current instance.

Q11.

Can you explain the concept of ' Boxing' and 'Unboxing' in C#?

Medium

Boxing is the process of converting a value type to a reference type, while unboxing is the process of converting a reference type to a value type.

Q12.

What is the purpose of the 'yield' keyword in C#?

Medium

The 'yield' keyword is used to implement iterators, allowing developers to create custom iteration logic for collections and other data structures.

Q13.

How does the 'Garbage Collector' in .NET manage memory?

Medium

The Garbage Collector automatically reclaims memory occupied by objects that are no longer in use, thus preventing memory leaks and optimizing system performance.

Q14.

Can you explain the difference between 'override' and 'new' keywords in C#?

Medium

The 'override' keyword is used to provide a specific implementation for a method that is already defined in its base class, while the 'new' keyword is used to hide a method of the base class.

Q15.

What is the purpose of the 'IDisposable' interface in C#?

Easy

The 'IDisposable' interface provides a standard way for classes to release unmanaged resources, such as file handles or database connections, when they are no longer needed.

Q16.

How does the 'Parallel.ForEach' method in C# simplify parallel programming?

Medium

The 'Parallel.ForEach' method allows developers to execute a loop in parallel, automatically dividing the work among multiple threads and managing thread synchronization.

Q17.

Can you explain the concept of 'Lazy Loading' in C#?

Medium

Lazy loading is a technique that delays the initialization of an object until its value is actually needed, thus improving performance by reducing unnecessary computations.

Q18.

What is the difference between 'string' and 'String' in C#?

Easy

The 'string' keyword is an alias for the 'System.String' class, while 'String' is the actual class name.

Q19.

How does the 'PLINQ' framework in C# simplify parallel query execution?

Medium

PLINQ (Parallel Language Integrated Query) allows developers to execute LINQ queries in parallel, automatically dividing the work among multiple threads and managing thread synchronization.

Q20.

Can you explain the concept of 'memoization' in C#?

Hard

Memoization is an optimization technique that stores the results of expensive function calls so that they can be reused instead of recalculated, thus improving performance.

Q21.

What is the purpose of the 'async Main' method in C#?

Medium

The 'async Main' method allows the main entry point of a console application to be asynchronous, thus enabling the use of async/await syntax in the main method.

Q22.

How does the 'Span<T>' type in C# improve performance in certain scenarios?

Hard

The 'Span<T>' type allows for efficient manipulation of contiguous regions of memory, thus improving performance in scenarios such as parsing and processing large datasets.

Q23.

Can you explain the concept of 'immutable objects' in C#?

Medium

Immutable objects are objects whose state cannot be modified once they are created, thus providing thread safety and improving code maintainability.

Q24.

What is the difference between 'Task.Run' and 'Task.Factory.StartNew' in C#?

Medium

Both 'Task.Run' and 'Task.Factory.StartNew' are used to start a new task, but 'Task.Run' is a simpler and more convenient way to start a task, while 'Task.Factory.StartNew' provides more advanced options for task creation.

Q25.

How does the 'IQueryable<T>' interface in C# enable database queries to be executed remotely?

Hard

The 'IQueryable<T>' interface allows LINQ queries to be executed remotely on a database server, thus enabling efficient data retrieval and reducing the amount of data transferred over the network.

Q26.

Can you explain the concept of 'Expression Trees' in C#?

Hard

Expression trees are data structures that represent code as a tree-like structure, allowing for dynamic creation and manipulation of code at runtime.