Three real slices of Module 1: the revision notes, the explained Q&A, and the rapid-fire mock. Tap an option on any question — every lesson works like this.
An interviewer doesn't hand you four options — they ask a question and listen to how you answer it. So every question in this pack is written the way it is actually asked, and every answer gives you the words to say, the follow-up that comes next, and the thing that loses candidates the round. Try the two below; this is exactly how every lesson behaves.
Q1 What does this print, and why? 📣 Reported in: TCS, Infosys, Accenture, Capgemini .NET rounds
int a = 5;
object o = a; // boxing
a = 10;
Console.WriteLine(o);
Say this: It prints 5. int is a value type, so boxing it into object copies the value into a new object on the heap. Changing a afterwards changes the original variable, not that copy — the two are completely independent from the moment the boxing happened.
Say the rule out loud, they're listening for it: value types are copied, reference types are shared.
Follow-up: "So what is boxing costing you?" → A heap allocation and a copy every time. That's why ArrayList, which stores object, boxes a million ints where List<int> boxes none — and it's the reason generics were added to the language.
Follow-up: "Unbox it to a long?" → InvalidCastException. You must unbox to the exact type first, then convert.
Don’t say: "10" — that assumes o holds a reference to a. It's the most common wrong answer, and it's why struct vs class is almost always the very next question.
Q2 Which keyword lets a derived class replace a base-class method at runtime — and what's the difference from new? 📣 Reported in: Cognizant, Wipro, Capgemini, HCL
Say this: override. The base method is marked virtual or abstract, the derived class marks its version override, and the call is resolved by the object's runtime type — that's dynamic polymorphism. new is different: it doesn't override anything, it hides the base method, and the call is resolved by the declared type of the variable.
The one-line rule that lands: override follows the object; new follows the variable.
Follow-up: "So with A x = new B(); where B uses new — which runs?" → A's version, because the variable is declared as A. Cast it to B and you get B's. That's exactly the output puzzle they set next.
Follow-up: "Can you override a static method?" → No. Static members belong to the type and there's no instance to dispatch on.
Don’t say: "new and override do the same thing with different syntax." They produce different output from the same call, and that difference is the whole question.
The full pack has revision notes + 125 explained interview questions like these across C# & OOP, Collections & LINQ, Async & the CLR, ASP.NET Core & EF Core, and SQL Server & ADO.NET, 62 mock-round questions including a predict-the-output round, 30 coding-round programs with the approach to say, clean C# and the follow-up that comes after your code works, and a company-wise module covering what TCS, Infosys, Wipro, Accenture, Capgemini, Cognizant, HCL, Hexaware, Persistent, Nagarro, Zensar, Microsoft, Optum, Amdocs and Oracle Health actually ask — with every answer written out. No multiple choice anywhere, because no interviewer gives you options.
Every module gives you two study lessons: a 📖 full-notes lesson that teaches the topic in depth, and a ⚡ cheat sheet like this one for quick revision before the Q&A. Here are the first 3 sections of the C# & OOP cheat sheet from Module 1 (C# & OOP).
⚡ Cheat sheet · quick revision before the Q&AC# interviews lean on a handful of mechanics: how value and reference types behave, how the compiler resolves a method call, how strings are stored, and how exceptions flow. Learn those and the rest is vocabulary.
usingProgram.cs ──csc (Roslyn)──▶ assembly (.dll/.exe) containing IL + metadata ──▶ CLR JIT-compiles IL to native at runtime
CLR = Common Language Runtime: memory management (GC), type safety, exceptions, JIT, security
CTS = Common Type System (int = System.Int32 in every .NET language); CLS = rules for cross-language compatibility
BCL/FCL = base class library; NuGet = package manager; dotnet CLI = new / build / run / test / publish
.NET Framework (Windows-only, 4.8 is the last) vs .NET (Core → .NET 5/6/7/8): cross-platform, open source, faster, side-by-side versions, unified since .NET 5. New work targets .NET 8 LTS. Managed code runs under the CLR; unmanaged (C++) does not.
| Value types | Reference types | |
|---|---|---|
| Examples | int, double, bool, char, decimal, struct, enum, DateTime | class, string, object, array, interface, delegate |
| Stored | inline (stack for locals, inside the object for fields) | object on the heap; variable holds a reference |
| Assignment | copies the value | copies the reference (both point to one object) |
| Default | zero / false / default(T) | null |
| Can be null? | only as int? (Nullable<int>) | yes (nullable reference types warn in C# 8+) |
int a = 5; object o = a; // boxing: value → heap object
int b = (int)o; // unboxing: explicit cast; wrong type → InvalidCastException
int? n = null; int v = n ?? 0; // null-coalescing; n.HasValue, n.Value, n.GetValueOrDefault()
string s = obj?.Name; // null-conditional
decimal price = 99.99m; // decimal for money (28–29 digits), not double
int x = 7 / 2; // 3 double y = 7 / 2.0; // 3.5 checked(int.MaxValue + 1) → OverflowException
string is a reference type that behaves like a value type — immutable and compared by value (== is overloaded). That one sentence answers three questions.
public class Account
{
public string Id { get; } // read-only auto property (set in constructor)
public decimal Balance { get; private set; } // public read, private write
public string Owner { get; init; } // settable only during object initialisation (C# 9)
private static int _count; // shared by all instances
public Account(string id) { Id = id; _count++; }
public Account() : this("TEMP") { } // constructor chaining
}
public struct Point { public int X, Y; } // value type: small, immutable-ish data; no inheritance
public record Person(string Name, int Age); // immutable reference type with value equality, ToString, deconstruction
var p2 = p1 with { Age = 30 }; // non-destructive mutation
Struct vs class: struct copies on assignment, lives inline, cannot have a parameterless ctor before C# 10, no inheritance (but can implement interfaces). Use struct for small, immutable values (Point, Money). record struct exists too (C# 10).
🔒 7 more sections in the full notes:
+ 2 quick-check interview questions at the end of every study lesson, a ⚡ cheat sheet like this in every module — and a 📖 full-notes lesson that teaches the whole topic in depth before you revise.
After the notes and cheat sheet comes the Q&A lesson — 25 questions asked the way an interviewer asks them, each with a model answer, the follow-up probe and what not to say. Answer aloud first, then open the answer. Here are the first 5 from Module 1.
Q1 What is the CLR, and what does it actually do for you? 🏢 TCS, Infosys, Capgemini
Say this: The CLR is the Common Language Runtime — the virtual machine my C# runs on. The compiler doesn't produce machine code; it produces IL, intermediate language, inside an assembly. At runtime the CLR JIT-compiles that IL to native code for the machine it's actually on, and while the program runs it handles garbage collection, type safety, exception handling and thread management. That's why C# is called managed code — the runtime manages memory and safety instead of me.
Follow-up: "So what's the difference between the CLR and the BCL?" → The CLR is the engine; the BCL — Base Class Library — is the shipped library of types (String, List<T>, File) that runs on it. Together with the compiler and tooling they make up .NET.
Follow-up: "What is JIT and why not compile ahead of time?" → JIT compiles each method the first time it's called, so it can optimise for the actual CPU. AOT (PublishAot, ReadyToRun) exists for faster startup — used in containers and serverless — at the cost of some runtime optimisation.
Don’t say: "The CLR is the C# compiler." The compiler is Roslyn (csc) and it runs before your program; the CLR runs during it. Mixing them up is an instant fresher tell.
Q2 What is the difference between .NET Framework and .NET Core / .NET 8? Which would you use for a new project? 🏢 TCS, Accenture, Cognizant, HCL
Say this: .NET Framework is the old Windows-only stack — 4.8 is the final version, it still gets security fixes but no new features, and one machine has one installed copy. .NET Core, renamed to just .NET from version 5, is cross-platform, open source, considerably faster, and installs side by side so two apps on the same box can target different versions. For anything new I'd target the current LTS — .NET 8 — because it's supported for three years and everything modern, Minimal APIs, EF Core, native AOT, is built there.
Follow-up: "Then what was .NET Standard?" → A specification of APIs that both Framework and Core implemented, so one class library could be referenced by both. It's effectively retired now that everything targets .NET 6/8.
Follow-up: "When would you still choose Framework?" → An existing app on WebForms, WCF server-side or a Windows-only COM dependency. That's a maintenance decision, not a new-project one.
Don’t say: "They're the same, just renamed." They're separate runtimes with different APIs, and confidently mixing them up costs you the answer to every hosting question that follows.
Q3 Walk me through what this prints, and why. 🏢 TCS, Infosys, Wipro — written round
class C { public int V; }
C x = new C { V = 1 };
C y = x;
y.V = 2;
int p = 1, q = p;
q = 2;
Console.WriteLine($"{x.V} {p}");
Say this: It prints 2 1. C is a class, so it's a reference type — y = x copies the reference, both names point at the same object on the heap, so y.V = 2 is visible through x. int is a value type — q = p copies the value, so changing q leaves p at 1.
Say the rule out loud, they're listening for it: value types are copied, reference types are shared.
Follow-up: "Where does each live?" → Value-type locals live on the stack; objects live on the heap and the variable on the stack holds the reference. Careful with the sloppy version of this: an int that is a field of a class lives on the heap inside that object.
Follow-up: "Is string a value type then? It behaves like one." → No, it's a reference type. It only feels like a value type because it's immutable, so you can never observe the sharing.
Don’t say: "2 2" — that assumes int is shared too, and it tells the interviewer you've memorised the phrase without understanding assignment.
Q4 What is boxing and unboxing, and why should you care? 🏢 Cognizant, Capgemini, Infosys
Say this: Boxing wraps a value type in an object on the heap so it can be treated as object; unboxing casts it back out. object o = 42; is boxing — it allocates. int i = (int)o; is unboxing. I care because each box is a heap allocation and a copy, so doing it inside a hot loop creates garbage collection pressure for no reason.
The example that proves you understand it: ArrayList stores object, so adding a million ints boxes a million times. List<int> stores ints directly and boxes nothing — that is exactly why generics were added in C# 2.
Follow-up: "What happens if you unbox to the wrong type?" → InvalidCastException at runtime, even between compatible-looking numerics: boxing an int and unboxing to long throws. You must unbox to the exact type, then convert.
Follow-up: "Give one boxing case people miss." → Calling a non-overridden object method on a struct, or passing a struct where an interface is expected. Also string.Format/old-style Console.WriteLine arguments box their value types.
Don’t say: "It's just casting" — casting between two reference types is free; the whole point of boxing is the allocation.
Q5 struct vs class — when would you actually pick a struct? 🏢 TCS, Wipro, Nagarro
Say this: A struct is a value type: copied on assignment, no inheritance from other structs or classes, can't be null unless I make it Nullable<T>. A class is a reference type: on the heap, supports inheritance, nullable, shared when assigned. In practice I default to class and only reach for struct when the thing is small, immutable and behaves like a single value — a Point, a Money, a coordinate. Microsoft's rule of thumb is under about 16 bytes and immutable.
Follow-up: "Can a struct implement an interface?" → Yes. But if you then store it in a variable of that interface type it gets boxed, which quietly undoes the reason you chose a struct.
Follow-up: "What goes wrong with a big mutable struct?" → Every assignment and every method call copies all of it, so it's slower than the class you were avoiding, and mutations get lost because you're modifying a copy — the classic "I set the property and nothing changed" bug.
Don’t say: "Structs are always faster because they're on the stack." They're on the stack only as locals; as a field of a class they live on the heap with the object.
🔒 20 more explained questions in this lesson — and a 25-question Q&A lesson like this in every tech module, plus the company-wise module with every answer written out.
Every module ends with a mock interview — answer each aloud in 30–60 seconds, then check the key points. First 3 of the 12-question Module 1 mock:
Q1 If I don't write an access modifier on a class member, what is it?
Good answer hits: private for members of a class or struct. For a top-level type it's internal — visible within the assembly. Interface members are implicitly public.
One-liner: "Members default to private, types default to internal."
Follow-up they add: "And protected internal?" → Accessible from the same assembly or from a derived class anywhere. private protected is the stricter one: derived classes, same assembly only.
Q2 Name three value types and three reference types in C#.
Good answer hits: Value types — int, double, bool, char, decimal, DateTime, any struct, any enum. Reference types — string, object, arrays, any class, any interface, delegates.
One-liner: "Structs and enums are values; classes, interfaces, delegates, arrays and string are references."
The two people get wrong: string is a reference type that behaves like a value because it's immutable. An array is a reference type even when it holds ints.
Q3 Which keyword stops a class from being inherited, and give me a BCL example.
Good answer hits: sealed. System.String is the example everyone knows. On a method it's sealed override, which stops further overriding down the chain.
One-liner: "sealed blocks inheritance; String is sealed to protect immutability and interning."
🔒 9 more mock questions in this lesson, and a mock at the end of every module.
Full course
7 modules · 31 lessons · lifetime access
Every module: notes → 25 explained Q&A → mock. Plus the practical round and the company-wise module (TCS, Infosys, Wipro, Accenture…). 7-day money-back guarantee.