Showing posts with label .NET Interview Questions. Show all posts
Showing posts with label .NET Interview Questions. Show all posts

MS.NET Interview Questions And Answers

12/10/2012 No Comment

.Net Interview Questions and Answers for freshers. 

Some Basic Question and Answers in MS.NET expected in IT companies.

What do you mean by code review?
Answer : Code review is nothing but a simple process of examining the source code from a peer or colleague, to verify and find out whether it conforms to the best practices and standards.

Explain what is the global assembly cache (GAC) in MS.NET?
Answer : Global Assembly Cache is a machine-wide cache of assemblies that enable .NET applications to share different libraries. GAC solves one of the main problem associated with Microsoft DLL, also known as Dll Hell.


What do you mean by logging?
Answer : Logging is used in a project to find out the persisting information about the status of an application.

What do you mean by stack and a heap? Explain the differences between the two?
Stack is nothing but a place in the memory where value types are stored whereas Heap is a place in the memory where the reference types are stored.


What do you mean by instrumentation?
Answer : Instrumentation is nothing but the ability to monitor an application so that information about the application’s progress, performance and status can be captured and reported in real time in precise manner.

Explain what do you mean by functional and non-functional requirements?
Answer : Functional requirements defines the behavior of a system whereas non-functional requirements specify how the system should behave or they specify the quality requirements and judge the behavior of a system.
For InstanceFunctional - Display a pie chart which shows the maximum number of products sold in a certain locality.
Non-functional – It is the data presented in the chart that must be updated after a certain duration, say every 6 mins.

What do you mean by mock-ups?
Answer : Mock-ups are a set of designs in the form of screens, diagrams, snapshots which helps in verifying the design and acquiring feedback about the application’s requirements and use cases, at a very early stage of the design process within the project.

What is a Form and what is used for?
Answer : A form is a representation of any graphical window displayed in your .NET application. Form can be used to create standard, border less, floating or modal windows.

Explain what do you mean by a multiple-document interface(MDI)?
Answer : MDI is a user interface container that enables a user to work with more than one document at a time. For instance, Microsoft Excel.

What is a single-document interface (SDI) ?
Answer : SDI is a user interface that is created to manage graphical user interfaces and controls into single windows. For instance, Microsoft Word

What do you mean by ClickOnce in MS.NET?
Answer : ClickOnce is nothing but a new deployment technology that allows you to create and publish self-updating applications that can be installed and run with minimal interaction from the user.


Explain in brief what is BLOB ?
Answer : A BLOB (binary large object) is a large item such as an picture, image, video, media  file or an executable represented in binary form.

Explain what do you mean by object role modeling (ORM) ?
Answer : ORM is a logical model for designing and querying different database models. In the market, there are various ORM tools like CaseTalk, Microsoft Visio for Enterprise Architects, etc.


Explain in detail what is the difference between user and custom controls?
  • User controls are used when the layout is static whereas custom controls are used in dynamic layouts.
  • User controls are easier to create whereas custom controls require a lot of extra effort.
  • A user control cannot be added to the toolbox whereas a custom control can be added.
  • A separate copy of a user control is required in every application that uses it whereas since custom controls are stored in the GAC, only a single copy can be used by all applications.
What is a private assembly?
Answer : A private assembly is an assembly that is deployed with an application and is used only by that application. Private means the assembly cannot be referenced by another application outside the installation directory.

What do you mean by a shared assembly?
Answer : A shared assembly is kept in the Global Assembly Cache (GAC) and can be used by one or more applications on a machine.

Where do custom controls reside?
Answer : Custom controls reside in the global assembly cache (GAC).

What do you mean by a third-party control ?
Answer : A third-party control is one that is not created by the owners of a project. They are usually used to save time and resources and reuse the functionality developed by others (third-party).

What do you mean by a binary formatter?
Answer : Binary formatter is used to serialize and deserialize an object in binary format.

Explain Boxing/Unboxing concept in .NET?
Answer : Boxing is used when we need to convert value types to object.
E.g. int x = 1;
object obj = x ;
Unboxing is used when we need to convert the object back to the value type.
E.g. int y = (int)obj;
Boxing and Unboxing is quiet an expensive operation, so care should be taken.


What do you mean by a digital signature?
Answer : A digital signature is an electronic signature that is used to verify and guarantee the identity of a certain user who is sending the message.

What do you mean by COM Callable Wrapper (CCW)?
Answer : CCW is a wrapper created by the .NET Common Language Runtime(CLR) that enables COM components to access .NET objects.

What do you mean by Runtime Callable Wrapper (RCW)?
Answer : RCW is a wrapper created by the .NET Common Language Runtime(CLR) to enable .NET components to call COM components.

Explain in short what is garbage collection?
Answer : Garbage collection is the process of managing the memory, the allocation and release of memory in your applications. Allocation is required for the program to occupy space in memory and de-allocation releases the memory after the execution of the program.

What do you mean by globalization?
Answer : Globalization is the process of customizing/modifying applications so that it support multiple cultures and regions. For instance, an application that is to be rolled in 20 different countries.

What do you mean by localization?
Answer : Localization is nothing but the process of customizing applications that support a given culture and regions. For Instance, An application rolled out in France, the language preference, currency, the time-zone settings and other cultural settings will pertain to France.

Miscrosoft.NET Advanced Question Answers

8/31/2012 No Comment

Miscrosoft.NET Advanced Question Answers with code.

Can we use static constructors to initialize non static members?
Yes, it is possible. But we have to create an object of the class inside the static constructor and then initialize the non static member through the object reference.

Code(example):
class Class2
{
int a;
static Class2()
{
Class2 p = new Class2();
p.a = 45;
System.Console.WriteLine(p.a);
}
static void Main()
{
}
}
Is MSIL a high/low/middle level language?

MSIL is Microsoft Intermediate Language:
It is nothing but a set of CPU independent instructions which represent your code and used to provide language interoperability and compatibility of your code on different platforms.

It is not a high level language:
High Level language is C#:
High level language  as such is more human readable,closer to a spoken language.
(Example: programming constructs like loops,if else conditions, keywords like using, class)
High level language defines modular programming,OOPS concepts and the source code.

MSIL is not low level language either:
Low level language is in an executable or binary format(eg: machine language)
MSIL is not in an executable or binary format.

MSIL is not middle level language too:
Middle level language is C. It has modular programming and source code.
It is human readable.
C also supports low level programming (Assembly Language).

What is the difference between Assembly.LoadFrom() and Assembly.LoadFile() methods?
Both methods are used to load the assemblies. we can then extract all the metatdata of the assembly using Reflection.

Difference:
1)LoadFrom can use either the name or the path of the assembly, LoadFile will expect the path of the assembly(see the overloaded versions)

2)LoadFrom uses a probing algorithm to find the assembly.f if you have two assemblies that have the same identity but different locations, you can get some unexpected behavior.But using LoadFile, you can load the desired assembly as needed.

Can you install multiple assemblies together?
Answer : Yes, we can install multiple assemblies together use installutil command in .NET
Ex: installutil Assembly1.exe Assembly2.exe.
The above command will install both the Assemblies in a transactional manner. the two are dependent ie if installation of one of the assemblies fail, the installation of the other assembly will be rolled back.

What is the difference between lock and Monitor.Enter() in .NET ?
Answer : The lock keyword in .NET basically provides a shortcut to Enter method of Monitor class.
Monitor is used to provide thread synchronization. It means till the Thread in which the method is being used finishes its task, no other thread can access the same object.

example:
lock (object)
{
}
It is compiled into
Monitor.Enter(object);
try
{
//code
}
finally
{
Monitor.Exit(object);
}
We can write much more code and perform customization in the try block.

Dear readers, please use the comment section for suggestions, feedback and also for any questions that you have for us.

Question Answers on Advanced Foundations of Microsoft .NET

8/27/2012 No Comment

Interview Question and Answers on Advanced  Foundations of Microsoft .NET

Explain under what scenarios and circumstances we need to go for HTML server controls and when we have to go for .NET web server controls?
Answer : When we talk of server controls we should always remember that they are a part of ASP.NET.  As such when a server control is needed to be used there will be an extra overhead on the server to create the control at run time and in accordance with it set the values. On the other hand HTML controls are only static controls and are easy to use in the application. They are also supported in ASP.NET for use.

Now as a thumb rule, if there is a corresponding HTML control available instead of the ASP.NET server control, it is always preferable to got for the HTML control as it improves the server performance and ensures faster response, as it reduces a lot of server overhead. Server controls should only be used in cases when the available HTML controls are not sufficient to achieve the particular tasks in the application.

Explain what is the the main difference between user control and a custom control in ASP.NET? List out the advantages/disadvantages?
Web user controls are quite easier to create and are mainly for static layout whereas Web custom controls are comparatively much harder to create and they are good for dynamic layout. User controls offers limited support for consumers who use a visual design tool and cannot be added in the toolbox in Visual Studio, but a custom control offers full visual design tool support for consumers and can be added to the toolbox area. For a user control, we need a separate copy of the control in each application, on the other hand only a single copy of the control is required, in the global assembly cache (GAC) for a custom control in ASP.NET.

Can you tell us what is the dll that is required to translate XML to SQL in IIS?
Answer : The DLL Microsoft.data.sqlxml.dll is used to translate XML to SQL using Internet Information Server (IIS)

Explain what do you mean by is connection pooling and how can you use it in your application?
Answer : When we open a database connection, its a very performance intensive operation, it is also a very time consuming operation. Using the concept of connection pooling we can increase the performance of the applications just by reusing the active database connections instead of creating new connection every time.

Connection pooling is controlled by the 4 connection string parameters which controls most of the connection pooling behavior in the .NET applications
1. Connect Timeout
2. Max Pool Size
3. Min Pool Size
4. Pooling

Explain why client side JavaScript validation don't run on the ASP.NET Button but they run successfully on the HTML Button?
Answer :  In case of ASP.NET, the button is  post backed on the server when the state is not yet Submit and when it goes to the server its state is lost. As such, if we are using JavaScript in our application so we always use the Input Button in the ASP Button.

Explain what is the use of ErrorProvider Control in ASP.NET?
Answer : In ASP.NET, the ErrorProvider control is used to indicate wrong or invalid data on a data entry form. By using this control, we are able to attach error messages that display next to the control when the data is invalid. Nornally, a red circle with an exclamation point blinks when the user moves over the cursor, the error message is displayed as a tooltip which helps the end user to understand with more clarity.

Which is the DLL used to translate XML to SQL in Internet Information Server (IIS)?
Answer : Sqlisapi.dll is the DLL which is used to translate XML to SQL in Internet Information Server (IIS) in ASP.NET.

Explain what is the main difference Between Response.write & response.output.Write in ASP.NET?
Answer : In ASP.NET the Response object is of type HttpResponse and when you say Response.Write you’re really saying (basically) HttpContext.Current.Response.Write and calling one of the many overloaded Write methods of HttpResponse. Response.Write then calls .Write() on it’s internal TextWriter object:
public void Write(object obj){ this._writer.Write(obj);}
HttpResponse also has a Property called Output that is of type, yes, TextWriter, so:
public TextWriter get_Output(){ return this._writer; }
Which means you can to the Response whatever a TextWriter will let you. Now, TextWriters support a Write() method ala String.Format, so you can do this:
Response.Output.Write(”Scott is {0} at {1:d}”, “cool”,DateTime.Now);
But internally this is what that is happening:
public virtual void Write(string format, params object[] arg)
{
this.Write(string.Format(format, arg));
}
Explain how would you make a class serializable?
Answer : To make a class serializable is to mark it with the Serializable attribute as follows.
[Serializable]
public class MyObject {
public int n1 = 0;
public int n2 = 0;
public String str = null;
}
What do you mean by Viewstate in Microsoft.NET?
Answer : In old and classic ASP, when a form is submitted , all form values are cleared. Any error in the page means you have to start all over again and reenter the values. With ASP.NET when a form is submitted, it is able to retain with all form values. It is possible only because of the property called ViewState (which is an instance of the StateBag class). In ASP.NET, a server control’s ViewState is nothing but the accumulation of all its property values. To retain its values across HTTP requests, ASP.NET server controls use this property which was not there in classical ASP.

Advanced MS.NET Interview Questions Answers

8/12/2012 No Comment
What is the difference between Panel and GroupBox classes using .NET?

Panel and Group box both can used as container for other controls like radio buttons and check box.
the difference in panel and group box are Panel
1) In case of panel captions cannot be displayed
2) Can have scroll bars.

Group box
1) Captions can be displayed.
2) Cannot have a scroll bar

How many types of exception handlers are there in .NET?

http://msdn.microsoft.com/library/default.asp? url=/library/en-us/cpguide/html/cpconexceptionsoverview.asp
The exception information table represents four types of exception handlers for protected blocks:
A finally handler that executes whenever the block exits, whether that occurs by normal control flow or by an unhandled exception.

A fault handler that must execute if an exception occurs, but does not execute on completion of normal control flow.

A type-filtered handler that handles any exception of a specified class or any of its derived classes.

A user-filtered handler that runs user-specified code to determine whether the exception should be handled by the associated handler or should be passed to the next protected block.

What are the advantages and drawbacks of using ADO.NET?
Pros

ADO.NET is rich with plenty of features that are bound to impress even the most skeptical of programmers. If this weren’t the case, Microsoft wouldn’t even be able to get anyone to use the Beta. What we’ve done here is come up with a short list of some of the more outstanding benefits to using the ADO.NET architecture and the System.Data namespace.

* Performance – there is no doubt that ADO.NET is extremely fast. The actual figures vary depending on who performed the test and which benchmark was being used, but ADO.NET performs much, much faster at the same tasks than its predecessor, ADO. Some of the reasons why ADO.NET is faster than ADO are discussed in the ADO versus ADO.NET section later in this chapter.

* Optimized SQL Provider – in addition to performing well under general circumstances, ADO.NET includes a SQL Server Data Provider that is highly optimized for interaction with SQL Server. It uses SQL Server’s own TDS (Tabular Data Stream) format for exchanging information. Without question, your SQL Server 7 and above data access operations will run blazingly fast utilizing this optimized Data Provider.

What are the different methods of session maintenance in ASP.NET?
3 types:
In-process storage.
Session State Service.
Microsoft SQL Server.

In-Process Storage
The default location for session state storage is in the ASP.NET process itself.

Session State Service
As an alternative to using in-process storage for session state, ASP.NET provides the ASP.NET State Service. The State Service gives you an out-of-process alternative for storing session state that is not tied quite so closely to ASP.NET’s own process.

To use the State Service, you need to edit the sessionState element in your ASP.NET application’s web.config file:
You’ll also need to start the ASP.NET State Service on the computer that you specified in the stateConnectionString attribute. The .NET Framework installs this service, but by default it’s set to manual start up. If you’re going to depend on it for storing session state, you’ll want to change that to automatic start up by using the Services MMC plug-in in the Administrative Tools group.

If you make these changes, and then repeat the previous set of steps, you’ll see slightly different behavior: session state persists even if you recycle the ASP.NET process.


What is an interface and what is an abstract class? Please, expand by examples of using both. Explain why?
In a interface class, all methods are abstract without implementation where as in an abstract class some methods we can define concrete. In interface, no accessibility modifiers are allowed. An abstract class may have accessibility modifiers. Interface and abstract class are basically a set of rules which u have to follow in case u r using them(inheriting them).

What is CLR in .NET?
CLR(Common Language Runtime) is the main resource of .Net Framework. it is collection of services like garbage collector, exception handler, jit compilers etc. with the CLR cross language integration is possible.

What exactly is being serialized when you perform serialization in .NET?
The object’s state (values)

What do you know about ADO.NET’s objects and methods?
ADO.NET provides consistent access to data sources such as Microsoft SQL Server, as well as data sources exposed through OLE DB and XML.

Data-sharing consumer applications can use ADO.NET to connect to these different data sources and retrieve, manipulate, and update data.

ADO.NET provides first-class support for the disconnected, n-tier programming environment for which many new applications are written.
95 :: .NET framework overview?
1. Has own class libraries. System is the main namespace and all other namespaces are subsets of this.
2. It has CLR(Common language runtime, Common type system, common language specification)
3. All the types are part of CTS and Object is the base class for all the types.
4. If a language said to be .net complaint, it should be compatible with CTS and CLS.
5. All the code compiled into an intermediate language by the .Net language compiler, which is nothing but an assembly.
6. During runtime, JIT of CLR picks the IL code and converts into PE machine code and from there it processes the request.
7. CTS, CLS, CLR
8. Garbage Collection
9. Dispose, finalize, suppress finalize, Idispose interface
10. Assemblies, Namespace: Assembly is a collection of class/namespaces. An assembly contains Manifest, Metadata, Resource files, IL code
11. Com interoperability, adding references, web references
12. Database connectivity and providers

List of ASP.NET interview questions only?
1. What is a static class?
2. What is static member?
3. What is static function?
4. What is static constructor?
5. How can we inherit a static variable?
6. How can we inherit a static member?
7. Can we use a static function with a non-static variable?
8. How can we access static variable?
9. Why main function is static?
10. How will you load dynamic assembly? How will create assesblies at run time?

Advanced MS.NET Interview Questions Answers

7/17/2012 No Comment

Advanced MS.NET Interview Questions Answers asked in top companies.

What is context menu?
The menu that you get when you right-click is called the context menu. It is a modular piece of markup code that can move around the page. It consists of two distinct blocks, one is the user interface and another is the script code to connect the UI to it.

Explain how to retrieve resources using ResourceManager class?
ResourceManager class is used to retrieve resources at run time.
• Create a ResourceManager with resource file name and the resource assembly as parameters.
• After having created, you can use ResourceManager.GetString method to retrieve a string.
• Use the ResourceManager.GetObject method to retrieve images and objects from a resource file.

What are the ways to retain variables between requests?
Below there are different ways to retain variables between requests. That is:

Context.Handler: This object can be used to retrieve public members of the webform from a subsequent web page.

Querystring: Querystring is used to pass information between requests as part of the web address. Since it is visible to use, we can't use it to send any secured data.

Cookies: Cookies stores small amount of information on client side. But we can't reply on cookies since many clients can refuse cookies.

View state: View state stores items added to the pages. These properties are as hidden fields on the page.

Session state: Session state stores items that are local to the current session.

Application state: Application state stores items that are available to all users of the application.

In .NET, which namespace contains classes used to a)Create a localized application? b)Develop Web Forms? c)Create Web server controls? d)Access Sql Server? e)Read a File?
a)System.Globalization, System.Resources
b)System.Web
c)System.Web.UI.WebControls
d)System.Data.SqlClient
e)System.IO

What is break mode? What are the options to step through code?
Break mode lets you to observe code line to line in order to locate error.

The VS.NET provides following options to step through code.
• Step Into
• Step Over
• Step Out
• Run To Cursor
• Set Next Statement

How do we step through code?
Stepping through the code is a way of debugging the code in which one line is executed at a time.

There are three commands for stepping through code:

Step Into: This debugging mode is usually time-consuming. However, if one wants to go through the entire code then this can be used. When you step into at a point and a function call is made somewhere in the code, then step into mode would transfer the control to the first line of the code of the called function.

Step Over: The time consumed by the Step into mode can be avoided in the step over mode. In this, while you are debugging some function and you come across another function call inside it, then that particular function is executed and the control is returned to the calling function.

Step Out: You can Use Step Out when you are inside a function call and want to return to the calling function. Step Out resumes execution of your code until the function returns, and then breaks at the return point in the calling function.

What are the debugging windows available?
The windows which are available while debugging are known as debugging windows.

These are: Breakpoints, Output, Watch, Autos, Local, Immediate, Call Stacks, Threads, Modules, Processes, Memory, Disassembly and Registers.

Explain the similarities and differences between arrays and collections?

• The Array class is not part of the System.Collections namespace. But an array is a collection, as it is based on the list interface.

• Array has a fixed capacity but the classes in the System.Collections namespace don’t have fixed capacity. That’s why array is a static container, but collection is dynamic container.

• Collections objects have a key associated with them. You can directly access an item in the collection by the key. But to find a specific item in an array, unless you don’t know the index number you need to traverse the array to find the value.

Explain declarative and imperative security?

Security checks can be applied in two ways that is imperatively or declaratively.

Declarative security is applied by associating attribute declarations that specify a security action with classes or methods.

Imperative security is applied by calling the appropriate methods of a Permission object that represents the Principal (for role based security) or system resource (for code access security).

What is code security? What are the types?
.NET framework provides the security features to secure code from unauthorized users.

There are two types of code security:
Role based security: This authorizes user.
Code access security: This protects system resources from unauthorized calls.

Define Principal object?

The Principal object represents authenticated users. It contains information about user’s identity and role. You have Principal Permission object in .NET Framework that specifies user and its role. It has Demand method that checks the current user or Principal against the name and role specified in the Principal Permission.

Which namespace contains the classes that required to serialize an object? Explain Object Serialization?
System.Runtime.Serialization

Object serialization is the process of reducing an object instance into a format that can be either stored to disk or transported over a network.

Accenture MS.NET Interview Questions Answers

7/16/2012 No Comment
How do you assign an RGB color to a System.Drawing.Color object?
You can call the static method FromArgb of this class and pass it the RGB values in .NET

What is Delegation in .NET?
Delegate acts like a strongly type function pointer. Delegates can invoke the methods that they reference without making explicit calls to those methods.

It 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.

What is "Microsoft Intermediate Language" (MSIL)?
A .NET programming language (C#, VB.NET, J# etc.) does not compile into executable code; instead it compiles into an intermediate code called Microsoft Intermediate Language (MSIL). As a programmer one need not worry about the syntax of MSIL - since our source code in automatically converted to MSIL. The MSIL code is then send to the CLR (Common Language Runtime) that converts the code to machine language, which is, then run on the host machine. MSIL is similar to Java Byte code. MSIL is the CPU-independent instruction set into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects. Combined with metadata and the common type system, MSIL allows for true cross- language integration Prior to execution, MSIL is converted to machine code. It is not interpreted.

Differences between Datagrid, Datalist and Repeater in .NET?
1. Datagrid has paging while Datalist doesn't.
2. Datalist has a property called repeat. Direction = vertical/horizontal. (This is of great help in designing layouts). This is not there in Datagrid.
3. A repeater is used when more intimate control over html generation is required.
4. When only checkboxes/radiobuttons are repeatedly served then a checkboxlist or radiobuttonlist are used as they involve fewer overheads than a Datagrid.
The Repeater repeats a chunk of HTML you write, it has the least functionality of the three. DataList is the next step up from a Repeater; accept you have very little control over the HTML that the control renders. DataList is the first of the three controls that allow you Repeat-Columns horizontally or vertically. Finally, the DataGrid is the motherload. However, instead of working on a row-by-row basis, you’re working on a column-by-column basis. DataGrid caters to sorting and has basic paging for your disposal. Again you have little control, over the HTML. NOTE: DataList and DataGrid both render as HTML tables by default. Out of the 3 controls, I use the Repeater the most due to its flexibility w/ HTML. Creating a Pagination scheme isn't that hard, so I rarely if ever use a DataGrid.
Occasionally I like using a DataList because it allows me to easily list out my records in rows of three for instance.

I am constantly writing the drawing procedures with System.Drawing.Graphics, but having to use the try and dispose blocks is too time-consuming with Graphics objects. Can I automate this?
Yes, the code

System.Drawing.Graphics canvas = new System.Drawing.Graphics();
try
{
//some code
}
finally
canvas.Dispose();

is functionally equivalent to

using (System.Drawing.Graphics canvas = new System.Drawing.Graphics())
{
//some code
} //canvas.Dispose() gets called automatically
How do you trigger the Paint event in System.Drawing?
Invalidate the current form, the OS will take care of repainting. The Update method forces the repaint.


With these events, why wouldn’t Microsoft combine Invalidate and Paint, so that you wouldn’t have to tell it to repaint, and then to force it to repaint?
Painting is the slowest thing the OS does, so usually telling it to repaint, but not forcing it allows for the process to take place in the background.

What class does Icon derive from? Isn’t it just a Bitmap with a wrapper name around it?
No, Icon lives in System.Drawing namespace. It’s not a Bitmap by default, and is treated separately by .NET. However, you can use ToBitmap method to get a valid Bitmap object from a valid Icon object.

Before in my VB app I would just load the icons from DLL. How can I load the icons provided by .NET dynamically?
By using System.Drawing.SystemIcons class, for example System.Drawing.SystemIcons.Warning produces an Icon with a warning sign in it.

When displaying fonts, what’s the difference between pixels, points and ems?
A pixel is the lowest-resolution dot the computer monitor supports. Its size depends on user’s settings and monitor size. A point is always 1/72 of an inch. An em is the number of pixels that it takes to display the letter M.

Accenture Microsoft.NET Interview Questions and Answers

1/20/2012 No Comment
Accenture DotNet Interview Questions and Answers

What event can you subscribe to if you want to display information from SQL Print statements?
NOTE: This is objective type question, Please click question title for correct answer.

Q1. Explain the differences between Server-side and Client-side code?
Ans. Server side code will execute at server (where the website is hosted) end, & all the business logic will execute at server end where as client side code will execute at client side (usually written in javascript, vbscript, jscript) at browser end.

Q2. What type of code (server or client) is found in a Code-Behind class?
Ans. Server side code.

Q3. How to make sure that value is entered in an asp:Textbox control?
Ans. Use a RequiredFieldValidator control.

Q4. Which property of a validation control is used to associate it with a server control on that page?
Ans. ControlToValidate property.

Q5. How would you implement inheritance using VB.NET & C#?
Ans. C# Derived Class : Baseclass
VB.NEt : Derived Class Inherits Baseclass


Q6. Which method is invoked on the DataAdapter control to load the generated dataset with data? Ans. Fill() method.


Q7. What method is used to explicitly kill a user's session?
Ans. Session.Abandon()


Q8. What property within the asp:gridview control is changed to bind columns manually?
Ans. Autogenerated columns is set to false

Q9. Which method is used to redirect the user to another page without performing a round trip to the client?
Ans. Server.Transfer method.


Q10. How do we use different versions of private assemblies in same application without re-build? Ans.Inside the Assemblyinfo.cs or Assemblyinfo.vb file, we need to specify assembly version.
assembly: AssemblyVersion

Difference between VB.NET and C#.
Difference between VB.NET and C#.
VB.NET :
-----------

1)no unsigned int
2)Loosely typed language
3)no operator overloading
4)no pointers
5)no auto XML documentation


C#.net :
-------------
1) supports unsigned int
2)strongly typed language
3)supports operator overloading
4)supports pointers
5)supports auto XML documentation

Name a feature which is common to all .NET languages?
Name a feature which is common to all .NET languages?
There is only one feature which is common to all languages and that is Garbage collection or GC. This feature is automated which relieves developers of much work. This garbage is disposed only when there is need of memory or stress for memory. GC feature halts the application for few seconds before restarting it.

What is the difference between Master- Detail view and MVG?
Following are the main advantages:-
1) MVG Makes effective use of the space.
2) Multiple set of detail records can be viewed from a single
view

If I write System.exit (0); at the end of the try block, will the finally block still execute ?
No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never executes.

whats the similarilty & difference between .dll extension and .exe extension files?
A standard exe application is one that is created using Standard EXE project. It is the most widely used Project type using VB6. Standard EXE application is normally the most widely used among the available Project types in Visual Basic. Stand-alone programs have an .EXE file extension.

Usage A standard EXE application is normally used when you want to develop a stand-alone application. Examples include calculators, text editors, and other similar applications.

An ActiveX EXE application is one that is created using ActiveX EXE project. ActiveX EXE are widely used in conjunction with standard EXE applications. There are three types of widely used of ActiveX projects. These are:

a. ActiveX EXE
b. ActiveX DLL
c. ActiveX Control

ActiveX EXE: Unlike a stand-alone EXE file, an ActiveX EXE file is designed to work as an OLE server, which is nothing more than a program designed to share information with another program. It has an .EXE file extension.

ActiveX DLL: ActiveX DLL files are not meant to be used by themselves. Instead, these types of files contain subprograms designed to function as building blocks when creating a stand-alone program. It has a .DLL file extension.

ActiveX Control: Unlike an ActiveX DLL or ActiveX EXE file, an ActiveX Control file usually provides both subprograms and a user interface that you can reuse in other programs. It has an .OCX file extension.

Usage
1. The ActiveX EXE/DLL is normally used when you need to build a component that is separate from the main program. The concept is based on COM model.

2. ActiveX DLL/EXE allows multiple applications to share the same code. This allows for scalability of programs, and saves time because you only need to write the code once.

3. ActiveX DLLs and ActiveX EXEs are almost same in the ways they are built and used. In either case, you build one or more classes that applications can use to do something.

4. One of the main differences between ActiveX EXE and an ActiveX DLL's is that the code is executed within the main program's address space for ActiveX DLL. This is because the code lies inside the program's address space, calling methods and execution of code is very fast.

Differences

An ActiveX Exe provides the reusability of code, by accessing it from different clients.

An ActiveX Exe is a component that can be called by another application by providing a reference to the component. But a Standard Exe application cannot be called in this way.

An ActiveX EXE's code is run in a separate process. When the main program calls an ActiveX EXE's method, the application passes required parameters into the ActiveX EXE's and calls the method. The ActiveX EXE, upon execution may return the results to the main program. This is slower than running an ActiveX DLL's method inside the main program's address space.

Advanced .NET Interview Questions Answers Explanations

1/17/2012 No Comment

What's the advantage of using System.Text.StringBuilder over System.String?
StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it's being operated on, a new instance is created.

What's a satellite assembly?
When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.


What is the difference between the value-type variables and reference-type variables in terms of garbage collection?
The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null.

What's the difference between the Debug class and Trace class?
Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds

How does CAS work?
The CAS security policy revolves around two key concepts - code groups and permissions. Each .NET assembly is a member of a particular code group, and each code group is granted the permissions specified in a named permission set.
For example, using the default security policy, a control downloaded from a web site belongs to the 'Zone - Internet' code group, which adheres to the permissions defined by the 'Internet' named permission set. (Naturally the 'Internet' named permission set represents a very restrictive range of permissions.)

How does assembly versioning work?
Each assembly has a version number called the compatibility version. Also each reference to an assembly (from another assembly) includes both the name and version of the referenced assembly.The version number has four numeric parts (e.g. 5.5.2.33). Assemblies with either of the first two parts different are normally viewed as incompatible. If the first two parts are the same, but the third is different, the assemblies are deemed as 'maybe compatible'. If only the fourth part is different, the assemblies are deemed compatible. However, this is just the default guideline - it is the version policy that decides to what extent these rules are enforced. The version policy can be specified via the application configuration file.

Why string is called Immutable data Type?
The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is formed & the start address is changed. Thus keeping the Old string in Memory for Garbage Collector to be disposed.

What is side-by-side execution? Can two application one using private assembly and other using Shared assembly be stated as a side-by-side executables?
Side-by-side execution is the ability to run multiple versions of an application or component on the same computer. You can have multiple versions of the common language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time. Since versioning is only applied to shared assemblies, and not to private assemblies, two application one using private assembly and one using shared assembly cannot be stated as side-by-side executables

Tell me a method to access a COM dll in .NET?
We can create a interop dll of COM to access in .NET

What is the class to access FTP?
FtpWebRequest

Can you please tell me about the typed dataset?
A typed dataset will be having the sehema with them as in an xml format.
It raises the compile time exceptions. Arranging data and giving relationship is possible through this.

How do we store the same named assemblies in GAC? Whether its possible?
Yes it is possible. By different versions of assembly we can store.

.NET Basics Interview Question Answers

10/14/2011 No Comment
What is strong name?
A name that consists of an assembly's identity—its simple text name, version number, and culture information (if provided)—strengthened by a public key and a digital signature generated over the assembly.

What is managed code and managed data?
We can describe this Manage code like, if a code running under the control CLR, then we can call it as Managed Code.

Managed code is code that is written to target the services of the common language runtime (see what is CLR?). In order to target these services, the code must provide a minimum level of information (metadata) to the runtime. All C# (when not using the unsafe keyword), Visual Basic .NET, J#, and JScript .NET code is managed by default. Visual Studio .NET C++ code is not managed by default, but the compiler can produce managed code by specifying a Command-line switch (/CLR).

Closely related to managed code is managed data—data that is allocated and reallocated by the common language runtime's garbage collector. C#, Visual Basic.NET, J# and JScript .NET data is managed by default. C# data can, however, be marked as unmanaged through the use of special keywords. Visual Studio .NET C++ data is unmanaged by default (even when using the /CLR switch), but when using Managed Extensions for C++, a class can be marked as managed by using the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector. In addition, the class becomes a full participating member of the .NET Framework community, with all of the benefits and restrictions that brings. An example of a benefit is proper interoperability with classes written in other languages (for example, a managed C++ class can inherit from a Visual Basic.NET class). An example of a restriction is that a managed class can only inherit from one base class. Any restrictions, such as this one, are designed to prevent common programming errors.

What is the Microsoft Intermediate Language (MSIL)?
MSIL is the Machine independent Code into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects. Combined with metadata and the common type system, MSIL allows for true cross language integration. Prior to execution, MSIL is converted to machine code via CLR’s Just-in-Time (JIT) compiler.

What is the common type system (CTS)?
The common type system (CTS) is a rich type system, built into the common language runtime (CLR) that supports the types and operations found in most of .NET programming languages. The common type system supports the complete implementation of a wide range of programming languages.

What is the common language runtime (CLR)?
The common language runtime (CLR) is major component in the .NET Framework and it is the execution engine for .NET Framework applications.

It is responsible for proving the number of services, including the following:
1. Code management (loading and execution)
2. Verification of type safety
3. Conversion of Microsoft Intermediate Language (MSIL) to native code
4. Access to metadata (enhanced type information)
5. Managing memory for managed objects
6. Enforcement of code access security (See what is code access security?)
7. Exception handling, including cross-language exceptions
8. Interoperation between managed code, COM objects, and pre-existing DLLs (unmanaged code and data)
9. Automation of object layout
10. Support for developer services (profiling, debugging, and so on)

What is GC in NET Framework?
The .NET Framework's garbage collector manages the allocation and release of memory for your application. Each time you use the new operator to create an object, the runtime allocates memory for the object from the managed heap. As long as address space is available in the managed heap, the runtime continues to allocate space for new objects. However, memory is not infinite. Eventually the garbage collector must perform a collection in order to free some memory. The garbage collector's optimizing engine determines the best time to perform a collection, based upon the allocations being made. When the garbage collector performs a collection, it checks for objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their memory.

From the following which datatype is not supported in RangeValidator?

What does the "EnableViewState" property do? Why would I want it on or off?
It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in viewstate.

What is the Global.asax used for?
The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.

What’s the difference between Response.Write() andResponse.Output.Write()?
Response.Output.Write() allows you to write formatted output.

What is the Difference between Web.config and Machine.config?
Scope:
Web.config => For particular application in IIS.
Machine.config = > For All the applications in IIS
Created:
Web.config => Created when you create an application
Machine.config => Create when you install Visual Studio
Known as:
Web.config => is known as Application Level configuration file
Machine.config => is known as Machine level configuration file
Location:
Web.config => In your application Directory
Machine.config => …\Microsoft.NET\Framework\(Version)\ CONFIG

Advantages of Crystal Reports
Advantages of Crystal Reports

Some of the major advantages of using Crystal Reports are:
1. Rapid report development since the designer interface would ease the coding work for the programmer.
2. Can extend it to complicated reports with interactive charts and enhance the understanding of the business model
3. Exposes a report object model, can interact with other controls on the ASP.NET Web form
4. Can programmatically export the reports into widely used formats like .pdf, .doc, .xls, .html and .rtf

.NET Specific Interview Question Answers

10/14/2011 No Comment
What are the Expansions of MSIL, JIT, CLR, CTS, CLS, RCW?
1. MSIL - Microsoft Intermediate Language.
2. JIT - Just-In-Time compiler .
3. CLR - Common Language Runtime.
4. CTS - Common Type System.

5. CLS - Common Language Specification.
6. RCW - Runtime Callable Wrapper.

Which NameSpace is used to get the information of events about the system, devices like Hard disk serial No, Operating System and Processor?
NOTE: This is objective type question, Please click question title for correct answer.

Which design pattern is implemented in the below code snippet? using System; public class MyClass { private static MyClass instance; private MyClass() {} public static MyClass Instance { get { if (instance == null) { instance = new MyClass(); } return instance; } } }
Posted by: Peermohamedmydeen
NOTE: This is objective type question, Please click question title for correct answer.

What is equivalent for regsvr32.exe in .NET?
In .NET we have regasm to register and unregister assemblies through .NET.

What is Covariance and Contravariance ?
Assigning a string to an object from specific type to a more general type is called covariance.

In contrast, assigning an array of objects to an array of strings, from general type to a more specific type, is referred to as contravariance.

Sorting on a Datatable
By using a datatable we can sort the data with out going for a dataview.

DataTable dt = new DataTable();
dt.Select(" select criteria if any " , " sort string ")

What is a DependencyProperty and How to implement it?
DependencyProperty is set to enable declarative code to alter the properties of an object which reduces the data requirements by providing a more powerful notification system regarding the change of data in a very specific way. In .NET, there are two types of properties. One is the normal property & another is the DependencyProperty which has added functionality over the normal property.

Now, let us discuss on how to implement such DependencyProperty to give a powerful notification on data change:

First of all, implement the UserControl class from INotifyPropertyChanged interface:

public partial class MyUserControl : UserControl, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
Create your own normal Property, lets say the name of the property is “Caption”.

public string Caption
{
get { return GetValue(CaptionProperty).ToString(); }
set { SetValue(CaptionProperty, value); }
}
Now, register the DependencyProperty to the CLR by calling the Register method by passing the property field that you used to store the data in earlier step:

public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(MyUserControl), new PropertyMetadata(string.Empty, OnCaptionPropertyChanged));

The name of the identifier field of the DependencyProperty will be same as you used in the property after appending “Property” at the end. In this example, our Property name is “Caption”, hence our identifier field name is “CaptionProperty”. Add the PropertyMetaData with default value & callback event handler within the Register method as mentioned in the above code. Mark the identifier as static & readonly so that this will be unique to the CLR.

Now, implement the OnCaptionPropertyChanged event handler:

private static void OnCaptionPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
MyUserControl myUserControl = dependencyObject as MyUserControl;
myUserControl.OnPropertyChanged("Caption");
myUserControl.OnCaptionPropertyChanged(e);
}

private void OnCaptionPropertyChanged(DependencyPropertyChangedEventArgs e)
{
txbCaption.Text = Caption;
}

The implementation of the DependencyProperty is complete. You can either call it from XAML:

or from Code behind:
MyUserControl myUserControl = new MyUserControl();
myUserControl.SetValue(MyUserControl.CaptionProperty, "My First Dependency Property Example");

How can we open the disassembler from Dot Net Command prompt ?
ILDASM (Intermediate Language Disassembler) is installed along with Visual Studio. You can found it inside the Visual Studio SDK Folder.
Version folder name will be depends on your .NET Framework version.
As for Example,
C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\
Now With the help of command

ILDASM
we can open it from Visual Studio Command Prompt.
We can open the ibuilt disassembler provided with framework to check the assembly information.

Which namespace is used to create an Exception Tree?
System.Data.Common.CommandTree namespace provide classes to create an Exception Tree.

Which namespace is used to work with RSS feeds in .NET?
System.ServiceModel.Syndication namespace is used to work with RSS feeds in .NET.

Which class is the base class of all the exception classes?
System.Exception class is the base class of all the exception classes in .NET.

What is the use of System.SystemException namespace?
System.SystemException provide different classes to handle fatal as well as non fatal errors.

Microsoft .NET Framework Basic Questions asked in a job interview

7/25/2011 No Comment
What is the Microsoft.NET?
.NET is a set of technologies designed to transform the internet into a full scale distributed platform. It provides new ways of connecting systems, information and devices through a collection of web services. It also provides a language independent, consistent programming model across all tiers of an application.
The goal of the .NET platform is to simplify web development by providing all of the tools and technologies that one needs to build distributed web applications.

What is CLS?
Common Language Specification (CLS) defines the rules and standards to which languages must adhere to in order to be compatible with other .NET languages. This enables C# developers to inherit from classes defined in VB.NET or other .NET compatible languages.

What is managed code?
The .NET Framework provides a run-time environment called the Common Language Runtime, which manages the execution of code and provides services that make the development process easier. Compilers and tools expose the runtime's functionality and enable you to write code that benefits from this managed execution environment. The code that runs within the common language runtime is called managed code.

What is the .NET Framework?
The .NET Framework is set of technologies that form an integral part of the .NET Platform. It is Microsoft's managed code programming model for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes.

The .NET Framework has two main components: the common language runtime (CLR) and .NET Framework class library. The CLR is the foundation of the .NET framework and provides a common set of services for projects that act as building blocks to build up applications across all tiers. It simplifies development and provides a robust and simplified environment which provides common services to build application. The .NET framework class library is a collection of reusable types and exposes features of the runtime. It contains of a set of classes that is used to access common functionality.

What is CLR?
The .NET Framework provides a runtime environment called the Common Language Runtime or CLR. The CLR can be compared to the Java Virtual Machine or JVM in Java. CLR handles the execution of code and provides useful services for the implementation of the program. In addition to executing code, CLR provides services such as memory management, thread management, security management, code verification, compilation, and other system services. It enforces rules that in turn provide a robust and secure execution environment for .NET applications.

What is CTS?
Common Type System (CTS) describes the datatypes that can be used by managed code. CTS defines how these types are declared, used and managed in the runtime. It facilitates cross-language integration, type safety, and high performance code execution. The rules defined in CTS can be used to define your own classes and values.
 What is MSIL?
When the code is compiled, the compiler translates your code into Microsoft intermediate language (MSIL). The common language runtime includes a JIT compiler for converting this MSIL then to native code.
MSIL contains metadata that is the key to cross language interoperability. Since this metadata is standardized across all .NET languages, a program written in one language can understand the metadata and execute code, written in a different language. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations.

What is JIT?
JIT is a compiler that converts MSIL to native code. The native code consists of hardware specific instructions that can be executed by the CPU.
Rather than converting the entire MSIL (in a portable executable[PE]file) to native code, the JIT converts the MSIL as it is needed during execution. This converted native code is stored so that it is accessible for subsequent calls.

What is portable executable (PE)?
PE is the file format defining the structure that all executable files (EXE) and Dynamic Link Libraries (DLL) must use to allow them to be loaded and executed by Windows. PE is derived from the Microsoft Common Object File Format (COFF). The EXE and DLL files created using the .NET Framework obey the PE/COFF formats and also add additional header and data sections to the files that are only used by the CLR.

How does an AppDomain get created?
AppDomains are usually created by hosts. Examples of hosts are the Windows Shell, ASP.NET and IE. When you run a .NET application from the command-line, the host is the Shell. The Shell creates a new AppDomain for every application. AppDomains can also be explicitly created by .NET applications.

What is an assembly?
An assembly is a collection of one or more .exe or dll’s. An assembly is the fundamental unit for application development and deployment in the .NET Framework. An assembly contains a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the CLR with the information it needs to be aware of type implementations.

What are the contents of assembly?
A static assembly can consist of four elements:
· Assembly manifest - Contains the assembly metadata. An assembly manifest contains the information about the identity and version of the assembly. It also contains the information required to resolve references to types and resources.
· Type metadata - Binary information that describes a program.
· Microsoft intermediate language (MSIL) code.
· A set of resources.

What are the different types of assembly?
Assemblies can also be private or shared. A private assembly is installed in the installation directory of an application and is accessible to that application only. On the other hand, a shared assembly is shared by multiple applications. A shared assembly has a strong name and is installed in the GAC.
We also have satellite assemblies that are often used to deploy language-specific resources for an application.

What is an application domain?
Application domain is the boundary within which an application runs. 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.

What is a dynamic assembly?
A dynamic assembly is created dynamically at run time when an application requires the types within these assemblies.

What is a strong name?
You need to assign a strong name to an assembly to place it in the GAC and make it globally accessible. A strong name consists of a name that consists of an assembly's identity (text name, version number, and culture information), a public key and a digital signature generated over the assembly. The .NET Framework provides a tool called the Strong Name Tool (Sn.exe), which allows verification and key pair and signature generation.

What is GAC? What are the steps to create an assembly and add it to the GAC?
The global assembly cache (GAC) is a machine-wide code cache that stores assemblies specifically designated to be shared by several applications on the computer. You should share assemblies by installing them into the global assembly cache only when you need to.
Steps
- Create a strong name using sn.exe tool eg: sn -k mykey.snk
- in AssemblyInfo.cs, add the strong name eg: [assembly: AssemblyKeyFile("mykey.snk")]
- recompile project, and then install it to GAC in two ways :
· drag & drop it to assembly folder (C:\WINDOWS\assembly OR C:\WINNT\assembly) (shfusion.dll tool)
· gacutil -i abc.dll

What is the caspol.exe tool used for?
The caspol tool grants and modifies permissions to code groups at the user policy, machine policy, and enterprise policy levels.

What are generations and how are they used by the garbage collector?
Generations are the division of objects on the managed heap used by the garbage collector. This mechanism allows the garbage collector to perform highly optimized garbage collection. The unreachable objects are placed in generation 0, the reachable objects are placed in generation 1, and the objects that survive the collection process are promoted to higher generations.

What is Ilasm.exe used for?
Ilasm.exe is a tool that generates PE files from MSIL code. You can run the resulting executable to determine whether the MSIL code performs as expected.

What is Ildasm.exe used for?
Ildasm.exe is a tool that takes a PE file containing the MSIL code as a parameter and creates a text file that contains managed code.

What is a garbage collector?
A garbage collector performs periodic checks on the managed heap to identify objects that are no longer required by the program and removes them from memory.

What is the ResGen.exe tool used for?
ResGen.exe is a tool that is used to convert resource files in the form of .txt or .resx files to common language runtime binary .resources files that can be compiled into satellite assemblies.

Some .NET Interview Question Answers

7/14/2011 No Comment
What is an application server?
An application server is a software engine that delivers applications to client computers or devices. The application server runs your server code. Some well known application servers are IIS (Microsoft), WebLogic Server (BEA), JBoss (Red Hat), WebSphere (IBM).

Compare C# and VB.NET

What is a base class and derived class?
A class is a template for creating an object. The class from which other classes derive fundamental functionality is called a base class. For e.g. If Class Y derives from Class X, then Class X is a base class.

The class which derives functionality from a base class is called a derived class. If Class Y derives from Class X, then Class Y is a derived class.

What is an extender class?
An extender class allows you to extend the functionality of an existing control. It is used in Windows forms applications to add properties to controls.
A demonstration of extender classes can be found over here.

What is inheritance?
Inheritance represents the relationship between two classes where one type derives functionality from a second type and then extends it by adding new methods, properties, events, fields and constants.

C# support two types of inheritance:
· Implementation inheritance
· Interface inheritance

What is implementation and interface inheritance?
When a class (type) is derived from another class(type) such that it inherits all the members of the base type it is Implementation Inheritance.
When a type (class or a struct) inherits only the signatures of the functions from another type it is Interface Inheritance.
In general Classes can be derived from another class, hence support Implementation inheritance. At the same time Classes can also be derived from one or more interfaces. Hence they support Interface inheritance.

What is inheritance hierarchy?
The class which derives functionality from a base class is called a derived class. A derived class can also act as a base class for another class. Thus it is possible to create a tree-like structure that illustrates the relationship between all related classes. This structure is known as the inheritance hierarchy.

How do you prevent a class from being inherited?
In VB.NET you use the NotInheritable modifier to prevent programmers from using the class as a base class. In C#, use the sealed keyword.

When should you use inheritance?

Define Overriding?
Overriding is a concept where a method in a derived class uses the same name, return type, and arguments as a method in its base class. In other words, if the derived class contains its own implementation of the method rather than using the method in the base class, the process is called overriding.

Can you use multiple inheritance in .NET?
.NET supports only single inheritance. However the purpose is accomplished using multiple interfaces.

Why don’t we have multiple inheritance in .NET?
There are several reasons for this. In simple words, the efforts are more, benefits are less. Different languages have different implementation requirements of multiple inheritance. So in order to implement multiple inheritance, we need to study the implementation aspects of all the languages that are CLR compliant and then implement a common methodology of implementing it. This is too much of efforts. Moreover multiple interface inheritance very much covers the benefits that multiple inheritance has.

What is an Interface?
An interface is a standard or contract that contains only the signatures of methods or events. The implementation is done in the class that inherits from this interface. Interfaces are primarily used to set a common standard or contract.

When should you use abstract class vs interface or What is the difference between an abstract class and interface?
I would suggest you to read this. There is a good comparison given over here.

What are events and delegates?
An event is a message sent by a control to notify the occurrence of an action. However it is not known which object receives the event. For this reason, .NET provides a special type called Delegate which acts as an intermediary between the sender object and receiver object.

What is business logic?
It is the functionality which handles the exchange of information between database and a user interface.

What is a component?
Component is a group of logically related classes and methods. A component is a class that implements the IComponent interface or uses a class that implements IComponent interface.

What is a control?
A control is a component that provides user-interface (UI) capabilities.

What are the differences between a control and a component?

What are design patterns?
Design patterns are common solutions to common design problems.

What is a connection pool?
A connection pool is a ‘collection of connections’ which are shared between the clients requesting one. Once the connection is closed, it returns back to the pool. This allows the connections to be reused.

What is a flat file?
A flat file is the name given to text, which can be read or written only sequentially.

Sample Microsoft .NET Interview Question Answers

7/04/2011 No Comment
Which namespace provides classes for Regular Expression?
System.Text.RegularExpressions namespace provides classes for Regular Expression

Which file sets the environment variables for Visual Studio?
The vsvars32.bat sets the environment variables for Visual Studio. You can find it from %Microsoft Visual Studio 2008\Common7\Tools\vsvars32.bat.

When you start the Visual Studio 2008 command prompt it automatically runs vsvars32.bat.

Which assembly is used for Mobile web application?
System.Web.Mobile

what namespace is used for the controls in a mobile web application?
System.Web.UI.MobileControls

what is Reflection?
Reflection is the feature in .Net, which enables us to get some information about object in runtime. That information contains data of the class. Also it can get the names of the methods that are inside the class and constructors of that object.

program should use the reflection derived from namespace System.Reflection .
using reflection can dynamically load assembly.

What are the elements inside an assembly?
A .NET assembly consists of the following elements,
A Win32 File Header
A CLR file header
CIL code
Type Metadata
An assembly manifest
Optional embedded resources

What is the namespace to use LINQ to XML?
System.Xml.XLinq

What is the role of compiler?
Compiler translates a high level language into machine language.

Which namespace is used to create a multi-threaded application?
System.Threading

Why HashTable is used
It is a .NET class that allows an element to be accessed using a unique key. It is mainly used in database programming.

What is the base class for all .NET classes?
System.Object

What is an Assembly in .NET?
When you compile an application, the MSIL code created is stored in an assembly.Assemblies include both executable application files(.exe files)& libraries(.dll extension)for use by other application.

In addition to containing MSIL,assemblies also include met information(i.e. information about the information contained in assembly,also called as meta-data)and optional resources(sound and picture file, etc).The meta information enables assemblies to be fully self-descriptive.You need no other information to use an assembly,meaning you avoid situations such as failing to odd required data to the system registry and so on,which was often a problem when developing with other platforms.

Microsoft .NET Interview Question Answers - 4

6/20/2011 No Comment
Microsoft .NET Interview Question Answers collected from various sources.Please leave comments and your suggestions

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.

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.

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 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
class.
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.

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
user.
Below is the config snippet which defines for how much time the message should be in
queue.

.NET 4.0 Framework Interview Questions and Answers

3/15/2011 No Comment
Microsoft.NET 4.0 Framework Interview Questions and Answers,Net framework 4.0 Interview Questions,.Net Framework 4.0 – A Parallel – Programming Initiative,.NET Framework Interview questions

Where do I get .Net 4.0 from?

You can download .NET 4.0 beta from http://www.microsoft.com/downloads/details.aspx?FamilyID=ee2118cc-51cd-46ad-ab17-af6fff7538c9&displaylang=en 

What are the important new features in .NET 4.0?

Rather than walking through the 100 new features list, let's concentrate on the top 3 features which we think are important.
. Windows work flow and WCF 4.0:- This is a major change in 4.0. In WCF they have introduced simplified configuration, discovery, routing service, REST improvements and workflow services. In WWF they have made changes to the core programming model of workflow. Programming model has been made more simple and robust. The biggest thing is the integration between WCF and WWF.

. Dynamic Language runtime: - DLR adds dynamic programming capability to .NET 4.0 CLR. We will talk more about it as this FAQ moves ahead.

. Parallel extensions: - This will help to support parallel computing for multi-core systems. .NET 4.0 has PLINQ in the LINQ engine to support parallel execution. TPL (Task parallel library) is introduced which exposes parallel constructs like parallel 'For' and 'ForEach' loops, using regular method calls and delegates. We will be talking in more details of the above features in the coming sections.

What's the most important new feature of .NET 4.0?

WCF and WWF new features are one of the most interesting features of all. Especially the new programming model of WWF and its integration with WCF will be an interesting thing to watch.
DLR, parallel programming and other new features somehow just seem to be brownie points rather than compelling features.

What is DLR in .NET 4.0 framework?

DLR (Dynamic language runtime) is set of services which add dynamic programming capability to CLR. DLR makes dynamic languages like LISP, Javascript, PHP,Ruby to run on .NET framework.


There are two types of languages statically typed languages and dynamically typed languages. In statically typed languages you need to specify the object during design time / compile time. Dynamically typed languages can identify the object during runtime. .NET . DLR helps you to host code written in dynamic languages on top of your CLR.

Due to DLR runtime, dynamic languages like ruby, python, JavaScript etc can integrate and run seamlessly with CLR. DLR thus helps to build the best experience for your favorite dynamic language. Your code becomes much cleaner and seamless while integrating with the dynamic languages.

Integration with DLR is not limited to dynamic languages. You can also call MS office components in a much cleaner way by using COM interop binder.
One of the important advantages of DLR is that it provides one central and unified subsystem for dynamic language integration.

Can you give more details about DLR subsystem?

DLR has 3 basic subsystems:-
. Expression trees: - By this we can express language semantics in form of AST (Abstract syntax tree). DLR dynamically generates code using the AST which can be executed by the CLR runtime. An expression tree is a main player which helps to run various dynamic languages javascript, ruby with CLR. . Call site caching: - When you make method calls to dynamic objects DLR caches information about those method calls. For the other subsequent calls to the method DLR uses the cache history information for fast dispatch.
. Dynamic object interoperability (DOI):- DOI has set of classes which can be used to create dynamic objects. These classes can be used by developers to create classes which can be used in dynamic and static languages.
We will be covering all the above features in more detail in the coming FAQ sections.

How can we consume an object from dynamic language and expose a class to dynamic languages?

To consume a class created in DLR supported dynamic languages we can use the 'Dynamic' keyword. For exposing our classes to DLR aware languages we can use the 'Expando' class.
So when you want to consume a class constructed in Python , Ruby , Javascript , COM languages etc we need to use the dynamic object to reference the object. If you want your classes to be consumed by dynamic languages you need to create your class by inheriting the 'Expando' class. These classes can then be consumed by the dynamic languages. We will be seeing both these classes in the coming section.
Do not forget to download help document for library authors regarding how to enable the dynamic language across platform using DLR.

Can we see a sample of 'Dynamic' objects?

We had already discussed that 'Dynamic' objects helps to consume objects which are created in dynamic languages which support DLR.The dynamic keyword is a part of dynamic object interoperability subsystem.
If you assign an object to a dynamic type variable (dynamic x=new SomeClass()), all method calls, property invocations, and operator invocations on 'x' will be delayed till runtime, and the compiler won't perform any type checks for 'x' at compile time.
Consider the below code snippet where we are trying to do method calls to excel application using interop services.
// Get the running object of the excel application
object objApp = System.Runtime.InteropServices.Marshal.GetActiveObject
("Excel.Application");
// Invoke the member dynamically
object x = objApp.GetType().InvokeMember("Name", System.Reflection.
BindingFlags.GetProperty, 
null, objApp, null);
// Finally get the value by type casting
MessageBox.Show(x.ToString());
The same code we now write using 'dynamic' keyword.
// Get the object using 
dynamic objApp1 = System.Runtime.InteropServices.Marshal.
GetActiveObject("Excel.Application");
// Call the 
MessageBox.Show(objApp1.Name);
You can clearly notice the simplification of property invocation syntax. The 'invokemember' is pretty cryptic and prone to errors. Using 'dynamic' keyword we can see how the code is simplified.

If you try to view the properties in VS IDE you will see a message stating that you can only evaluate during runtime.

What's the difference between 'Dynamic', 'Object' and reflection?

Many developers think that 'Dynamic' objects where introduced to replace to 'Reflection' or the 'Object' data type. The main goal of 'Dynamic' object is to consume objects created in dynamic languages seamlessly in statically typed languages. But due to this feature some of its goals got overlapped with reflection and object data type.
Eventually it will replace reflection and object data types due to simplified code and caching advantages. The main goal of dynamic object was never introduced in the first place to replace 'reflection' or object data type, but due to overlapping features it did.
Dynamic
Object / Reflection
Dynamic object is a small feature provided in the DLR engine by which we can make calls to objects created in dynamic languages. The big picture is the DLR which helps to not only to consume, but also your classes can be exposed to dynamic languages.
Reflection and Object type is only meant for referencing types whose functions and methods are not know during runtime. Reflection and object type do not help to expose your classes to other languages. They are purely meant to consume objects whose methods are known until runtime.
Syntax code is quiet clean
Syntax has a bit of learning curve.
Performance is improved due to caching of method calls.
No caching of method calls exists currently.

What are the advantages and disadvantage of dynamic keyword?

We all still remember how we talked bad about VB6 (Well I loved the language) variant keyword and we all appreciated how .NET brought in the compile time check feature, well so why are we changing now.
Well, bad developers will write bad code with the best programming language and good developers will fly with the worst programming language. Dynamic keyword is a good tool to reduce complexity and it's a curse when not used properly.
So advantages of Dynamic keyword:-
. Helps you interop between dynamic languages.
. Eliminates bad reflection code and simplifies code complexity. . Improves performance with method call caching.
Disadvantages:-
. Will hit performance if used with strongly typed language.

Advanced Dot Net Interview Questions

10/18/2010 No Comment
Advanced Dot Net Interview Questions,Interview questions : Advanced C# questions
What do you mean by three-tier architecture?

The three-tier architecture was comes into existence to improve management of code and contents and to improve the performance of the web based applications. There are mainly three layers in three-tier architecture. the are define as follows

(1)Presentation
(2)Business Logic

(3)Database

(1)First layer Presentation contains mainly the interface code, and this is shown to user. This code could contain any technology that can be used on the client side like HTML, JavaScript or VBScript etc.

(2)Second layer is Business Logic which contains all the code of the server-side .This layer have code to interact with database and to query, manipulate, pass data to user interface and handle any input from the UI as well.

(3)Third layer Data represents the data store like MS Access, SQL Server, an XML file, an Excel file or even a text file containing data also some additional database are also added to that layers.

Does .NET CLR and SQL SERVER run in different process?


Dot Net CLR and all .net realtes application and Sql Server run in same process or we can say that that on the same address because there is no issue of speed because if these two process are run in different process then there may be a speed issue created one process goes fast and other slow may create the problem.

The IHttpHandler and IHttpHandlerFactory interfaces ?


The IHttpHandler interface is implemented by all the handlers. The interface consists of one property called IsReusable. The IsReusable property gets a value indicating whether another request can use the IHttpHandler instance. The method ProcessRequest() allows you to process the current request. This is the core place where all your code goes. This method receives a parameter of type HttpContext using which you can access the intrinsic objects such as Request and Response. The IHttpHandlerFactory interface consists of two methods - GetHandler and ReleaseHandler. The GetHandler() method instantiates the required HTTP handler based on some condition and returns it back to ASP.NET. The ReleaseHandler() method allows the factory to reuse an existing handler.


When not to use Design Patterns


Do not use design patterns in any of the following situations.

• When the software being designed would not change with time.
• When the requirements of the source code of the application are unique.

When to use Design Patterns


Design Patterns are particularly useful in one of the following scenarios.

• When the software application would change in due course of time.
• When the application contains source code that involves object creation and event notification.

Benefits of Design Patterns


The following are some of the major advantages of using Design Patterns in software development.

• Flexibility
• Adaptability to change
• Reusability

What are Design Patterns?


A Design Pattern essentially consists of a problem in a software design and a solution to the same. In Design Patterns each pattern is described with its name, the motivation behind the pattern and its applicability.
According to MSDN, "A design pattern is a description of a set of interacting classes that provide a framework for a solution to a generalized problem in a specific context or environment. In other words, a pattern suggests a solution to a particular problem or issue in object-oriented software development.

Explain about Generics?


Generics are not a completely new construct; similar concepts exist with other languages. For example, C++ templates can be compared to generics. However, there's a big difference between C++ templates and .NET generics. With C++ templates the source code of the template is required when a template is instantiated with a specific type. Contrary to C++ templates, generics are not only a construct of the C# language; generics are defined with the CLR. This makes it possible to instantiate generics with a specific type in Visual Basic even though the Generic class was defined with C#.

Describe the Provider Model in ASP.NET 2.0?


The Provider model in ASP.NET 2.0 is based on the Provider Design Pattern that was created in the year 2002 and later implemented in the .NET Framework 2.0.

The Provider Model supports automatic creation of users and their respective roles by creating entries of them directly in the SQL Server (May even use MS Access and other custom data sources). So actually, this model also supports automatically creating the user table's schema.

The Provider model has 2 security providers in it: Membership provider and Role Provider. The Membership provider saves inside it the user name (id) and corresponding passwords, whereas the Role provider stores the Roles of the users.

For SQL Server, the SqlMembershipProvider is used, while for MS Access, the AccessMembershipProvider is used. The Security settings may be set using the website adminstration tool. Automatically, the AccessMembershipProvider creates a Microsoft Access database file named aspnetdb.mdb inside the application's App_Data folder. This contains 10 tables.


In Assembly which work as GacBrowser ?


The GACPicker class allows the user to select an assembly from the Global assembly Cache. It does this by looking at the filesystem representation of the GAC, since there appears to be no actual API in the current .NET environment.

What are the consideration in deciding to use .NET Remoting or ASP.NET Web Services?


Remoting is a more efficient communication exchange when you can control both ends of the application involved in the communication process. Web Services provide an open-protocol-based exchange of informaion. Web Services are best when you need to communicate with an external organization or another (non-.NET) technology.


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.

Can you define what is SharePoint and some overview about this ?


SharePoint helps workers for creating powerful personalized interfaces only by dragging and drop pre-defined Web Part Components. And these Web Parts components also helps non programmers to get information which care and customize the appearance of Web pages. To under stand it we take an example one Web Part might display a user's information another might create a graph showing current employee status and a third might show a list of Employees Salary. This is also possible that each functions has a link to a video or audio presentation.So now Developers are unable to create these Web Part components and make them available to SharePoint users.
 

Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer