net-core-interview-questions
net-core-interview-questions copied to clipboard
π΄ .NET Core Interview Questions and Answered to prepare for your next .NET developer interview
.NET Core Interview Questions And Answers
The sun is setting on .NET Framework. From now on, .NET Core is king. New projects, be they web or desktop, should be started in .NET Core. Stay prepared for your next .NET Core Tech Interview with our list of top .NET Core interview questions and answers.
You could also find all the answers here π https://www.fullstack.cafe/.NET%20Core.
Q1: What is .NET Core? β
Answer:
The .NET Core platform is a new .NET stack that is optimized for open source development and agile delivery on NuGet.
.NET Core has two major components. It includes a small runtime that is built from the same codebase as the .NET Framework CLR. The .NET Core runtime includes the same GC and JIT (RyuJIT), but doesnβt include features like Application Domains or Code Access Security. The runtime is delivered via NuGet, as part of the ASP.NET Core package.
.NET Core also includes the base class libraries. These libraries are largely the same code as the .NET Framework class libraries, but have been factored (removal of dependencies) to enable to ship a smaller set of libraries. These libraries are shipped as System.* NuGet packages on NuGet.org.
π Source: stackoverflow.com
Q2: What is the difference between String and string in C#? β
Answer:
string is an alias in C# for System.String. So technically, there is no difference. It's like int vs. System.Int32.
As far as guidelines, it's generally recommended to use string any time you're referring to an object.
string place = "world";
Likewise, it's generally recommended to use String if you need to refer specifically to the class.
string greet = String.Format("Hello {0}!", place);
π Source: blogs.msdn.microsoft.com
Q3: What is the .NET Framework? β
Answer:
The .NET is a Framework, which is a collection of classes of reusable libraries given by Microsoft to be used in other .NET applications and to develop, build and deploy many types of applications on the Windows platform including the following:
- Console Applications
- Windows Forms Applications
- Windows Presentation Foundation (WPF) Applications
- Web Applications
- Web Services
- Windows Services
- Services-oriented applications using Windows Communications Foundation (WCF)
- Workflow-enabled applications using Windows Workflow Foundation(WF)
π Source: c-sharpcorner.com
Q4: What is .NET Standard? β
Answer:
The .NET Standard is a formal specification of .NET APIs that are intended to be available on all .NET implementations.
π Source: docs.microsoft.com
Q5: What is the difference between .NET Core and Mono? ββ
Answer:
To be simple:
- Mono is third party implementation of .Net Framework for Linux/Android/iOs
- .Net Core is Microsoft's own implementation for same.
π Source: stackoverflow.com
Q6: What are some characteristics of .NET Core? ββ
Answer:
-
Flexible deployment: Can be included in your app or installed side-by-side user- or machine-wide.
-
Cross-platform: Runs on Windows, macOS and Linux; can be ported to other OSes. The supported Operating Systems (OS), CPUs and application scenarios will grow over time, provided by Microsoft, other companies, and individuals.
-
Command-line tools: All product scenarios can be exercised at the command-line.
-
Compatible: .NET Core is compatible with .NET Framework, Xamarin and Mono, via the .NET Standard Library.
-
Open source: The .NET Core platform is open source, using MIT and Apache 2 licenses. Documentation is licensed under CC-BY. .NET Core is a .NET Foundation project.
-
Supported by Microsoft: .NET Core is supported by Microsoft, per .NET Core Support
π Source: stackoverflow.com
Q7: What's the difference between SDK and Runtime in .NET Core? ββ
Answer:
-
The SDK is all of the stuff that is needed/makes developing a .NET Core application easier, such as the CLI and a compiler.
-
The runtime is the "virtual machine" that hosts/runs the application and abstracts all the interaction with the base operating system.
π Source: stackoverflow.com
Q8: What is the difference between decimal, float and double in .NET? ββ
Questions Details:
When would someone use one of these?
Answer:
Precision is the main difference.
- Float - 7 digits (32 bit)
- Double-15-16 digits (64 bit)
- Decimal -28-29 significant digits (128 bit)
As for what to use when:
-
For values which are "naturally exact decimals" it's good to use decimal. This is usually suitable for any concepts invented by humans: financial values are the most obvious example, but there are others too. Consider the score given to divers or ice skaters, for example.
-
For values which are more artefacts of nature which can't really be measured exactly anyway, float/double are more appropriate. For example, scientific data would usually be represented in this form. Here, the original values won't be "decimally accurate" to start with, so it's not important for the expected results to maintain the "decimal accuracy". Floating binary point types are much faster to work with than decimals.
π Source: blogs.msdn.microsoft.com
Q9: What is an unmanaged resource? ββ
Answer:
Use that rule of thumb:
- If you found it in the Microsoft .NET Framework: it's managed.
- If you went poking around MSDN yourself, it's unmanaged.
Anything you've used P/Invoke calls to get outside of the nice comfy world of everything available to you in the .NET Framwork is unmanaged β and you're now responsible for cleaning it up.
π Source: stackoverflow.com
Q10: What is MSIL? ββ
Answer:
When we compile our .NET code then it is not directly converted to native/binary code; it is first converted into intermediate code known as MSIL code which is then interpreted by the CLR. MSIL is independent of hardware and the operating system. Cross language relationships are possible since MSIL is the same for all .NET languages. MSIL is further converted into native code.
π Source: c-sharpcorner.com
Q11: What is a .NET application domain? ββ
Answer:
It is an isolation layer provided by the .NET runtime. As such, App domains live with in a process (1 process can have many app domains) and have their own virtual address space.
App domains are useful because:
- They are less expensive than full processes
- They are multithreaded
- You can stop one without killing everything in the process
- Segregation of resources/config/etc
- Each app domain runs on its own security level
π Source: stackoverflow.com
Q12: Name some CLR services? ββ
Answer:
CLR services
- Assembly Resolver
- Assembly Loader
- Type Checker
- COM marshalled
- Debug Manager
- Thread Support
- IL to Native compiler
- Exception Manager
- Garbage Collector
π Source: c-sharpcorner.com
Q13: What is CLR? ββ
Answer:
The CLR stands for Common Language Runtime and it is an Execution Environment. It works as a layer between Operating Systems and the applications written in .NET languages that conforms to the Common Language Specification (CLS). The main function of Common Language Runtime (CLR) is to convert the Managed Code into native code and then execute the program.
π Source: c-sharpcorner.com
Q14: What is CTS? ββ
Answer:
The Common Type System (CTS) standardizes the data types of all programming languages using .NET under the umbrella of .NET to a common data type for easy and smooth communication among these .NET languages.
CTS is designed as a singly rooted object hierarchy with System.Object as the base type from which all other types are derived. CTS supports two different kinds of types:
- Value Types: Contain the values that need to be stored directly on the stack or allocated inline in a structure. They can be built-in (standard primitive types), user-defined (defined in source code) or enumerations (sets of enumerated values that are represented by labels but stored as a numeric type).
- Reference Types: Store a reference to the valueβs memory address and are allocated on the heap. Reference types can be any of the pointer types, interface types or self-describing types (arrays and class types such as user-defined classes, boxed value types and delegates).
π Source: c-sharpcorner.com
Q15: What is .NET Standard and why we need to consider it? ββ
Answer:
- .NET Standard solves the code sharing problem for .NET developers across all platforms by bringing all the APIs that you expect and love across the environments that you need: desktop applications, mobile apps & games, and cloud services:
- .NET Standard is a set of APIs that all .NET platforms have to implement. This unifies the .NET platforms and prevents future fragmentation.
- .NET Standard 2.0 will be implemented by .NET Framework, .NET Core, and Xamarin. For .NET Core, this will add many of the existing APIs that have been requested.
- .NET Standard 2.0 includes a compatibility shim for .NET Framework binaries, significantly increasing the set of libraries that you can reference from your .NET Standard libraries.
- .NET Standard will replace Portable Class Libraries (PCLs) as the tooling story for building multi-platform .NET libraries.
π Source: stackoverflow.com
Q16: What is Kestrel? βββ
See π Answer
Q17: Talk about new .csproj file? βββ
See π Answer
Q18: What about NuGet packages and packages.config? βββ
See π Answer
Q19: What is difference between .NET Core and .NET Framework? βββ
See π Answer
Q20: Explain what is included in .NET Core? βββ
See π Answer
Q21: What is .NET Standard? βββ
See π Answer
Q22: What's the difference between .NET Core, .NET Framework, and Xamarin? βββ
See π Answer
Q23: Explain two types of deployment for .NET Core applications βββ
See π Answer
Q24: What is CoreCLR? βββ
See π Answer
Q25: Is there a way to catch multiple exceptions at once and without code duplication? βββ
Questions Details:
Consider:
try
{
WebId = new Guid(queryString["web"]);
}
catch (FormatException)
{
WebId = Guid.Empty;
}
catch (OverflowException)
{
WebId = Guid.Empty;
}
Is there a way to catch both exceptions and only call the WebId = Guid.Empty call once?
See π Answer
Q26: Why to use of the IDisposable interface? βββ
See π Answer
Q27: Explain the difference between Task and Thread in .NET βββ
See π Answer
Q28: What is FCL? βββ
See π Answer
Q29: What's is BCL? βββ
See π Answer
Q30: What is implicit compilation? βββ
See π Answer
Q31: What is JIT compiler? βββ
See π Answer
Q32: What is Explicit Compilation? βββ
See π Answer
Q33: What are the benefits of explicit compilation? βββ
See π Answer
Q34: What does Common Language Specification (CLS) mean? βββ
See π Answer
Q35: Explain the difference between βmanagedβ and βunmanagedβ code? βββ
See π Answer
Q36: What is the difference between .NET Standard and PCL (Portable Class Libraries)? βββ
See π Answer
Q37: What is the difference between Class Library (.NET Standard) and Class Library (.NET Core)? βββ
See π Answer
Q38: When should we use .NET Core and .NET Standard Class Library project types? βββ
See π Answer
Q39: What is the difference between .NET Framework/Core and .NET Standard Class Library project types? ββββ
See π Answer
Q40: What's the difference between RyuJIT and Roslyn? ββββ
See π Answer
Q41: Explain how does Asynchronous tasks (Async/Await) work in .NET? ββββ
Questions Details:
Consider:
private async Task<bool> TestFunction()
{
var x = await DoesSomethingExists();
var y = await DoesSomethingElseExists();
return y;
}
Does the second await statement get executed right away or after the first await returns?
See π Answer
Q42: What are benefits of using JIT? ββββ
See π Answer
Q43: Why does .NET use a JIT compiler instead of just compiling the code once on the target machine? ββββ
See π Answer
Q44: What is the difference between CIL and MSIL (IL)? ββββ
See π Answer
Q45: What is the difference between AppDomain, Assembly, Process, and a Thread? ββββ
See π Answer
Q46: Why does .NET Standard library exist? ββββ
See π Answer
Q47: How to choose the target version of .NET Standard library? ββββ
See π Answer
Q48: Explain Finalize vs Dispose usage? βββββ
See π Answer
Q49: What is the difference between Node.js async model and async/await in .NET? βββββ
See π Answer
Q50: How many types of JIT Compilations do you know? βββββ
See π Answer
Q51: Could you name the difference between .Net Core, Portable, Standard, Compact, UWP, and PCL? βββββ
See π Answer