.NET Framework Interview Questions and Answers (547) - Page 4

What is the difference between overloading and overriding ? how can this be .NET?

Overriding - Method has the same signature as the parent class method.
Overloading - Method having diff parameters list or type or the return type may be different.
Explain friend and protected friend?

Friend/Internal - Method, Properties in that class can be accessed by all the classes within that particular assembly.
Protected Friend/Protected Internal - Methods, Properties can be accessed by the child classes of that particular class in that particular assembly.
What is isPostback property?

. This property is used to check whether the page is being loaded and accessed for the first time or whether the page is loaded in response to the client postback.
Consider two combo boxes
In one lets have a list of countries
In the other, the states.
Upon selection of the first, the subsequent one should be populated in accordance. So this requires postback property in combo boxes to be true.
Can you give an example of when it would be appropriate to use a web service as opposed to a non-serviced .NET component?

When to use Web Service:
1. Communicating through a Firewall When building a distributed application with 100s/1000s of users spread over multiple locations, there is always the problem of communicating between client and server because of firewalls and proxy servers. Exposing your middle tier components as Web Services and invoking the directly from a Windows UI is a very valid option.

2. Application Integration When integrating applications written in various languages and running on disparate systems. Or even applications running on the same platform that have been written by separate vendors.

3. Business-to-Business Integration This is an enabler for B2B intergtation which allows one to expose vital business processes to authorized supplier and customers. An example would be exposing electronic ordering and invoicing, allowing customers to send you purchase orders and suppliers to send you invoices electronically.

4. Software Reuse This takes place at multiple levels. Code Reuse at the Source code level or binary componet-based resuse. The limiting factor here is that you can reuse the code but not the data behind it. Webservice overcome this limitation. A scenario could be when you are building an app that aggregates the functionality of serveral other Applicatons. Each of these functions could be performed by individual apps, but there is value in perhaps combining the the multiple apps to present a unifiend view in a Portal or Intranet.

When not to use Web Services:
1. Single machine Applicatons When the apps are running on the same machine and need to communicate with each other use a native API. You also have the options of using component technologies such as COM or .NET Componets as there is very little overhead.

2. Homogeneous Applications on a LAN If you have Win32 or Winforms apps that want to communicate to their server counterpart. It is much more efficient to use DCOM in the case of Win32 apps and .NET Remoting in the case of .NET Apps
when we do the searchpattern in Directory.GetFiles(DirectoryPath, Filter) it will show the 5.docx files two times.

this is the bug of

it only match for 3 no of character of extention.

show when we filter for doc then it also include the docx file/
Whats MSIL, and why should my developers need an appreciation of it if at all?

MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL. MSIL also allows the .NET Framework to JIT compile the assembly on the installed computer.
Can I use the Win32 API from a .NET Framework program?

Yes. Using platform invoke, .NET Framework programs can access native code libraries by means of static DLL entry points.
Here is an example of C# calling the Win32 MessageBox function:
using System;
using System.Runtime.InteropServices;

class MainApp
[DllImport("user32.dll", EntryPoint="MessageBox")]
public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType);

public static void Main()
MessageBox( 0, "Hello, this is PInvoke in operation!", ".NET", 0 );
What are Dead letter queues?

The main use of queue is that you do not need the client and the server running at one
time. So it’s possible that a message will lie in queue for long time until the server or client
picks it up. But there are scenarios where a message is of no use after a certain time. So
these kinds of messages if not delivered within that time span it should not be sent to the
Below is the config snippet which defines for how much time the message should be in
<binding name="MyBindings"
what are the various ways of hosting a WCF service?

There are three major ways to host a WCF service:-
1. Self hosting the service in his own application domain. This we have already covered
in the first section. The service comes in to existence when you create the object of
ServiceHost class and the service closes when you call the Close of the ServiceHost
2. Host in application domain or process provided by IIS Server.
3. Host in Application domain and process provided by WAS (Windows Activation
Service) Server.
can we force garbage collector to run?

System.GC.Collect() forces garbage collector to run.This is not recommended but can be used if situation arises.
What is the difference between debug build and release build?

The biggest difference between these is that:

In a debug build the complete symbolic debug information is emitted to help while debugging applications and also the code optimization is not taken into account.

While in release build the symbolic debug info is not emitted and the code execution is optimized.
Also, because the symbolic info is not emitted in a release build, the size of the final executable is lesser than a debug executable.

One can expect to see funny errors in release builds due to compiler optimizations or differences in memory layout or initialization. These are ususally referred to as Release - Only bugs :)

In terms of execution speed, a release executable will execute faster for sure, but not always will this different be significant.
Difference between String and Stringbuilder reference types?

System.string provides a set of members for working with text.Like search,replace,concratinate etc.. and strings of type system.string are immutable(that means any change to string causes a runtime to create a new string and abandon old one).
System.stringbuilder is used to dynamic strings which are mutable also.these string classes also overrides operators from System.object.
How do you configure the SOAP (Simple Object Access Protocol) to associate with particular web method?

NOTE: This is objective type question, Please click question title for correct answer.
What is the primary purpose of Namespace property, which is used in WebServices attribute?

NOTE: This is objective type question, Please click question title for correct answer.
Which page is used to display the link of webmethods in ASP.NET web services?

NOTE: This is objective type question, Please click question title for correct answer.
What are the three main section of SOAP (Simple Object Access Protocol) message?

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories