Select Category 
 

DotNet Interview Questions Answers

DotNet Interview Question - 1 : -

What are channels in .NET Remoting?

DotNet Interview Answer - 1 : -

Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.

 

DotNet Interview Question - 2 : -

What is the difference between typeof(foo) and myFoo.GetType()?

DotNet Interview Answer - 2 : -

  Typeof is operator which applied to a object returns System.Type object. Typeof cannot be overloaded white GetType has lot of overloads.GetType is a method which also returns System.Type of an object. GetType is used to get the runtime type of the object.

Example from MSDN showing Gettype used to retrive type at untime:-

public class MyBaseClass: Object {
}

public class MyDerivedClass: MyBaseClass {
}

public class Test {

   public static void Main() {
      MyBaseClass myBase = new MyBaseClass();
      MyDerivedClass myDerived = new MyDerivedClass();
      object o = myDerived;
      MyBaseClass b = myDerived;

      Console.WriteLine("mybase: Type is {0}", myBase.GetType());
      Console.WriteLine("myDerived: Type is {0}", myDerived.GetType());
      Console.WriteLine("object o = myDerived: Type is {0}", o.GetType());
      Console.WriteLine("MyBaseClass b = myDerived: Type is {0}", b.GetType());
   }
}


/*

This code produces the following output.

What is a Manifest?

DotNet Interview Answer - 3 : -

An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes. The assembly manifest can be stored in either a PE (Portable Executable) file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE (Portable Executable) file that contains only assembly manifest information. The following table shows the information contained in the assembly manifest. The first four items the assembly name, version number, culture, and strong name information make up the assembly's identity.

Assembly name: A text string specifying the assembly's name.

Version number: A major and minor version number, and a revision and build number. The common language runtime uses these numbers to enforce version policy.

Culture: Information on the culture or language the assembly supports. This information should be used only to designate an assembly as a satellite assembly containing culture- or language-specific information. (An assembly with culture information is automatically assumed to be a satellite assembly.) Strong name information: The public key from the publisher if the assembly has been given a strong name. List of all files in the assembly:

A hash of each file contained in the assembly and a file name. Note that all files that make up the assembly must be in the same directory as the file containing the assembly manifest.

Type reference information: Information used by the runtime to map a type reference to the file that contains its declaration and implementation. This is used for types that are exported from the assembly.

Information on referenced assemblies: A list of other assemblies that are statically referenced by the assembly. Each reference includes the dependent assembly's name, assembly metadata (version, culture, operating system, and so on), and public key, if the assembly is strong named.

 

DotNet Interview Question - 4 : -

  How can you prevent your class to be inherated further?

DotNet Interview Answer - 4 : -

   By setting Sealed - Key word

 public sealed class Planet
 {
             //code goes here
 }

class Moon:Planet
 {
     //Not allowed as base class is sealed
 }

 

DotNet Interview Question - 5 : -

  Difference between Dispose and Finallize method?

DotNet Interview Answer - 5 : -

  Finalize method is used to free the memory used by some unmanaged resources like window handles (HWND). It's similar to the destructor syntax in C#. The GC calls this method when it founds no more references to the object. But, In some cases we may need release the memory used by the resources explicitely.To release the memory explicitly we need to implement the Dispose method of IDisposable interface.
 

DotNet Interview Question - 6 : -

What is Delegation?

DotNet Interview Answer - 6 : -

A delegate acts like a strongly type function pointer. Delegates can invoke the methods that they reference without making explicit calls to those methods.
Delegate is an entity that is entrusted with the task of representation, assign or passing on information. In code sense, it means a Delegate is entrusted with a Method to report information back to it when a certain task (which the Method expects) is accomplished outside the Method's class.
 

DotNet Interview Question - 7 : -

  How is the DLL Hell problem solved in .NET?

DotNet Interview Answer - 7 : -

Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly.
 

DotNet Interview Question - 8 : -

  What is managed and unmanaged code?

DotNet Interview Answer - 8 : -

  The .NET framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. i.e., code executing under the control of the CLR is called managed code. For example, any code written in C# or Visual Basic .NET is managed code. Code that runs outside the CLR is referred to as "unmanaged code." COM components, ActiveX components, and Win32 API functions are examples of unmanaged code.
 

DotNet Interview Question - 9 : -

Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

DotNet Interview Answer - 9 : -

  The tracing dumps can be quite verbose.  For applications that are constantly running you run the risk of overloading the machine and the hard drive.  Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.
 

DotNet Interview Question - 10 : -

What are possible implementations of distributed applications in .NET?

DotNet Interview Answer - 10 : -

.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.

 

DotNet Interview Question - 11 : -

What is .NET?

DotNet Interview Answer - 11 : -

 

.NET is essentially a framework for software development. It is similar in nature to any other software development framework (J2EE etc) in that it provides a set of runtime containers/capabilities, and a rich set of pre-built functionality in the form of class libraries and APIs
The .NET Framework is an environment for building, deploying, and running Web Services and other applications. It consists of three main parts: the Common Language Runtime, the Framework classes, and ASP.NET.

 

DotNet Interview Question - 12 : -

  What platforms does the .NET Framework run on?

DotNet Interview Answer - 12 : -

The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development. IIS is not supported on Windows XP Home Edition, and so cannot be used to host
 

DotNet Interview Question - 13 : -

What is view state?

DotNet Interview Answer - 13 : -

The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control
 

DotNet Interview Question - 14 : -

How can you automatically generate interface for the remotable object in .NET with Microsoft tools?

DotNet Interview Answer - 14 : -

the Soapsuds tool.

 

DotNet Interview Question - 15 : -

What is "Common Language Runtime" (CLR)?

DotNet Interview Answer - 15 : -

CLR is .NET equivalent of Java Virtual Machine (JVM). It is the runtime that converts a MSIL code into the host machine language code, which is then executed appropriately. The CLR is the execution engine for .NET Framework applications. It provides a number of services, including:

- Code management (loading and execution)
- Application memory isolation
- Verification of type safety
- Conversion of IL to native code.
- Access to metadata (enhanced type information)
- Managing memory for managed objects
- Enforcement of code access security
- Exception handling, including cross-language exceptions
- Interoperation between managed code, COM objects, and pre-existing DLL's (unmanaged code and data)
- Automation of object layout
- Support for developer services (profiling, debugging, and so on).