P2Pprogrammer 2 programmer

Home > Interview Question and Answer > C# and VB.Net > .NET Framework

.NET Framework Interview Question and Answer


Interview questions and answers for .NET Framework, .NET base class library, common language runtime (CLR), reference type and a value type, garbage collection, constructors and destructors, Public, Friend, and Private access levels, class and structure, configuration files, application domains, managed and Unmanaged code, Garbage Collector, CTS, MSIL Code.

.NET Framework and Visual Studio 2003, 2005, 2008, 2010, 2013, 2015, 2017 Interview Question and Answers.



Interview questions and answers for .NET Framework 2.0, 3.5, 4.0, 4.5


1. Briefly describe the major components of the .NET Framework and describe what each component do.

The .NET Framework consists of two primary parts: the common language runtime, which manages application execution, enforces type safety, and manages memory reclamation, and the .NET base class library, which consists of thousands of pre developed classes that can be used to build applications.

2. What is reference type and value type?

A value type holds all of the data represented by the variable within the variable itself. A reference type contains a reference to a memory address that holds the data instead of the actual data itself.

3. How do you enable your application to use .NET base class library members without referencing their fully qualified names?

Use the Imports keyword (Visual Basic .NET) or the using keyword (Visual C#) to make a .NET Framework namespace visible to your application.

4. Briefly describe how garbage collection works.

The garbage collector is a thread that runs in the background of managed .NET applications. It constantly traces the reference tree and attempts to find objects that are no longer referenced. When a non referenced object is found, its memory is reclaimed for later use.

5. Briefly describe what members are, and list the four types of members.

Members are the parts of a class or a structure that hold data or implement functionality. The primary member types are fields, properties, methods, and events.

6. Explain what constructors and destructors are and describe what they are used for.

The constructor is the method that initializes a class or structure and is run when a type is first instantiated. It is used to set default values and perform other tasks required by the class. A destructor is the method that is run as the object is being reclaimed by garbage collection. It contains any code that is required for cleanup of the object.

7. Briefly explain the difference between Public (public), Friend (internal), and Private (private) access levels as they apply to user-defined types and members.

In user-defined types, Public (public) classes can be instantiated by any element of the application. Friend (internal) classes can be instantiated only by members of the same assembly, and Private (private) classes can be instantiated only by themselves or types they are nested in. Likewise, a Public (public) member can be accessed by any client in the application, a Friend (internal) member can be accessed only from members of the same assembly, and Private (private) members can be accessed only from within the type.

8. Do you need to instantiate a class before accessing a Shared (static) member? Why or why not?

Because a Shared (static) member belongs to the type rather than to any instance of the type, you can access the member without first creating an instance of the type.

9. Briefly describe how a class is similar to a structure. How are they different?

  1. Both classes and structures can have members such as methods, properties, and fields, both use a constructor for initialization and both inherit from System.Object.
  2. Both classes and structures can be used to model real world objects.
  3. Classes are reference types, and the memory that holds class instances is allocated on the heap.
  4. Structures are value types, and the memory that holds structure instances is allocated on the stack.

10. What are the development tools and operational systems that .NET provides to build, deploy, and integrate applications?

.NET provides the following development tools and operational systems:

  1. Smart Client Software
  2. .NET Server Infrastructure
  3. XML Web Services
  4. Microsoft Visual Studio .NET and the .NET Framework

11. What are the functions of the components of the common language runtime?

The components of the common language runtime provide the run-time environment and run-time services for .NET applications. These components also load the IL code of a .NET application into the runtime, compile the IL code into native code, execute the code, and enforce security. In addition, these components implement type safety and provide

12. What are the different types of assemblies?

The different types of assemblies include

  1. Static and dynamic assemblies
  2. Private and shared assemblies
  3. Single-file and multiple-file assemblies

13. What are the different types of configuration files that the .NET Framework provides?

  1. Machine configuration file- This file is located in the %runtime installation path%\Config directory. The machine configuration file contains settings that affect all the applications that run on the machine.
  2. Application configuration file - This file contains the settings required to configure an individual application. ASP.NET configuration files are named Web.config, and application configuration files are named App.exe.config, where App.exe is the name of the executable.
  3. Security configuration file - The security configuration files contain security permissions for a hierarchy of code groups. The security configuration files define the enterprise-level, machine-level, and user-level security policies. The Enterprisesec.config file defines the security policies for the enterprise. The machine-level Security.config file defines the security policy for the machine, whereas the user-level Security.config file defines the security policy for a user.

14. What are application domains?

Application domains are the boundaries within which applications run. A process can contain multiple application domains. Application domains provide an isolated environment to applications that is similar to the isolation provided by processes. An application running inside one application domain cannot directly access the code running inside another application domain. To access the code running in another application domain, an application needs to use a proxy.

15. What is boxing?

The act of wrapping a Value type, such as an Integer, inside an object so that it can be treated like a Reference type.

16. What is Cust?

An explicit conversion from one type to another.

17. What is Common Language Runtime (CLR) ?

The environment in which managed code executes. The common language runtime provides just-in-time compilation, enforces type safety, and manages memory through garbage collection.

18. What is Common Type System (CTS) ?

A set of types that are used by all .NET languages, thus ensuring .NET language type compatibility.

19. What is Explicit and Implicit Conversion ?

  1. Explicit conversion of one type to another that cannot be performed automatically. An explicit conversion usually presents some danger of a failed conversion or a loss of data.
  2. Implicit conversion between types that can be performed automatically by the common language runtime. An implicit conversion will always succeed and never pose a danger of data loss.

20. What is Garbage Collector (GC)?

Automatic memory management provided by the common language runtime. Unused memory is automatically reclaimed by garbage collection without interaction with the application.

21. What is Manage Code ?

Code that runs under the common language runtime. The common language runtime handles many tasks that would formerly have been handled in the application’s executable. Managed code solves the Windows programming problems of component registration and versioning (sometimes called DLL Hell) because managed code contains all the versioning and type information that the common language runtime needs to run the application. The common language runtime handles registration dynamically at run time rather than statically through the system registry, as is done with applications based on the Component Object Model (COM).

22. What is Microsoft Intermediate Language (MSIL) ?

A low-level language that is just-in-time compiled to native code at run time. All .NET assemblies are represented in the MSIL.

23. What is unmanaged code ?

Code that is not managed by the common language runtime. Unmanaged code is not checked for type-safety and must be used with extreme care.

24. What is Assembly?

Assemblies are the fundamental building blocks of a .NET Framework application. They contain the types and resources that make up an application and describe those contained types to the common language runtime. Assemblies enable code reuse, version control, security, and deployment. Put simply, an assembly is a project that compiles to an executable file or to a DLL file. Although .NET .exe and .dll files resemble other .exe and .dll files externally, the internal structure of an assembly is quite different from that of .exe or .dll files created with earlier development tools. An assembly consists of four internal parts: The assembly manifest, or metadata. This contains information about the assembly that is exposed to the common language runtime.

25. What is Native Image Generator (Ngen.exe)?

The Native Image Generator utility (Ngen.exe) allows you to run the JIT compiler on Your assembly's MSIL and generate native machine code which is cached to disk. Running Ngen.exe on an assembly potentially allows the assembly to load and execute faster, because it restore code and data structure from the native image cache rather than generating them dynamically.

26. What is GAC?

Global Assembly Cache (GAC) A machine-wide cache that stores assemblies that have been specifically designated to be shared between several applications.

More C# and VB.Net Interview Question and Answers

  1. .NET Framework interview questions and answers
  2. VB.NET and C# User Interface interview questions and answers
  3. .NET Object-Oriented Programming (OOPs) interview questions and answers
  4. ADO.NET interview questions and answers
  5. Advanced .NET Framework Topics interview questions and answers
  6. Windows Service, COM+ and XML Web Services interview questions and answers
  7. .NET Assemblies, Configuration, and Security interview questions and answers
  8. VB.NET and C# setup and deployment interview questions and answers
  9. VB.NET and C# general interview questions and answers


Home > Interview Question and Answer > C# and VB.Net > .NET Framework