.
NET Developer Interview Guide - Part 1 (C# Fundamentals)
Based on the uploaded interview question sheet. This document covers Questions 1-23 with
interview-ready answers.
1. Difference between ref and out
Answer:
ref requires the variable to be initialized before passing; out does not. Both pass by
reference. Use ref when existing value matters; out when returning additional values.
Interview Tip: Explain with a small real-world example whenever possible.
2. Abstract class vs Interface
Answer:
Abstract classes can have implementation, constructors and fields. Interfaces define a
contract and support multiple inheritance.
Interview Tip: Explain with a small real-world example whenever possible.
3. Can we create an object of an abstract class?
Answer:
No. An abstract class cannot be instantiated directly. Create an object of a derived class.
Interview Tip: Explain with a small real-world example whenever possible.
4. Return multiple values
Answer:
Use Tuple, ValueTuple, out parameters, custom class or record.
Interview Tip: Explain with a small real-world example whenever possible.
5. var vs dynamic
Answer:
var is resolved at compile time; dynamic is resolved at runtime and skips compile-time type
checking.
Interview Tip: Explain with a small real-world example whenever possible.
6. Tuple
Answer:
A lightweight type used to return or group multiple values.
Interview Tip: Explain with a small real-world example whenever possible.
7. Value type vs Reference type
Answer:
Value types store data directly (stack in most cases); reference types store references to
objects (heap).
Interview Tip: Explain with a small real-world example whenever possible.
8. Expression Tree
Answer:
Represents code as data. Widely used by LINQ providers such as Entity Framework.
Interview Tip: Explain with a small real-world example whenever possible.
9. IDisposable
Answer:
Implemented to release unmanaged resources. Typically used with the using statement.
Interview Tip: Explain with a small real-world example whenever possible.
10. Anonymous methods
Answer:
Inline methods created using delegate syntax. Lambda expressions are the modern
replacement.
Interview Tip: Explain with a small real-world example whenever possible.
11. Default Web API return type
Answer:
Modern [Link] Core commonly uses IActionResult, ActionResult<T> or IResult (Minimal
APIs).
Interview Tip: Explain with a small real-world example whenever possible.
12. Stack vs Heap
Answer:
Stack stores local variables and is automatically cleaned. Heap stores objects and is cleaned
by the Garbage Collector.
Interview Tip: Explain with a small real-world example whenever possible.
13. Memory cleanup
Answer:
The .NET Garbage Collector automatically frees unused managed objects.
Interview Tip: Explain with a small real-world example whenever possible.
14. Anonymous methods
Answer:
Same as Q10.
Interview Tip: Explain with a small real-world example whenever possible.
15. record
Answer:
Reference type designed for immutable data with value-based equality.
Interview Tip: Explain with a small real-world example whenever possible.
16. CLS vs CTS
Answer:
CTS defines all .NET types; CLS is the subset ensuring language interoperability.
Interview Tip: Explain with a small real-world example whenever possible.
17. Stack vs Queue
Answer:
Stack uses LIFO; Queue uses FIFO.
Interview Tip: Explain with a small real-world example whenever possible.
18. Constructors and destructors
Answer:
A class can have multiple constructors but only one destructor.
Interview Tip: Explain with a small real-world example whenever possible.
19. Async without async/await
Answer:
Yes. Use Task, ContinueWith or ThreadPool, though async/await is preferred.
Interview Tip: Explain with a small real-world example whenever possible.
20. public abstract class : IVehicle
Answer:
An abstract class implements an interface and forces derived classes to implement abstract
members.
Interview Tip: Explain with a small real-world example whenever possible.
21. Single vs SingleOrDefault
Answer:
Single throws if zero or multiple records exist; SingleOrDefault returns default for zero
records but throws for multiple.
Interview Tip: Explain with a small real-world example whenever possible.
22. Select vs First
Answer:
Select(x=>x>3) returns a sequence of booleans. First(x=>x>3) returns the first matching
element (4).
Interview Tip: Explain with a small real-world example whenever possible.
23. SingleOrDefault vs FirstOrDefault
Answer:
FirstOrDefault returns the first match/default. SingleOrDefault requires at most one match;
otherwise throws.
Interview Tip: Explain with a small real-world example whenever possible.