If you are looking for questions that are usually asked in .net interview questions then you are at the right place. We have picked the best questions that are commonly asked during a .net interview that will help you prepare for your next interview.
Also check- Jquery interview questions / Devops interview questions
.Net Interview Questions
Q1.What is .Net framework?Ans-It is a platform for building various applications on windows. It has a list of inbuilt functionalities in the form of class, library, and APIs which are used to build, deploy and run web services and different applications. It supports different languages such as C#, VB .Net, Cobol, Perl, etc.–This framework supports object-oriented programming model.
Q2.What is CLR?Ans-CLR stands for Common Language Runtime. It is one of the most important components of .Net framework. It provides building blocks for many applications.–An application built using C# gets compiled by its own compiler and is converted into an Intermediate language. This is then targeted to CLR. CLR does various operations like memory management, Security checks, assemblies to be loaded and thread management. It provides a secure execution environment for applications.
Q3.What is CLS?Ans-CLS stands for Common Language Specification. With the rules mentioned under CLS, the developers are made to use the components that are inter-language compatible. They are reusable across all the .Net Compliant languages.
Q4.What is JIT?Ans-JIT stands for Just In Time. JIT is a compiler that converts Intermediate Language to a Native code.–The code is converted into Native language during execution. Native code is nothing but hardware specifications that can be read by the CPU. The native code can be stored so that it is accessible for subsequent calls.
Q5.What is MSIL?Ans-MSIL stands for Microsoft Intermediate Language.–MSIL provides instructions for calling methods, initializing and storing values, operations such as memory handling, exception handling and so on. All .Net codes are first compiled to IL.
Q6.What are the important components of .Net?Ans-The components of .Net are Common language run-time, .Net Class library, Application domain, Common Type System, .Net framework, Profiling, etc. However, the two important components are Class library and Common Language Runtime.–CLR provides building blocks for a wide variety of applications. The class library consists of a set of classes that are used to access the common functionality. The functionality can be shared among different applications.
Q7.What is meant by Managed and Unmanaged code?Ans-The code that is managed by the CLR is called Managed code. This code runs inside the CLR. Hence, it is necessary to install the .Net framework in order to execute the managed code. CLR manages the memory through garbage collection and also uses the other features like CAS and CTS for efficient management of the code.–Unmanaged code is any code that does not depend on CLR for execution. It means it is developed by any other language independent of .Net framework. It uses its own runtime environment for compiling and execution.–Though it is not running inside the CLR, the unmanaged code will work properly if all the other parameters are correctly followed.
Q8.How is a Managed code executed?Ans-Following steps are followed while executing a Managed code:–Choosing a language compiler depending on the language in which the code is written.Converting the above code into Intermediate Language by its own compiler.The IL is then targeted to CLR which converts the code into native code with the help of JIT.Execution of Native code.
Q9.What is ASP.Net?Ans-ASP .Net is a part of .Net technology and it comprises of CLR too. It is an open source server-side technology that enables the programmers to build powerful web services, websites and web applications.
Q10.What is CTS?Ans-CTS stands for Common Type System. It has a set of rules which state how a data type should be declared, defined and used in the program. It describes the data types that are to be used in the application.–We can design our own classes and values by following the rules that are present in the CTS. The rules are made so that the data type declared using a programming language is callable by an application that is developed using a different language.
Best .Net Interview Questions
Q11.Explain State management in ASP .Net.Ans-State Management means maintaining the state of the object. The object here refers to a web page/control.–There are two types of State management, Client Side, and Server side.–Client Side – Storing the information in the Page or Client’s System. They are reusable, simple objects.–Server Side – Storing the information on the Server. It is easier to maintain the information on the Server rather than depending on the client for preserving the state.
Q12.What is an Assembly? What are the different types of Assemblies?Ans-An Assembly is a collection of logical units. Logical units refer to the types and resources which are required to build an application and deploy them using the .Net framework. The CLR uses this information for type implementations. Basically, Assembly is a collection of Exe and Dlls. It is portable and executable.–There are two types of Assemblies, Private and Shared.–Private Assembly, as the name itself suggests, it is accessible only to the application. It is installed in the installation directory of the Application.–A Shared assembly can be shared by multiple applications. It is installed in the GAC.
Q13.Explain the different parts of an Assembly.Ans-The different parts of an Assembly are:–Manifest – It contains the information about the version of an assembly. It is also called as assembly metadata.Type Metadata – Binary information of the program.MSIL – Microsoft Intermediate Language code.Resources – List of related files.
Q14.What is an EXE and a DLL?Ans-Exe and DLLs are Assembly executable modules.–Exe is an executable file. This runs the application for which it is designed. An Exe is generated when we build an application. Hence the assemblies are loaded directly when we run an Exe. However, an Exe cannot be shared with the other applications.–DLL stands for Dynamic Link Library. It is a library that consists of code which needs be hidden. The code is encapsulated inside this library. An Application can consist of many DLLs. These can be shared with the other applications as well.–Other applications which need to share this DLL need not worry about the code intricacies as long as it is able to call the function on this DLL.
Q15.What is Caching?Ans-Caching means storing data temporarily in the memory so that the application can access the data from the cache instead of looking for its original location. This increases the performance of the application and its speed. System.Runtime.Caching namespace is used for Caching information in .Net.–Given below are the 3 different types of Caching:–Page CachingData CachingFragment Caching
Q16.What is MVC?Ans-MVC stands for Model View Controller. It is an architectural model for building the .Net applications.–Models – Model objects store and retrieve data from the database for an application. They are usually the logical parts of an application that is implemented by the application’s data domain.–View – These are the components that display the view of the application in the form of UI. The view gets the information from the model objects for their display. They have components like buttons, drop boxes, combo box, etc.–Controllers – They handle the User Interactions. They are responsible for responding to the user inputs, work with the model objects, and pick a view to be rendered to the user.
Q17.What is the difference between Function and Stored procedure?Ans-Stored Procedure:–A Stored procedure is always used to perform a specific task.It can return zero, one or more value.It can have both Input and Output Parameters.Exception handling can be done using a try-catch block.A function can be called from a Procedure.Functions:–Functions must return a single value.It can only have the input parameter.Exception handling cannot be done using a try-catch block.A Stored procedure cannot be called from a function.
Q18.Explain CAS (Code Access Security).Ans-.Net provides a security model that prevents unauthorized access to resources. CAS is a part of that security model. CAS is present in the CLR. It enables the users to set permissions at a granular level for the code.–CLR then executes the code depending on the available permissions. CAS can be applied only to the managed code. Unmanaged code runs without CAS. If CAS is used on assemblies, then the assembly is treated as partially trusted. Such assemblies must undergo checks every time when it tries to access a resource.–The different components of CAS are Code group, Permissions, and Evidence.–Evidence– To decide what permissions to give, the CAS and CLR depend on the specified evidence by the assembly. The examination of the assembly provides details about the different pieces of evidence. Some common evidence include Zone, URL, Site, Hash Value, Publisher and Application directory.–Code Group – Depending on the evidence, codes are put into different groups. Each group has specific conditions attached to it. Any assembly that matches those condition is put into that group.–Permissions – Each code group can perform only specific actions. They are called Permissions. When CLR loads an assembly, it matches them to one of the code groups and identifies what actions those assemblies can do. Some of the Permissions include Full Trust, Everything, Nothing, Execution, Skip Verification, and the Internet.
Q19.What is GAC?Ans-GAC stands for Global Assembly Cache. Whenever CLR gets installed on the machine, GAC comes as a part of it. GAC specifically stores those assemblies which will be shared by many applications. A Developer tool called Gacutil.exe is used to add any file to GAC.
Q20.What is meant by Globalization and Localization?Ans-Internationalization is the process of designing applications that support multiple languages. This is divided into Localization and Globalization.–Globalization is nothing but developing applications to support different languages. Existing applications can also be converted to support multiple cultures.–Whereas Localization means changing the already globalized app to cater to a specific culture or language Microsoft.Extensions.Localization is used for localizing the app content. Some of the other keywords that are used for Localization are IHtmlLocalizer, IStringLocalizer, IViewLocalizer and so on
.Net Interview Questions For 10 Years Experience
Q21.What is a Constructor?Ans-It’s a method which have same name as class or struct name. It’s called automatically at the time of object creation.
Q22.What are the types of constructors?Ans-Default ConstructorParameterized ConstructorCopy ConstructorStatic ConstructorPrivate Constructor
Q23.What is String Builder? Which one Preferable string or String Builder?Ans-String Builder is a dynamic object. Its allow number of characters in string. Its does not create a new object in memory.–StringBuilder sb = new StringBuilder(“Hi Team!!”);–We can prefer StringBuilder. Beacuse it performs faster than string when appending multiple string values.
Q24.What is Anonymous Functions?Ans-Function without name is called Anonymous functions. Two types of anonymous functions.Lambda ExpressionsAnonymous Methods
Q25.What is Reflection?Ans-It is a process to get metadata of a type at runtime. Few classes for reflection are below,TypeAssemblyAssembly Name
Q26.What is Abstract Class?Ans-Its declared as abstract. It can have abstract and non-abstract methods. It cannot be instantiated. Its implementation must be provided by derived classes.
Q27.What is Sealed?Ans-Its a restrictions of class and methods. Sealed class cannot be derived and Sealed method cannot be overridden.
Q28.What are the filters in MVC?Ans-AuthenticationAuthorizationResultActionException
Q29.How we can use multiple model in Single view?Ans-We can use multiple model in Single view using below things,–View DataView BagTupleDynamic ModelView Model
Q30.Major reasons to select dotnet framework to develop software?Ans-It has rich GUI controls, secured, integrated with many Microsoft applications, scalability and stability, support many programming languages, rich SOLID principals, portable, it supports various architectures and design patterns, easy to maintain and deploy.
.Net Interview Questions For 6 Years Experience
Q31.Reasons behind the top Enterprise applications are built on dotnet framework?Ans-Easiest way to code with a powerful IDE (Visual studio), with better flexibility, rich development community, no compromise with the security, top deploying solution with Microsoft azure cloud integration.
Q32.Ways to achieve redirection from one page to other page in webformsAns-Page processing can be transferred from one page to other page with the help of server.transfer without making a post back to the browser. Redirection of the page from another page can be achieved with the help of response.redirect which perform a post-back to the client browser.
Q33.How to make thread safe with collections.Ans-By using the SynchronizedCollection<T> has a built-in synchronization object which can be used to make collection thread-safe, and this can be used for specific requirement.
Q34.What is the best approach to use collections in multi-threaded applications?Ans-Immutable collection take a different approach in making collections thread-safe. As concurrent collections use synchronization locks instead, immutable collections can’t be changed after they are created. Automatically it makes them safe to use in multi-threaded scenarios since there’s no way for another thread to modify them and make the state inconsistent. This design decision definitely affects the API of immutable collection classes. They don’t even have public constructors.
Q35.What are Honest method or pure method?Ans-Honest method is a function whose output depends on its input parameters and that does not have any side effects. Which means that a pure method cannot mutate an argument, cannot read or mutate global state, cannot read the system timer, cannot read or write file contents, cannot read from or write to the console, etc.
Q36.Why C# is a type safe language?Ans-C# discourages or prevents data type errors, the data type error is un-desirable program behavior caused by variation between differing datatype for the program variables, constants and functions this is the reason behind C# a type safe language.
Q37.C# Types and type member signaturesAns-The System.Object type is CLS compliant and it is base type of all object types in the .NET Framework type system. Inheritance in the .NET Framework is either implicit (for example, the String class implicitly inherits from the Object class) or explicit (for example, the CultureNotFoundException class explicitly inherits from theArgumentException class, that is explicitly inherited from the Exception class. For a derived type to be a CLS compliant, its base type must also be CLS compliant.
Q38.Intrinsic types which are not CLS Compliant in .net frameworkAns-The following intrinsic types are not CLS-Compliant.SByte – 8-bit signed integer data type, TypedReference – Pointer to an object and its runtime type, Uint16 – 16-bit unsigned integer, Uint32 – 32-bit unsigned integer, Uint64 – 64-bit unsigned integer, UintPtr – Unsigned pointer or handle.le.
Q39.What are dynamic views.Ans-Views that don’t declare a model type using @model but that have a model instance passed to them (for example, return View(Address)) can reference the instance’s properties dynamically. The feature offers flexibility, but it doesn’t offer compilation protection or IntelliSense. If the property doesn’t exist, then webpage generation fails at run-time.
Q40.Purpose of Generics.Ans-Generic types to maximize code re-usability, type safety, and performance. The main common use of generics is to create collection classes. The .NET Framework class library contains many new generic collection classes in the System.Collections.Generic namespace. These can be used whenever possible instead of classes such as ArrayList in the System.Collections namespace. We can create our own generic interfaces, classes, methods, events and delegates. Generic may be constrained to enable access to methods on data types. The information on the types that are used in a generics data type may be obtained at run-time by using reflection.
Q41.What are delegates.Ans-In .NET Framework delegates provide a late binding mechanism. it means which we create an algorithm where the caller also supplies at least one method that implements part of the algorithm. Consider sorting a list of stars in an astronomy program. we may choose to sort those stars by their distance from the earth, or the magnitude of the star, or their perceived brightness.
Conclusion:These are the best .Net interview questions and answers. I hope these .Net questions will help you in your .Net interview. If you have any question or suggestion then just comment below or contact us.Thanks