These are a series of questions that can ask you for a.Net developer interview and can be answered in the simplest way. Let’s go for it:
- What is the .Net framework and how does it work?
It is a virtual machine that executes managed code, code that is executed by the CLR (Common Language Runtime) and that has been compiled from C # or VB.Net.
It works in the following way:
- You make a program in C # or VB.Net and compile it; this is translated to CIL (Common Intermediate Language).
- Subsequently, the program in assembly to bytecode to generate a CLI (Common Language Infrastructure) assembled a file that can be .exe or .dll.
- Run the program (or use the DLL), and it is executed by the.Net framework CLR (Common Language Runtime), not by the operating system directly, for this reason, it is called “Managed Code”.
- The .Net Framework CLR, through the JIT compiler (Just In Time Compiler), is responsible for compiling this code managed in intermediate language to the native machine language assembler, so that the CPU can execute it.
The CIL (Common Intermediate Language) is the language that understands the.Net Framework.
C # and VB.Net are languages that we understand humans,
C # and VB. Net are translated to CIL.
- What is the Heap and What is the Stack?
Both are memory locations; the Heap is global; the Stack is local.
The Heap is at the application level, the thread-level Stack.
The Stack is a stack, first inputs first outputs, the Heap does not have a defined data structure.
Its size is defined at the time of its creation, the Heap when starting the application, the Stack when creating a thread.
Both can grow dynamically.
The Stack is faster; it is a stack, it is in “cache”, it does not have to synchronize with the other threads like the Heap.
The Stack stores values, the Heap, objects.
- What is the Garbage Collector?
It is an automatic process of memory release. When the memory is running low, for the threads that are running, it goes through the Heap and eliminates the objects that are no longer being used, frees up memory, reorganizes all the remaining threads and adjusts the pointers to these objects, both in the Heap and in the Stack.
- What is a delegate?
It is a definition of a method, encapsulates certain arguments and type of return. It allows passing a method as an argument of a function, as long as it respects the definition.
- What is LINQ?
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.
- 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.
- What is the deferred execution and the immediate execution in LINQ?
The deferred execution is to encapsulate the definition of the query, but not to execute it until the data is used at runtime. The immediate implementation will call the query at the same moment of its definition.
By default, the executions are deferred, but we can do them immediately by calling “. To List ()” for example, in this way, a list of objects will be executed and returned to us when we define it.
- What are an object and a class?
An object is an instance of a class, and a class is a template for creating objects, it 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.
- What is inheritance, polymorphism, and encapsulation?
Inheritance is the ability to reuse definitions from one class in another, is to be able to base one class on another.
Polymorphism can declare the same method within a class with different arguments or a different type of return.
Encapsulation is to be able to expose only the methods, property and arguments necessary to use the operations of a class, while its detailed implementation remains private, hidden to other objects.
- What is the difference between an abstract class and an interface?
The abstract class can contain constructors, methods, and fields, public and private. The interface only methods and public properties.
You can only inherit from an abstract class, but implement many interfaces.
An interface defines behavior, something that the class that implements it can do. An abstract class defines what the class is, what it represents.
Neither can be instantiated.
An abstract class is useful when creating components, to make a partial initial implementation and a specific definition, leaving you free to implement other methods.
- Difference between public and static modifiers.
A method, field or static property can be invoked without having to instantiate the class.
A public method must be invoked from an instance of a class.
- What is a sealed class?
It is a class that cannot be inherited. It is used when, by design, a class is super specialized and should not be modified by overwriting.
- What is a “jagged array”?
It is an arrangement of arrangements.
- What is serialization?
Convert an object to a data stream. You must implement ISerialize.
- What is the difference between constants and read-only variables?
Constants are declared and initialized in the compilation. Its value cannot change. Read-only variables are assigned at runtime.
- Explain Mutex
Mutually exclusive is a resource manager shared by threads, it ensures that only one thread at a time makes use of one resource (one object) at a time. It is like a moderator who controls the microphone and gives the word to one person at a time; thus, Mutex grants access to resources one thread at a time, putting “on hold” the resources that want to access resources, until These are unemployed.
- What is immutability, what is it for and how is it codified?
The ability of objects not to change their state after being created serves to improve the maintainability of the code since a mutable object can encapsulate its changes and not be explicit in the code, making it difficult to follow the flow, especially in multi-threaded applications. To create immutable objects, you pass the arguments for their creation in the constructor and later make their properties read-only.
- What is the difference between Override and Overload in a method?
Override is to overwrite the method, same signature (parameters and return type) but different functionality. The method must be declared “virtual” in order to overwrite it. Overload is to code several versions of the same method, as long as it has a different signature (parameters and/or return value). It is not necessary that the method be “virtual” to apply to overload.
- What is the difference between struct and class?
A class is a definition of an object and can be inherited. A structure defines a type of data, and cannot be inherited.
- What is the difference between ODBC and ADO?
Open Database Connectivity is a standard for managing database operations in applications, a standard, using the same methods for Oracle as for Mysql, for example, with the particularity that connections are declared 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.
- What is the difference between encrypting a password and applying a hashing?
The hashing (MD5 or SHA1, for example) cannot be decrypted, to validate the password we must have the password in plain text, apply a hash and compare it against the stored one. An encrypted password, if we have the keys and know the encryption algorithms (such as Triple-DES for example), we can get the password in plain text from the encrypted password.
- What is Reflection and what is it for?
Is the ability to read properties and methods of the classes of an assembly, to be able to instantiate and invoke them. It is especially useful when we do not have the source code for these classes, only their assembly.
- What is a design pattern and what is it for? Give some examples
It is a reusable template to solve a common problem at the design level. It is not 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.
- Why do we use the “using” statement?
Using is used to make sure that you release the resources of the object used because it always calls “Dispose of” when it finishes its block of code.
- What is a variable of implicit type and what is its scope?
It is a variable for which you do not have to declare the type since the compiler automatically determines its type. Its scope is local, within a method and only allows to infer the kind the first time a value is assigned, to the second, if the type is different, it will throw an error.
- What is an anonymous method and how is it different from a lambda expression?
An anonymous method is a method that does not need a name or is declared before being used, implemented through a delegate. A lambda expression is a definition of an anonymous method in a single line, replacing the representative for this function, in a more elegant way.
- 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.
- 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, because if the method is called a new account, the native code already compiled is used, while an interpreter executes the same every block of code.