1. Tell us what is the Native Image Generator?
It is a tool that compiles the .Net assemblies to machine code for a specific processor. In this way, it improves its performance since the JIT no longer intervenes.
2. Tell us what is a sealed class?
It is a class that is not inheritable. A sealed class comes in use for a super specialized class, by design, and prevents modification by overwriting.
3. Please explain what is Reflection and what is it for?
It is the ability to read, instantiate, and invoke the properties & methods of an assembly's classes. It is especially useful when we do not have the source code for classes, only their assembly.
4. Please explain is the JIT an interpreter?
No, the JIT is not an interpreter. It is a compiler at runtime that improves performance compiling method by method only once. If the method is called a new account, the native code already compiled is used. However, an interpreter executes the same every block of code.
5. Tell us what is a variable of implicit type and what is its scope?
It is a variable that doesn't require type declaration since the compiler automatically determines its type. Its scope is local, within a method. It only allows inferring the kind the first time it assigns a value to the second. However, if the type is different, it throws an error.
6. Please explain what is a delegate?
It is the definition of a method that encapsulates certain arguments and type of return. It allows passing a method as an argument of a function, as long as it matches its specific signature.
7. Please explain what is the difference between a class and an object?
In short, a class is the definition of an object, and an object is instance of a class.
We can look at the class as a template of the object: it describes all the properties, methods, states and behaviors that the implementing object will have. As mentioned, an object is an instance of a class, and a class does not become an object until it is instantiated. There can be more instances of objects based on the one class, each with different properties.
8. Explain me difference between public and static modifiers?
To invoke a method, field, or static property, you don't need to instantiate the class.
On the other hand, to invoke a public method, you need an instance of a class.
9. What is the concept of inheritance and how it works in .NET?
In general OOP terms, inheritance means that a class can be based on another class, with the child class taking on the attributes of the parent class. For example, coders can create a class called Vehicle, and then child classes called Truck, Car and Motorcycle - all of which inherit the attributes of Vehicle.
To demonstrate their understanding of the interview question and the framework, candidates may bring up how .NET supports single inheritance only, which means that a class can inherit only from one other class. Their answer may also touch on the transitive nature of inheritance - for example, the Ford class inherits from Car, which inherits from Vehicle.
10. Please explain what are an object and a class?
An object is an instance of a class, and a class is a template for creating objects. Class is the definition of an object, the description of its characteristics and operations, its properties and its methods. An object has an identity because its characteristics have values.
11. Explain me what is a design pattern and what is it for?
It is a reusable template to solve a common problem at the design level. It is not the code but best practices to codify a solution. Some examples are Singleton, Abstract Factory, Observer or Pub/Sub, Model View Controller, Model View Presenter, and Model-View View-Model.
12. Explain me what is the difference between an abstract class and an interface?
An abstract class is always used as a base class. It provides some abstract/virtual members that the inheriting entities must implement, as well as a partial implementation for a functionality. For extra credit, job candidates might mention that this class can also declare fields. Developers cannot create an object from this class.
An interface, on the other hand, can declare properties, methods and events only (no access modifiers). The developer must implement all declared members. In short, an interface designates a contract/behavior that implementing classes should have.
13. What is the Single Responsibility Principle?
Single responsibility is the concept of a Class doing one specific thing (responsibility) and not trying to do more than it should, which is also referred to as High Cohesion.
Classes don't often start out with Low Cohesion, but typically after several releases and different developers adding onto them, suddenly you'll notice that it became a monster or God class as some call it. So the class should be refactored.
14. Please explain what are an inheritance, polymorphism, and encapsulation?
Inheritance is the ability to reuse definitions from one class in another and to base one class on another.
Polymorphism helps declare the same method within a class with different argument or return types.
Encapsulation is to be able to expose only the methods, property and arguments necessary to use the operations of a class. However, the detailed implementation remains private, hidden to other objects.
15. Please explain what is immutability, what is it for and how is it codified?
The ability of objects not to change their state, once created, helps improve the maintainability of the code. When a mutable object encapsulates its changes without being explicit in the code, following the flow becomes difficult. The level of difficulty increases in case of multi-threaded applications. To create immutable objects, pass the arguments for their creation in the constructor; make their properties read-only later.
16. Tell us the differences between an Interface and an Abstract Class in .NET?
An interface merely declares a contract or a behavior that implementing classes should have. It may declare only properties, methods, and events with no access modifiers. All the declared members must be implemented.
An abstract class provides a partial implementation for a functionality and some abstract/virtual members that must be implemented by the inheriting entities. It can declare fields too.
Neither interfaces nor abstract classes can be instantiated.
17. Please explain when should you use .NET Web Forms over ASP.NET MVC?
Traditionally, the .NET Framework has been based on Web Forms. This was essentially an effort to create web services using Microsoft's existing Visual Studio Tools without forcing developers to learn new scripting languages. Web Forms still allows developers to create quick and simple applications, and some legacy systems may still run as Web Forms.
ASP.NET MVC is increasingly the standard for contemporary developers, however. In a .NET interview, a strong candidate should be able to highlight the advantages of the Model-View-Controller (MVC) architectural pattern. MVC's most important feature is that it allows applications to be broken down into discrete models, views and controllers, making them much easier to test during development.
18. Do you know the difference between the Stack and the Heap?
The short answer would be: in the Stack are stored value types (types inherited from System.ValueType), and in the Heap are stored reference types (types inherited from System.Object).
We can say the Stack is responsible for keeping track of what is actually executing and where each executing thread is (each thread has its own Stack). The Heap, on the other hand, is responsible for keeping track of the data, or more precise objects.
19. Explain me how does LINQ work?
Internally build the correct query (in the case of databases) or generate the corresponding operations on the collections or parse the XML and returns the relevant data. It encapsulates all these behaviors and provides a single implementation, in this way, we can use the same queries, the same language, independently of the underlying data source.
Threads share a mutually exclusive resource manager, Mutex. It ensures that only one thread at a time makes use of one resource (one object) at a time. It is like a moderator that controls the microphone and gives the word to one person at a time. Thus, Mutex grants access to resources one thread at a time. For this, it puts the threads that want to access resources “on hold” until those are in use.
21. Tell us what is Heap and what is Stack?
☛ Both are memory locations, wherein Heap is global and Stack is local.
☛ The Heap is application level while the Stack is thread-level.
☛ The Stack has a defined first-in-first-out stack structure, while the Heap does not have a defined data structure.
☛ Its size is defined at the time of its creation. For Heap, the size is defined when starting the application and for Stack, when creating a thread.
☛ Both can grow dynamically.
☛ The Stack is faster than the Heap. A stack is in “cache” and doesn't have to synchronize with other threads like the Heap.
☛ The Stack stores values while the Heap stores objects.
22. Explain me what is encapsulation?
Encapsulation is one of four basic features of OOP and refers to the inclusion within a program object of methods and data needed for the object to function. For .NET interview questions like this, candidates should mention that encapsulation helps keep data from unwanted access through binding code and data in an object, which is the basic, single self-contained unit of a system.
Another way of understanding encapsulation is to think of it as “hiding” the state of an object as private or protected. Under this principle of information hiding, the internal workings of an object are segregated from the rest of the application. This is useful because it makes it less likely that other objects can modify the state or behavior of the object in question.
23. Please explain what do the terms “boxing” and “unboxing” mean?
This question can reveal how much candidates know about data types and OOP principles. The idea is relatively simple: Boxing is a process that converts a value type to an object type - by “boxing” the variable inside a dedicated object or interface. Unboxing extracts this value and stores it in a value type. Boxing was essential in some old Collection types such as ArrayList, and can still be used for accurate conversion of types - for example, from a double to an int.
24. Explain me what is .NET web service?
Web services are reusable components that allow developers to publish an application's function over the internet to make it accessible and directly interactable with other applications and objects online. Web services communicate by using standard web protocols and data formats - including HTTP, XML and SOAP - allowing them to connect across different platforms and programming languages. ASP.NET provides a simple way to develop web services. The .NET Framework provides built-in classes for building and consuming web services.
25. Please explain the difference between constants and read-only variables?
While constants and read-only variable share many similarities, there are some important differences:
☛ Constants are evaluated at compile time, while the read-only variables are evaluated at run time.
☛ Constants support only value-type variables (the only exception being strings), while read-only variables can hold reference-type variables.
☛ Constants should be used when the value is not changing during run time, and read-only variables are used mostly when their actual value is unknown before run time.
☛ Read-only variables can only be initialised at the time of declaration or in a constructor.
26. Do you know what is lambda expressions in C#?
A lambda expression is an anonymous function that you can use to create delegates or expression tree types. By using lambda expressions, you can write local functions that can be passed as arguments or returned as the value of function calls. Lambda expressions are particularly helpful for writing LINQ query expressions.
27. Please explain what is the difference between constants and read-only variables?
For constants, the compilation contains declaration and initialization. Its value cannot change. For read-only variables, the runtime execution contains the assignment of values.
It is standardization to consult data and convert it into objects, regardless of the source. It is a query manager for databases, XML and enumerable collections using a single language.
29. What is the difference between managed and unmanaged code?
.NET interview questions like this allow candidates to demonstrate their understanding of Common Language Runtime (CLR), a crucial part of the .NET Framework. Code written in C# or Visual Basic .NET will, when compiled, run only in the CLR, which provides functionalities such as garbage collection and memory management. The advantage of this is that managed code is platform-independent because it runs in the CLR rather than the operating system of the machine accessing the application.
Code written in other languages, such as C or C++, produces unmanaged code, meaning developers can't rely on the CLR to provide this kind of portability. Managed and unmanaged code are interoperable. Examples of unmanaged code used in .NET include COM components, ActiveX interfaces and Win32 API functions.
Garbage collection is a low-priority process that serves as an automatic memory manager which manages the allocation and release of memory for the applications. Each time a new object is created, the common language runtime allocates memory for that object from the managed Heap. As long as free memory space is available in the managed Heap, the runtime continues to allocate space for new objects. However, memory is not infinite, and once an application fills the Heap memory space, garbage collection comes into play to free some memory. When the garbage collector performs a collection, it checks for objects in the managed Heap that are no longer being used by the application and performs the necessary operations to reclaim the memory. Garbage collection will stop all running threads, it will find all objects in the Heap that are not being accessed by the main program and delete them. It will then reorganize all the objects left in the Heap to make space and adjust all the Pointers to these objects in both the Stack and the Heap.
To enforce garbage collection in your code manually, you can run the following command (written in C#):
System.GC.Collect();
31. Please explain what is the .Net framework and how does it work?
It is a virtual machine that executes a managed code. The code is compiled from C# or VB .NET and is executed by the CLR (Common Language Runtime).
Its working is as follows:
☛ You create a program in C # or VB.Net and compile it. The code is then translated to CIL (Common Intermediate Language).
☛ The program is assembled into bytecode to generate a CLI (Common Language Infrastructure) assembly file of.exe or .dll format.
☛ When you run the program (or the DLL), it is executed by the .Net framework CLR (Common Language Runtime). Since the code isn't directly run by the operating system, it is called “Managed Code”.
☛ The .Net Framework CLR, through the JIT (Just-In-Time) Compiler, is responsible for compiling this code managed in the intermediate language. The compiled code is then sent to the native machine language assembler for the CPU to execute it.
32. Please explain what is the difference between ODBC and ADO?
Open Database Connectivity is a standard for managing database operations in applications. The standard uses the same methods for Oracle as for Mysql. For example, it declares the connection with particularity at the user or operating system level.
ADO is a set of .Net libraries for data management, including ODBC connections. For ADO, ODBC is a driver.
33. Please explain what is Heap and what is Stack?
☛ Both are memory locations, wherein Heap is global and Stack is local.
☛ The Heap is application level while the Stack is thread-level.
☛ The Stack has a defined first-in-first-out stack structure, while the Heap does not have a defined data structure.
☛ Its size is defined at the time of its creation. For Heap, the size is defined when starting the application and for Stack, when creating a thread.
☛ Both can grow dynamically.
☛ The Stack is faster than the Heap. A stack is in “cache” and doesn't have to synchronize with other threads like the Heap.
☛ The Stack stores values while the Heap stores objects.
34. Do you know what's the difference between .NET and Laravel?
This is one of the more straightforward .NET interview questions you can ask. Most web developers will at least be familiar with alternative frameworks such as Laravel and should be able to discuss some of the differences between those platforms and .NET. This conversation will allow you to dig down and discover where candidates' interests lie and how they view the role of .NET developer. For example, they may focus on:
☛ Languages (e.g. C# support in .NET versus Laravel's support for PHP)
☛ Security
☛ Processing overheads
☛ .NET's integration with Visual Studio
☛ Third-party libraries
☛ Open-source community support
35. Tell us what is JSON data, and what is one way that .NET developers can work with JSON?
JSON (JavaScript Object Notation) provides developers with a way to organize and store data so it's easy to access and read. JSON is important for developers because it allows them to manipulate JSON feeds from other sites and to load them more quickly and easily than via SML/RSS feeds. Json.NET provides a way for .NET developers to define classes that parse objects and arrays from JSON text. You can also use Json.NET if you need to serialize value types into JSON text. Json.NET runs on .NET2, .NET3 and .NET4.