Top 10 Interview Questions for .net

  1. Explain what inheritance is, and why it’s important.
Inheritance is one of the most important concepts in object-oriented programming, together with encapsulation and polymorphism. Inheritance allows developers to create new classes that reuse, extend, and modify the behavior defined in other classes. This enables code reuse and speeds up development. With inheritance, developers can write and debug one class only once, and then reuse that same code as the basis for the new classes. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class. By default, all classes in .NET are inheritable.
  1. Explain 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.
  1. Explain the difference between managed and unmanaged code.
Managed code is a code created by the .NET compiler. It does not depend on the architecture of the target machine because it is executed by the CLR (Common Language Runtime), and not by the operating system itself. CLR and managed code offers developers few benefits, like garbage collection, type checking and exceptions handling. On the other hand, unmanaged code is directly compiled to native machine code and depends on the architecture of the target machine. It is executed directly by the operating system. In the unmanaged code, the developer has to make sure he is dealing with memory usage and allocation (especially because of memory leaks), type safety and exceptions manually. In .NET, Visual Basic and C# compiler creates managed code. To get unmanaged code, the application has to be written in C or C++.
  1. How does the .NET framework work?
  • .NET framework-based applications that are written in supportive languages like C#, F#, or Visual basic are compiled to Common Intermediate Language (CIL).
  • Compiled code is stored in the form of an assembly file that has a .dll or .exe file extension.
  • When the .NET application runs, Common Language Runtime (CLR) takes the assembly file and converts the CIL into machine code with the help of the Just In Time(JIT) compiler.
  • Now, this machine code can execute on the specific architecture of the computer it is running on.
 
  1. 5. What is JIT?
JIT stands for Just In Time. It is a compiler that converts the intermediate code into the native language during the execution.
  1. What is the difference between int and Int32?
There is no difference between int and Int32. Int32 is a type provided by the .NET framework class whereas int is an alias name for Int32 in the C# programming language.
  1. Explain about major components of the .NET framework.
The major components .NET framework are given below:
  • Common Language Runtime(CLR):
    • It is an execution engine that runs the code and provides services that make the development process easier.
    • Services provided by CLR are memory management, garbage collection, type safety, exception handling, security, and thread management. It also makes it easier for designing the applications and components whose objects interact across the languages.
    • The programs written for the .NET Framework are executed by the CLR regardless of programming language. Every .NET Framework version is having CLR.
  • Framework Class Library(FCL):
    • It has pre-defined methods and properties to implement common and complex functions that can be used by .NET applications. It will also provide types for dates, strings, numbers, etc.
    • This class library includes APIs for database connection, file reading and writing, drawing, etc.
  • Base Class Library(BCL):
    • The Base Class Library(BCL) has a huge collection of libraries features and functions that are helpful in implementing various programming languages such as C#, F#, Visual C++, etc., in the .NET Framework.
    • BCL is divided into two parts. They are:
  • User-defined class library:It includes Assemblies.
Assembly: A .NET assembly is considered as the major building block of the .NET Framework. An assembly in the CLI(Common Language Infrastructure) is a logical unit of code, which is used for security, deployment, and versioning. Assembly can be defined in two forms namely Dynamic Link Library(.dll) and executable(.exe) files. When compilation of the .NET program takes place, metadata with Microsoft Intermediate Language(MSIL) will be generated and will be stored in a file called Assembly.  
  • Predefined class library: It contains namespace.
Namespace: It is the collection of pre-defined methods and classes that are present in the .Net Framework. A namespace can be added to a .NET program with the help of “using system”, where using represents a keyword and system represents a namespace.
  • Common Type System(CTS):
    • CTS specifies a standard that will mention which type of data and value can be defined and managed in memory during runtime.
    • It will make sure that programming data defined in different languages should interact with each other for sharing the information. For example, in VB.NET we define datatype as integer, while in C# we define int as a data type.
    • It can be used to prevent data loss when you are trying to transfer data from a type in one language to its equivalent type in another language.
  • Common Language Specification (CLS):
    • Common Language Specification (CLS) is a subset of CTS and defines a set of rules and regulations to be followed by every .NET Framework’s language.
    • A CLS will support inter-operability or cross-language integration, which means it provides a common platform for interacting and sharing information. For example, every programming language(C#, F#, VB .Net, etc.) under the .NET framework has its own syntax. So when statements belonging to different languages get executed, a common platform will be provided by the CLS to interact and share the information.
 
  1. What is an EXE and a DLL?
EXE and DLLs are assembly executable modules. EXE is an executable file that runs the application for which it is designed. An EXE is produced when we build an application. Therefore the assemblies are loaded directly when we run an EXE. However, an EXE cannot be shared with the other applications. Dynamic Link Library (DLL) is a library that consists of code that needs to be hidden. The code is encapsulated inside this library. An application can consist of many DLLs which can be shared with the other programs and applications.
  1. Is ASP.NET different from ASP? If yes, explain how?
Yes, ASP.NET is different from ASP. These are the main differences:
  • NET is developed by Microsoft to create dynamic web applications while ASP (Active Server Pages) is a Microsoft’s server side technology use to create web pages.
  • NET is compiled while ASP is interpreted.
  • ASP uses the technology named ADO while ASP.NET uses ADO.NET.
  • NET is completely object oriented while ASP is partially object oriented.
 
  1. What is the state management in ASP.NET?
State management is a technique that is used to manage a state of an object on different request. It is very important to manage state in any web application. There are two types of state management systems in ASP.NET.

Leave a comment

×

 

Hello!

Click one of our contacts below to chat on WhatsApp

× Click to Whatsapp ... (+1 (321) 353-6006)