apbd Flashcards

(152 cards)

1
Q

What is Git and why do we use it?

A

Git is a distributed version control system that stores snapshots of your entire project at every commit. Every developer has the full history on their own machine. Key benefits: go back to any point in time, work on multiple features (branches), collaborate without overwriting each other’s work.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the three object types Git stores internally?

A

Blob (raw file content, no filename), Tree (directory snapshot — maps filenames to blob/tree hashes), Commit (pointer to root tree + parent commit + author + message). All stored in .git/objects/ addressed by SHA-1 hash.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Git branch really?

A

A branch is literally just a tiny text file inside .git/refs/heads/ containing a commit hash. Creating a branch is instant and costs almost nothing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is HEAD in Git?

A

HEAD is the file .git/HEAD. It normally holds ‘ref: refs/heads/main’, meaning ‘I am currently on branch main’. When you commit, the current branch pointer moves forward automatically.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is ‘detached HEAD’ state?

A

You checked out a commit directly (not a branch), e.g. git checkout 9f8e7d6. Any commits made here become orphaned if you switch away. Fix: git switch -c rescued-work to create a branch from it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the three zones in Git’s file lifecycle?

A

Working Directory (your edits on disk) → Staging Area / Index (.git/index — what will go into next commit) → Repository (.git/objects — committed snapshots).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does git add -p do?

A

Interactive staging. Git shows each changed chunk (hunk) and asks: stage it? (y/n/s to split). Lets you commit only part of a file for clean, focused commits.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you unstage a file without losing your changes?

A

git restore –staged Student.cs (modern syntax) OR git reset HEAD Student.cs (older syntax)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you discard working directory changes to a file?

A

git restore Student.cs (modern) OR git checkout – Student.cs (older). WARNING: changes are gone permanently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What makes a good commit message?

A

It should complete the sentence ‘If applied, this commit will…’. Be specific. Bad: ‘fix’. Good: ‘Add null-check in StudentController POST handler’. Each commit = one logical change.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does git commit -am do?

A

Stages ALL already-tracked (modified) files and commits in one step. It does NOT include brand new untracked files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a fast-forward merge?

A

When the branch being merged into (e.g. main) has no new commits since the feature branch was created. Git simply moves the main pointer forward — no merge commit is created, history stays linear.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a 3-way merge?

A

When both branches have new commits since they diverged. Git finds the common ancestor, compares both tips, and creates a new merge commit with two parents.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you force a merge commit even when fast-forward is possible?

A

git merge –no-ff feature/login — the –no-ff flag prevents fast-forward and always creates a merge commit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is git rebase and when should you use it?

A

Rebase replays your commits on top of another branch, giving a clean linear history. Use it for local, not-yet-pushed work to tidy history before sharing. NEVER rebase commits others have already fetched.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the golden rule of rebase?

A

Never rebase commits that have already been pushed and others may have fetched. Rebase only your local, unpushed work.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How do you push after rebasing a branch that was already pushed?

A

git push –force-with-lease origin feature/branch — safer than –force because it checks nobody else pushed since your last fetch.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What does interactive rebase (git rebase -i HEAD~4) let you do?

A

Edit, reword, squash, fixup, or drop any of the last 4 commits. Use ‘squash’ to merge a commit into the previous one (combines messages), ‘fixup’ to merge but discard the message.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How do you resolve a merge conflict step by step?

A
  1. git status (see conflicted files). 2. Open file — edit to final state, remove all «<, ===,»_space;> markers. 3. git add ConflictedFile.cs. 4. git commit (finish merge) or git rebase –continue (finish rebase). Code must still compile after resolution.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What do conflict markers mean?

A

«««< HEAD = your current branch version. ======= = separator.»_space;»»> feature/x = incoming branch version. You decide what the final code should be.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is git fetch vs git pull?

A

git fetch downloads remote changes into remote-tracking branches (origin/main) without touching your working directory. git pull = fetch + merge/rebase in one step. Prefer fetch + review + merge for safety.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What does git stash do?

A

Temporarily shelves your uncommitted changes so you can switch branches cleanly. git stash pop restores them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is git blame?

A

Shows every line of a file annotated with who wrote it, which commit, and when. git blame -L 10,20 file.cs shows only lines 10–20.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What commands show commit history?

A

git log (full), git log –oneline (compact), git log –oneline –graph –all –decorate (branch graph — memorise this!), git show <hash> (one commit detail).</hash>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is a .gitignore file for?
Lists patterns of files Git should not track: build output (bin/, obj/), IDE files (.vs/), secrets (appsettings.Development.json), system files (.DS_Store). Add a file after accidentally committing: git rm --cached filename.
26
What is a Pull Request?
A GitHub/GitLab feature (not Git itself) that wraps a branch with discussion, code review, and CI checks before merging into main. You push a branch, open a PR, get reviewed, then merge.
27
What is GitHub Flow?
Simple workflow: main is always deployable. All work goes in a feature branch. Push the branch, open PR, review passes + CI passes → merge to main → deploy. Ideal for most teams.
28
Explain Git Flow branching strategy.
Two permanent branches: main (production) and develop (integration). Feature branches branch from develop. Release branches branch from develop when ready. Hotfix branches branch from main for urgent production fixes.
29
What does git log -S 'CalculateDiscount' do?
Pickaxe search — finds all commits where the string 'CalculateDiscount' was added or removed from any file. Useful for tracking when a function was introduced or deleted.
30
What is the difference between git merge --ff-only and git merge --no-ff?
--ff-only: merge only if fast-forward is possible, otherwise abort. --no-ff: always create a merge commit even if fast-forward would work.
31
What is .NET and what are its main versions?
.NET Framework (2002, Windows-only) → .NET Core (2016, cross-platform rewrite) → .NET 5+ (2020, unified platform). Even versions (6, 8, 10) are LTS (3 years). Odd versions (7, 9) are STS (18 months).
32
What is the difference between .NET SDK and .NET Runtime?
SDK = Runtime + Roslyn compiler + dotnet CLI + templates + MSBuild. Install SDK on your dev machine. Runtime alone on production servers.
33
What does Roslyn do?
Roslyn is the C# compiler. It reads your .cs files and produces IL (Intermediate Language) code in a .dll assembly. No machine code yet — that comes from JIT at runtime.
34
What is JIT compilation?
Just-In-Time: the CLR translates IL to native machine code on first call to each method, caches the result in memory. Second call uses the cached native code. The JIT is called RyuJIT in modern .NET.
35
What is Tiered Compilation?
On by default since .NET Core 3.0. Tier 0: method compiled fast, no optimisations (fast startup). Tier 1: when a method is called often enough, it is recompiled with full optimisations. Best of both worlds.
36
What is AOT compilation?
Ahead-Of-Time: compiles IL to native machine code at publish time, not runtime. Zero cold-start penalty, no .NET runtime needed on target machine. Trade-off: limited reflection, larger binary.
37
What does dotnet new console --name MyApp do?
Creates a new folder MyApp/ containing MyApp.csproj and Program.cs ready to run as a console application.
38
What does dotnet watch run do?
Runs the app and automatically restarts it whenever you save a source file. Very useful during development.
39
What does dotnet publish -c Release --self-contained true --runtime linux-x64 do?
Builds a self-contained binary for Linux x64 that includes the .NET runtime — no .NET installation needed on the target machine.
40
What is a .csproj file?
XML file that is your project's DNA. Contains: target framework (net8.0), NuGet package references, project references, build settings like enable.
41
What does enable in .csproj do?
Enables nullable reference type annotations. The compiler warns you when you might dereference a null reference. string? means nullable, string means non-nullable.
42
What is the difference between value types and reference types in C#?
Value types (int, bool, struct, enum) store data on the stack — copying creates an independent copy. Reference types (class, string, array) store an address to the heap — copying copies the pointer, both variables point to the same object.
43
What is the difference between int and decimal in C#?
int is a 32-bit integer (whole numbers). decimal is 128-bit with 28-29 significant digits and no binary rounding errors. Always use decimal for money: decimal price = 19.99m; Never use float/double for financial calculations.
44
Why is 0.1 + 0.2 != 0.3 in C# (with double)?
double uses binary floating-point representation which cannot represent 0.1 or 0.2 exactly — same as in all IEEE 754 systems. Result: 0.30000000000000004. Use decimal (suffix m) for exact decimal arithmetic.
45
What is string interpolation in C#?
"Prefix a string with $ to embed expressions: string greeting = $\"Hello
46
What is a verbatim string in C#?
Prefix with @: string path = @\"C:\\Users\\Anna\\file.txt\"; — backslashes are literal, no need to escape. Good for file paths and regex.
47
Why is string comparison different in C# vs Java?
In C#, == on strings compares content (overloaded). In Java, == compares references (addresses) — you need .equals(). In C#: \"hello\" == \"hello\" is true.
48
What is the difference between const and readonly?
const: value known at compile time, baked into IL. readonly: value set once at declaration or in constructor, immutable afterwards but set at runtime. Use const for math constants; readonly for runtime-determined values that should never change.
49
What is var in C#?
Type inference — the compiler determines the type from the right-hand side. var name = \"Anna\" creates a string. The type is fixed at compile time; it is NOT dynamic.
50
What is the null-coalescing operator ??
Returns the left side if not null, otherwise the right side. int display = age ?? 0; means 'use age, or 0 if age is null'.
51
What is the null-conditional operator ?.
Safely accesses a member only if not null. Console.WriteLine(student?.Name); — if student is null, does nothing instead of throwing NullReferenceException.
52
What is the ??= operator?
Assigns a value only if the variable is currently null. age ??= 18; means 'if age is null, set it to 18'.
53
What is a property in C# and how is it different from a Java getter/setter?
A property is a language-level construct with get and set accessors. public string Name { get; set; } — no GetName()/SetName() needed. The compiler generates the backing field automatically.
54
What is an init-only property (C# 9)?
public string Email { get; init; } — can only be set during object initialisation (in object initialiser syntax or constructor), then immutable. Use with: var s = new Student { Email = \"x@y.com\" };
55
What is an object initialiser in C#?
Syntax to set properties after construction: var s = new Student { Name = \"Anna\", Age = 21 }; Works with properties that have public set or init accessors.
56
What does override mean in C# and how is it different from Java?
In C# methods are NOT virtual by default. You must mark a base method virtual, then use override in the derived class. In Java all instance methods are virtual by default.
57
What is the difference between abstract class and interface in C#?
Abstract class: IS-A relationship, can have fields, constructors, implemented methods, and abstract holes. Interface: CAN-DO contract, no fields (typically), multiple implementations allowed. A class can implement many interfaces but inherit only one class.
58
What is a record in C#?
An immutable data object. public record Person(string Name, int Age); auto-generates: constructor, properties, value equality (two records with same data are equal), ToString, Deconstruct. Use 'with' to create a copy with changes: var p2 = p1 with { Age = 26 };
59
What is a struct in C#?
A value type (stored on stack, copied on assignment). Good for small, performance-critical data (e.g. Point, Color). Use readonly struct for immutable structs.
60
When should you use record vs class vs struct?
Start with record for immutable data. Use class when you need mutable state and behaviour. Use struct (or readonly record struct) for small (<= 16 bytes) performance-critical value types.
61
What are checked exceptions in C# vs Java?
C# has NO checked exceptions — all exceptions are unchecked. You are not forced to declare or catch them. Java has both checked and unchecked exceptions.
62
What is the correct way to re-throw an exception in C#?
Use bare 'throw;' (not 'throw ex;'). 'throw;' preserves the original stack trace. 'throw ex;' resets the stack trace, losing where the error actually originated.
63
What does ex.ToString() give you vs ex.Message?
ex.Message is only the error description. ex.ToString() gives the full picture: message + exception type + complete stack trace. Always log ex.ToString().
64
What is the 'using' statement for in C#?
Automatically calls Dispose() on IDisposable objects when they go out of scope. using var stream = File.OpenRead(\"data.txt\"); — stream is disposed at the end of the block. Essential for files, database connections, HttpClient.
65
What is exception filtering in C# (when clause)?
catch (HttpException ex) when (ex.StatusCode == 404) { } — catches the exception only if the condition is true. Other HttpExceptions (e.g. 500) are not caught by this handler.
66
What is a delegate in C#?
A type that holds a reference to a method — a typed function pointer. delegate int MathOperation(int a, int b); You can store a method in a variable, pass it to another method, and call it later.
67
What are Func, Action, and Predicate in C#?
Built-in generic delegate types. Func: takes T, returns TResult. Action: takes T, returns void. Predicate: takes T, returns bool. Predicate is equivalent to Func.
68
What is a lambda expression in C#?
A concise anonymous method using =>. Func square = x => x * x; Multi-param: (a, b) => a + b. Multi-statement: x => { if (x < 0) return -x; return x; }. No param: () => Console.WriteLine(\"Hi\");
69
What is a closure in C#?
A lambda that captures variables from its enclosing scope. The compiler generates a hidden class with the captured variables as fields. The lambda captures the VARIABLE (its current value at call time), not the value at definition time.
70
What is the closure trap in for loops?
var actions = new List(); for (int i = 0; i < 5; i++) actions.Add(() => Console.WriteLine(i)); — all print 5 because all lambdas share the same 'i' variable. FIX: int copy = i; inside the loop body so each lambda captures its own copy.
71
Does the closure trap apply to foreach loops in modern C#?
No. Since C# 5+, foreach creates a new variable per iteration, so each lambda in a foreach captures its own independent copy. The trap only applies to classic for loops.
72
What is an expression tree in C#?
When a lambda is assigned to Expression> instead of Func<...>, the compiler builds a data structure (tree of nodes) describing the expression rather than compiling it to IL. Entity Framework reads these trees and translates them to SQL.
73
What is an event in C# and why use it instead of a raw delegate?
event keyword encapsulates a delegate so external code can only += (subscribe) or -= (unsubscribe) — they cannot overwrite all handlers or fire the event from outside. Implements the Observer pattern. Always unsubscribe (-=) when subscriber's lifetime ends to avoid memory leaks.
74
What is LINQ?
Language Integrated Query — a set of extension methods on IEnumerable (and IQueryable for databases) that let you filter, transform, sort, group, and aggregate data using a consistent, declarative API.
75
What does deferred execution mean in LINQ?
Most LINQ operators (Where, Select, OrderBy…) do NOT execute when called — they return a recipe (IEnumerable). Execution happens when you iterate (foreach, ToList, First, Count…). The query always sees the current state of the source at iteration time.
76
Which LINQ operators cause immediate execution?
ToList(), ToArray(), ToDictionary(), ToHashSet(), First(), FirstOrDefault(), Single(), SingleOrDefault(), Last(), Count(), Sum(), Average(), Min(), Max(), Any(), All(), Contains(), Aggregate().
77
Which LINQ operators are deferred (lazy)?
Where, Select, SelectMany, OrderBy, OrderByDescending, ThenBy, GroupBy, Join, GroupJoin, Skip, Take, Distinct, Concat, Union, Intersect, Except, Zip, DefaultIfEmpty.
78
What is the multiple-enumeration problem in LINQ?
If you iterate an IEnumerable query multiple times, it re-executes from scratch each time. With a database, this means multiple round-trips. Fix: call .ToList() once, then reuse the list.
79
What does .Where() do in LINQ?
Filters elements — keeps only those for which the predicate returns true. Returns IEnumerable of the same type. SQL equivalent: WHERE clause.
80
What does .Select() do in LINQ?
Transforms (projects) each element from type T to a new type TResult. Changes the type of the sequence. SQL equivalent: SELECT clause.
81
Why must you filter BEFORE Select, not after?
After Select you have a new type (e.g. IEnumerable). If you try to filter on a property of the original type after Select, it won't compile because that property doesn't exist on the new type.
82
What is the difference between OrderBy and ThenBy?
OrderBy sets the primary sort key and resets any previous sort. ThenBy adds a secondary sort criterion ON TOP of the primary. Using two OrderBy calls in sequence means the second REPLACES the first — always use ThenBy for secondary sorts.
83
What does .First() vs .FirstOrDefault() do?
First(): returns first matching element, throws InvalidOperationException if none found. FirstOrDefault(): returns null (or default value) if no match — SAFE. Always prefer FirstOrDefault in production code.
84
What does .Single() do and when does it throw?
Returns the one and only matching element. Throws InvalidOperationException if there are zero matches OR more than one match. Use when you expect exactly one result.
85
What does .Any() do and why prefer it over Count() > 0?
Any() returns true if at least one element matches the predicate and STOPS at the first match. Count() > 0 traverses the ENTIRE collection. Any() is O(1) in the best case; Count() is always O(n).
86
What does All() return on an empty collection?
True — this is called 'vacuously true'. There are no counter-examples, so the condition holds. Guard with .Any() first if this surprises you.
87
What does .GroupBy() return?
IEnumerable>. Each IGrouping is itself an IEnumerable with a .Key property. You iterate over groups and can iterate each group's elements.
88
What is the SQL equivalent of LINQ's Join?
INNER JOIN — only elements with a matching key on BOTH sides appear in output. Elements with no match on either side are excluded.
89
What is GroupJoin in LINQ?
Equivalent to SQL LEFT OUTER JOIN. Every element from the left side appears; its matched right-side elements form a (possibly empty) group. Use with SelectMany + DefaultIfEmpty for flat LEFT JOIN output.
90
What does .SelectMany() do?
Flattens nested collections. If Select on a nested list gives IEnumerable> (list of lists), SelectMany flattens it to IEnumerable. Equivalent to SQL CROSS APPLY or Java's flatMap.
91
What do Distinct, Union, Intersect, Except do?
Distinct: remove duplicates. Union: unique elements from both collections. Intersect: elements in BOTH. Except: elements in first but NOT in second. Concat: all elements including duplicates.
92
What does .Aggregate() do?
General-purpose fold/reduce. Applies a function cumulatively. Without seed: first element is initial accumulator. With seed: explicit starting value. All Sum/Min/Max/Average are specialisations of Aggregate.
93
What is .Skip(n).Take(m) used for?
Paging. Skip(n) skips the first n elements. Take(m) takes the next m. For page P with page size S: .Skip((P-1)*S).Take(S).
94
What is query syntax in LINQ?
Alternative SQL-like syntax: from s in students where s.Grade >= 3.0 orderby s.Name select s. The compiler translates it entirely to method syntax before compiling. Identical performance.
95
When should you prefer query syntax vs method syntax in LINQ?
Query syntax: complex multi-collection joins, 'let' for temporary variables, when SQL-like form is clearer. Method syntax: simple chains, operators with no query syntax equivalent (Any, All, Count, Skip, Take, Distinct, ToList…).
96
What is the SOLID principle — Single Responsibility?
A class should have one and only one reason to change. Don't put business logic, console UI, and data access all in one class. Each class should do one thing clearly.
97
What is the SOLID principle — Open/Closed?
Classes should be open for extension but closed for modification. Add new behaviour by extending (new subclass, new interface implementation) rather than editing existing code.
98
What is the SOLID principle — Liskov Substitution?
Subclasses must be substitutable for their base class without breaking the program. If code works with Equipment, it must work with Laptop or Projector without surprises.
99
What is the SOLID principle — Interface Segregation?
Clients should not be forced to depend on interfaces they don't use. Prefer many small, specific interfaces over one large general interface.
100
What is the SOLID principle — Dependency Inversion?
High-level modules should not depend on low-level modules — both should depend on abstractions (interfaces). Inject dependencies (e.g. IRentalService) rather than instantiating concrete classes inside.
101
What is cohesion in OOP?
How closely related the responsibilities of a class are. High cohesion = class does one focused thing. Low cohesion = class does many unrelated things. Aim for high cohesion.
102
What is coupling in OOP?
How much classes depend on each other. Tight coupling = changing one class breaks others. Loose coupling = classes interact through interfaces, easy to swap implementations.
103
What is the difference between inheritance and composition?
Inheritance (IS-A): Laptop IS-A Equipment. Composition (HAS-A): RentalService HAS-A list of Equipment. Prefer composition when the relationship is about behaviour/capability rather than identity. Avoid deep inheritance hierarchies.
104
What is an abstract class vs interface — when to use each?
Abstract class: shared implementation + abstract holes, IS-A relationship, single inheritance. Interface: pure contract, CAN-DO capability, multiple implementation allowed. Common pattern in ASP.NET: interface for DI contract + abstract base for shared logic + concrete class.
105
What does the 'virtual' keyword mean in C# and how is it different from Java?
In C#, instance methods are NOT virtual by default. You must explicitly mark a method virtual to allow overriding in subclasses. In Java all instance methods are virtual by default.
106
What does 'sealed' mean in C#?
Prevents further inheritance (on a class) or further overriding (on a method). public sealed class GoldenRetriever : Dog { } — nothing can inherit from GoldenRetriever.
107
What is a generic class/method in C#?
A class or method parameterised by type. class Container { T _value; } — works for any type while maintaining compile-time safety. Constraints: where T : class, IEntity, new() restricts what T can be.
108
What is the difference between C# generics and Java generics?
C# uses reification — type information is preserved at runtime. Java uses type erasure — generic type info is removed at runtime. C# generics have better performance (no boxing for value types) and full runtime type info.
109
What are the main collection types in C# and when to use each?
List: dynamic array, O(1) index access. Dictionary: hash map, O(1) key lookup. HashSet: unique elements, O(1) Contains. Queue: FIFO. Stack: LIFO. Default: List for everything else.
110
What is IEnumerable?
The base interface for all collections in C#. foreach works on anything implementing IEnumerable. It exposes GetEnumerator() which yields elements one at a time. All LINQ methods are extension methods on IEnumerable.
111
What does 'yield return' do?
Creates a lazy iterator. Elements are generated one at a time on demand — the method pauses at yield return and resumes on the next MoveNext() call. Enables infinite sequences: while(true) yield return n++; Take only what you need.
112
What is async/await in C#?
Makes asynchronous code read like synchronous code. await releases the current thread back to the thread pool while waiting for I/O (HTTP, database, file). When the response arrives, execution resumes. Methods must return Task or Task.
113
What is the rule about async void?
Never use async void except in event handlers. You cannot await it, and unhandled exceptions are silently lost. Always use async Task or async Task.
114
What is the danger of .Result or .Wait() in async code?
They block the current thread while waiting for the async operation. In ASP.NET contexts this causes deadlocks because the framework's synchronisation context is already occupied.
115
What is the naming convention for async methods in C#?
Always suffix with Async: GetUserAsync(), not GetUser(). This signals to callers that the method is asynchronous and should be awaited.
116
How do you run two async operations in parallel?
Task t1 = GetUserAsync(id); Task t2 = GetOrderAsync(id); await Task.WhenAll(t1, t2); — start both WITHOUT immediately awaiting, then wait for both to complete.
117
What does CancellationToken do in async code?
Allows cancelling long-running operations. Pass it through and call cancellationToken.ThrowIfCancellationRequested() at logical checkpoints. The caller can cancel by calling Cancel() on a CancellationTokenSource.
118
What is the difference between List.Count (property) and .Count() (LINQ method)?
List.Count is an O(1) property that reads a stored integer. .Count() is a LINQ extension method that traverses the ENTIRE sequence — O(n). Always use the property when available.
119
How does string concatenation differ from StringBuilder in C#?
string text = text + more; creates a new string object each time (the old one waits for GC). In a loop with N iterations this creates N temporary strings. StringBuilder.Append() modifies a buffer in-place — use it for string building in loops.
120
What does int.TryParse() do and why prefer it over int.Parse()?
TryParse returns bool (success/failure) and outputs the result. It never throws. int.Parse throws FormatException on invalid input. Always use TryParse in production code where input might be invalid.
121
What are the C# naming conventions?
Local variables/parameters: camelCase. Classes, methods, properties, namespaces: PascalCase. Private fields: _camelCase. Constants: PascalCase (NOT UPPER_CASE). Async methods: PascalCase + Async suffix.
122
What is the difference between == on value types vs reference types in C#?
Value types: == compares values (5 == 5 is true). Reference types (classes): == compares references (addresses) by default, unless overloaded. string overloads == to compare content. For custom classes, implement Equals() or use records (which have value equality built in).
123
What does .ToList() do in a LINQ chain?
Forces immediate execution of the entire query and stores results in a new List. After this point, changes to the source collection are NOT reflected. Use when: you need multiple passes, need random access, or want a snapshot.
124
What is the difference between .Where().Select() and .Select().Where()?
Always filter BEFORE projecting. After Select, you have a new type and may lose access to original fields needed for filtering. The order matters: Where first narrows the set, then Select transforms what remains.
125
What is Enumerable.Range() and Enumerable.Repeat()?
Range(start, count): generates { start, start+1, ..., start+count-1 }. Repeat(value, count): generates a sequence of 'count' copies of 'value'. Enumerable.Empty() creates an empty sequence.
126
What does .Zip() do in LINQ?
Pairs up elements from two sequences by position: list1.Zip(list2, (a, b) => new { a, b }). Stops at the shorter sequence.
127
What is .DefaultIfEmpty() used for?
If a sequence is empty, yields one element with the default value (null for reference types, 0 for int). Used in GroupJoin + SelectMany for LEFT JOIN simulation.
128
How does .ToDictionary() work?
Materialises a sequence into a Dictionary. students.ToDictionary(s => s.Id) creates a Dictionary keyed by Id. Throws if duplicate keys exist — use .GroupBy first if duplicates are possible.
129
What is .ToHashSet() used for?
Creates a HashSet from a sequence — unique elements with O(1) Contains. Useful for fast lookup: var studentIds = students.Select(s => s.Id).ToHashSet(); then use studentIds.Contains(id).
130
What is the syntax for a switch expression in C# 8+?
string result = value switch { 1 => \"one\", 2 => \"two\", _ => \"other\" }; Much more concise than classic switch. The _ is the default case. Can use 'or' for multiple patterns on one arm.
131
What is a positional record and how do you use 'with'?
public record Point(int X, int Y); — compiler auto-generates constructor, properties, Equals, ToString, Deconstruct. 'with' creates a copy with changes: var p2 = p1 with { Y = 10 }; Original is unchanged.
132
What is NuGet?
The .NET package manager (like npm for JS, Maven for Java). Packages are hosted on nuget.org. Add: dotnet add package Newtonsoft.Json. Remove: dotnet remove package. References stored in .csproj as .
133
What is a solution file (.sln) in .NET?
A container that groups multiple projects (e.g. API project + library project + test project). Visual Studio and Rider open the .sln and show all projects together. Create: dotnet new sln. Add project: dotnet sln MySolution.sln add MyAPI/MyAPI.csproj.
134
What does 'dotnet restore' do?
Downloads all NuGet packages referenced in .csproj from nuget.org and caches them locally in ~/.nuget/packages/. Not re-downloaded on subsequent builds if already cached.
135
What is ImplicitUsings in .csproj?
enable auto-imports common namespaces (System, System.Collections.Generic, System.Linq, System.Threading.Tasks, etc.) so you don't need explicit 'using' statements for them at the top of every file.
136
What is the difference between net8.0 and net48 in TargetFramework?
net8.0 (with dot) = modern cross-platform .NET 8. net48 (no dot) = old Windows-only .NET Framework 4.8. The distinction in the csproj is intentional — the dot signals the modern platform.
137
What is a LINQ join vs a GroupJoin?
Join = INNER JOIN (only matched pairs). GroupJoin = LEFT OUTER JOIN (every left element + a group of matched right elements, possibly empty). GroupJoin + SelectMany + DefaultIfEmpty = flat LEFT JOIN output.
138
In Tutorial 2, what does the README.md need to contain?
Project description, justification of design decisions, where the project shows cohesion/coupling/class responsibilities, why you chose that class organisation and file structure. NOT copied SOLID definitions — your own concrete explanation.
139
In Tutorial 2, what are the GitHub requirements?
At least 8 meaningful commits, at least 2 working branches merged into main, README.md with design justification, run instruction in README.
140
In Tutorial 3, what are the four advanced LINQ challenge tasks?
1. Students with more than one active enrollment. 2. Courses starting in April 2026 without final grades. 3. Lecturers and average grade across all their courses. 4. Student cities and number of active enrollments.
141
In Tutorial 1, what are the three README questions you must answer?
1. When does Git perform a fast-forward and when is a merge commit created? 2. What is the practical difference between merge and rebase? 3. How was the conflict resolved in your repository?
142
What is the assessment focus for Tutorial 1 (Git)?
Readability of the history, correctness of Git operations, sensible commit naming, repository shows a real work process (not a single upload of the final result).
143
What is the assessment focus for Tutorial 2 (OOP)?
Both correctness of behaviour AND structure. If it works but all logic sits in one class, the main purpose is NOT achieved. Separation of responsibilities is graded as heavily as functionality.
144
What is the assessment focus for Tutorial 3 (LINQ)?
Correct use of LINQ operators, result consistent with task description, readability and simplicity of the query, ability to combine several operators in advanced cases.
145
What rental limit applies to students vs employees in Tutorial 2?
Student: maximum 2 active rentals simultaneously. Employee: maximum 5 active rentals simultaneously. System must block the rental if the limit is exceeded.
146
What should the late return penalty rule look like in Tutorial 2?
Penalty rules should be in ONE clearly defined place (not hard-coded in five different places). If the rule may change, it should be easy to modify without touching multiple classes. Example: a dedicated PenaltyCalculator class or a method on the Rental object.
147
What is the dotnet CLI command to run tests?
dotnet test — runs all tests in the project. dotnet test --verbosity detailed for verbose output.
148
What does git remote add origin do?
Links your local repository to a remote repository (on GitHub etc.) under the name 'origin'. After this, git push -u origin main sends your commits to that remote.
149
What is the difference between git push -u origin branch and git push?
-u (--set-upstream) sets the tracking link between local and remote branch. After running it once, you can just type 'git push' on that branch without specifying remote and branch name.
150
What is 'origin' in Git?
Just a conventional name for the primary remote repository. It's not special — it's the default name given when you clone or when you add a remote with that name. You can rename it.
151
What does git clone do automatically?
Creates the local folder, initialises Git, adds 'origin' remote, downloads ALL history, checks out the default branch, and sets up tracking between local and remote branches.
152
What is the recommended way to set up SSH for GitHub?
ssh-keygen -t ed25519 -C \"your.email@example.com\" to generate key pair. cat ~/.ssh/id_ed25519.pub to print the public key. Paste it in GitHub Settings → SSH Keys. Test: ssh -T git@github.com