FinTechInterview Flashcards

1
Q

git merge vs git rebase

A

git merge creates a new commit that consists of two parent commits
the latest commit from the branch you are merging and into the latest commit from the branch that is being merged. The merged commit has two parents.

git rebase is taking the commits from master and applying them to your feature branch.

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

Lazy Loading

A

feature in EF Core that enables automatic loading of entities only when they are requested

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

EF Core Shadow Properties

A

Properties that are not defined in the entry class but are automatically created and managed by EF Core to store information such as foreign keys, metadata etc.

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

AsNoTracking()

A

Method that drops the tracking of entities from the DbContext. This could improve performance because entities are read only.

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

EF Core N+1 Query problem

A

This solves the problem of eager loading. Explicit loading is introduced and projection.

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

Lazy Loading, Explicit Loading, Projection

A

Lazy Loading: Data is loaded automatically when accessed.
Explicit Loading: Data is loaded manually by developers when needed.
Data is retrieved in a specific shape or with specific properties during the initial query.

Lazy Loading: Can lead to additional queries and performance issues.
Explicit Loading: Developers have more control, reducing the risk of performance issues.
Projection: Can optimize performance by retrieving only necessary data.

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

Difference between Process and a Thread

A

A process is an independent program with its own memory space.

A thread is a lightweight unit of execution within a process. Multiple threads within a process share the same memory space.

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

Mutex

A

A .NET primitive that ensures that only one thread can access a resource over time.

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

lock

A

The lock statement is used to guard a section in the code preventing multiple threads entering it.

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

Thread Pool

A

The Thread Pool is a technique used by the runtime to create and manage threads for each task. Threads from the pool are being pulled to improve performance.

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

What is TPL

A

TPL is a set of APIS in .NET that simplify parallel and concurrent programming. It includes Task and Parallel classes to help developers.

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

TPL vs async await

A

async await is a pattern used in asynchronous programming, allowing for non-blocking execution.

TPL is library allowing parallel programming including parallelizing CPU bound and I/O bound tasks.

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

ConfigureAwait(false) and ConfigureAwait(true)

A

ConfigureAwait(false) states explicitly that you do not want to use the original thread to continue the operation after the await keyword.

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

Task vs Thread

A

Represents an operating system thread. Threads are lower-level constructs provided by the operating system.

Represents a higher-level abstraction for parallel and asynchronous programming. It is built on top of the Thread Pool

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

Concurrency vs Parallelism

A

Concurrency is a concept where multiple tasks are making progress, seemingly simultaneously. It does not necessarily mean that tasks are executing in parallel or simultaneously at the exact same instant.

Parallelism is the simultaneous execution of multiple tasks in order to achieve faster results or improved throughput.

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

SQL Isolation levels

A
  • Read Uncommitted
  • Read Committed
  • Repeatable Read
  • Serializable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Common issues with transactions

A
  • Dirty read A dirty read occurs when one transaction reads data that has been modified by another transaction but not yet committed.
  • A non-repeatable read occurs when a transaction reads the same data multiple times within the same transaction, and the data is modified by another transaction in between the reads
  • A phantom read occurs when a transaction reads a set of rows that satisfy a certain condition, and another transaction inserts, updates, or deletes rows that also satisfy the same condition between the first and second read.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How is the thread represented in the OS, is it part of the OS?

A

The operating system (OS) is responsible for managing threads at the system level. It provides the necessary infrastructure to create, schedule, and switch between threads.

The OS scheduler decides which thread gets CPU time and when. Threads are scheduled based on priority, time slices, and other factors.

19
Q

Difference between asynchronous programming and multithreading

A
20
Q

Relational vs non-relational database, Which is faster, Why?

A
21
Q

What structure is the index

A

Balanced tree

The leaf level of the clustered index contains the actual data rows of the table.
The data pages are organized in a linked list, maintaining the physical order specified by the index key.

22
Q

non-clustered index

A

The non clustered index is a balanced tree as well.

Unlike a clustered index, the leaf level of a non-clustered index does not contain the actual data rows of the table.
Instead, the leaf level contains index rows with the indexed columns and a pointer (or clustered index key) to the corresponding data rows in the table.

23
Q

How does the List work. What’s the difference between List, array, LinkedList. Why would you use a List, why would you use LinkedList?

A
24
Q

Why searching in a dictionary is faster?

A

Unlike a clustered index, the leaf level of a non-clustered index does not contain the actual data rows of the table.
Instead, the leaf level contains index rows with the indexed columns and a pointer (or clustered index key) to the corresponding data rows in the table.

25
Q

How does httpclientfactory work? Is it singleton, is it scoped, is it transient? What about the httpclients generated by httpclientfactory?

A
26
Q

Does the CLR manage threads

A

In a .NET application, threads are also managed by the Common Language Runtime. These are often referred to as “managed threads.”

The CLR provides abstractions and APIs for creating and synchronizing threads. It includes classes in the System.Threading namespace for managing threads, synchronization primitives, and thread pools.

27
Q

What is a process and how is it related to thread? OS-wise

A

A process is an independent program or application in execution. It consists of its own memory space, executable code, system resources, and data.

Each process has its own address space and runs independently of other processes. Processes are isolated from each other, meaning that the memory and resources of one process are not directly accessible by another.

A thread is the smallest unit of execution within a process. Threads within a process share the same memory space and resources, such as file handles and open sockets.

A process can have multiple threads. These threads share the resources of the process, including memory space and file descriptors.

Threads within a process can communicate more efficiently but must coordinate to avoid race conditions and other concurrency issues.

28
Q

Processes and Threads in the CLR

A

In the context of the CLR, a process refers to an instance of the application running on the operating system.

In the context of the CLR, a process refers to an instance of the application running on the operating system.

Threads within the same process share the same application domain, allowing them to communicate through shared memory. However, developers must use synchronization mechanisms to avoid race conditions and ensure thread safety.

Asynchronous programming in .NET often involves the use of tasks and the async and await keywords to simplify concurrent code.

The CLR provides managed abstractions for processes and threads, allowing developers to write code without directly dealing with low-level operating system details.

29
Q

How are Tasks related to Threads and Processes

A

A Task represents an asynchronous operation or a unit of work that can be executed concurrently.

It allows developers to write asynchronous code without explicitly dealing with low-level threading details.

It allows developers to write asynchronous code without explicitly dealing with low-level threading details.

Tasks are managed by the Task Parallel Library (TPL) and can be executed on threads from the ThreadPool.

Multiple tasks can run on the same thread, and a thread can execute multiple tasks sequentially.

Tasks are designed to support both concurrency (efficiently switching between tasks) and parallelism (executing tasks in parallel).

Developers can use tasks to perform operations concurrently without explicitly managing threads.

Task objects support continuations, allowing developers to specify what should happen when a task completes (successfully or with an error).

30
Q

How many threads do you have in the thread pool?

A

ThreadPool in .NET is not fixed and can dynamically adjust based on the workload and system conditions. The ThreadPool in .NET is designed to manage a pool of worker threads that can be reused for executing asynchronous tasks.

You can control the minimum and maximum number of threads in the ThreadPool using the ThreadPool.SetMinThreads and ThreadPool.SetMaxThreads methods, but in many cases, the ThreadPool manages these dynamically based on the system’s resources and workload.

31
Q

Does Threads have their local memory?

A

Each thread in a .NET application has its own private memory space, including its own execution stack and thread-local storage.

Threads within the same process share the same address space, which includes the managed heap where objects are allocated using new.

32
Q

Do you have an abstraction ThreadPool

A

Yes there is the ThreadPool class from which you can schedule new Threads.

33
Q

Async programming vs Concurrency

A

Asynchronous programming is a programming paradigm that allows tasks to be executed independently of the main program flow. In an asynchronous program, tasks that may take time to complete, such as I/O operations or network requests, are initiated, and the program can continue with other tasks while waiting for the results.

Concurrency is a broader concept that involves the simultaneous execution of multiple tasks, possibly overlapping in time. Concurrency doesn’t necessarily imply parallelism

During the database query, when the asynchronous method encounters an await keyword, the original thread from the ThreadPool is released.
This allows the original thread to be used for handling other incoming requests while waiting for the database query to complete.

The asynchronous database query involves sending a request to the database server. The execution of the query takes place on the database server, not within the web app process.
The database server processes the query, retrieves the requested data, and performs any necessary operations.

34
Q

Example of 100 threads and 100 requests

A

However, it’s important to note that the ThreadPool has its own algorithms for managing thread creation and destruction, and it operates automatically based on factors such as demand, available system resources, and the characteristics of the workload.

In .NET, you can influence the behavior of the ThreadPool to some extent using the ThreadPool.SetMinThreads and ThreadPool.SetMaxThreads methods. These methods allow you to set the minimum and maximum number of worker threads, respectively. Keep in mind that these settings are hints to the ThreadPool, and the actual behavior might vary based on the runtime and the specific workload.

35
Q

Concurrency problems

A

Race Conditions: - Multiple threads may access shared resources concurrently, leading to unexpected results.

Deadlock: Deadlocks occur when two or more threads are blocked indefinitely, waiting for each other to release resources. This situation can bring the entire system to a standstill.

36
Q

Mutex

A

Primarily used to provide exclusive access to a resource. A mutex allows only one thread (or process) to acquire and hold the mutex at a time.

The keyword here is process. Mutex is a synchronization primitive on an OS level and provides synchronization across different processes.

37
Q

lock

A

lock is a synchronization primitive providing synchronization for threads of a single process but the scope of the lock is within the process.

38
Q

Semaphore

A

Used to control access to a resource by multiple threads (or processes). Semaphores maintain a count, allowing multiple threads to acquire it concurrently up to a specified limit.

Useful when a resource has a fixed number of available units, and multiple threads can access it concurrently up to the specified limit.

It maintains a count of available resources and allows threads or processes to acquire and release resources within the specified limit.

39
Q

SemaphoreSlim

A

It is a lightweight alternative to the traditional Semaphore class provided in the System.Threading namespace.

SemaphoreSlim allows you to control access to a shared resource by maintaining a count of available resources. Threads or tasks can acquire and release these resources.

40
Q

SQL vs NoSQL databases

A

SQL
-predefined schema
- strong relationships
- scales vertically
NoSQL
- no predefined schema
- dynamic schema in sql databases
- some databases are document based
- horizontal scaling

41
Q

Indexes in NoSQL

A

depends on the database.
For example in MongoDb there are indexes that are B-trees like an SQL db

42
Q

Searching in SQL and NoSQL

A

If the data is highly normalized and relationships are crucial, SQL databases might perform exceptionally well.

In NoSQL This flexibility can be advantageous for certain queries, but it may also require effective indexing strategies.

43
Q
A