2/17/09

Dot Net Interview Questions

Author: ngocbd
• Tuesday, December 30th, 2008

1.What is a stack? What is a heap?

Ans : Stack is a place in the memory where value types are stored. Heap is a place in the memory where the reference types are stored.

2.What is Boxing/Unboxing?

Ans : Boxing is used to convert value types to object.
E.g. int x = 1;
object obj = x ;
Unboxing is used to convert the object back to the value type.
E.g. int y = (int)obj;

3.What is globalization?

Ans : Globalization is the process of customizing applications that support multiple cultures and regions.

4.What is localization?

Ans : Localization is the process of customizing applications that support a given culture and regions.

5.What is Ilasm.exe used for?

Ans : 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.

6.What is Ildasm.exe used for?

Ans : 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.

7.What is the ResGen.exe tool used for?

Ans : 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.

8.What happens when you change the web.config file at run time?

Ans : ASP.NET invalidates the existing cache and assembles a new cache. Then ASP.NET automatically restarts the application to apply the changes.

9.Explain the AutoPostBack feature in ASP.NET?

Ans : AutoPostBack allows a control to automatically postback when an event is fired. For eg: If we have a Button control and want the event to be posted to the server for processing, we can set AutoPostBack = True on the button.

10.What are Master Pages?

Ans : Master pages is a template that is used to create web pages with a consistent layout throughout your application. Master Pages contains content placeholders to hold page specific content. When a page is requested, the contents of a Master page are merged with the content page, thereby giving a consistent layout.

11.What are the types of Caching?

Ans : 1.Application Cache 2.Page Output Cache 3.Variable Cache


12.Method Parameters in C#?

Ans : 1. REF,2. OUT,3.PARAMS


13.What’s the .NET datatype that allows the retrieval of data by a unique key?

Ans : HashTable.

14.How do you debug an ASP.NET Web application?

Ans : Attach the aspnet_wp.exe process to the DbgClr debugger.

15.What is the syntax to inherit from a class in C#?

Ans : Place a colon and then the name of the base class.

Example: class MyNewClass : MyBaseClass

16.What’s a bubbled event?

Ans : When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.

17.What does WSDL stand for?

Ans : Web Services Description Language.

18.Can you override private virtual methods?

Ans : No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.

19.What is an out parameter?

Ans : An out parameter allows an instance of a parameter object to be made inside a method. Reference parameters must be initialised but out gives a reference to an uninstanciated object.

20.What is recursion?

Ans : Recursion is when a method calls itself.

21.Name 10 C# keywords.

Ans : abstract, event, new, struct, explicit, null, base, extern, object, this

22.What is a DLL?

Ans : A set of callable functions, which can be dynamically loaded.

23.What is unsafe code?

Ans : Unsafe code bypasses type safety and memory management.

24.How would you read and write using the console?

Ans : Console.Write, Console.WriteLine, Console.Readline

25.What’s the difference between // comments, /* */ comments and /// comments?

Ans : Single-line comments, multi-line comments, and XML documentation comments.

Author: ngocbd
• Tuesday, December 30th, 2008

1.What are server controls?

Ans : ASP.NET server controls are components that run on the server and encapsulate user-interface and other related functionality. They are used in ASP.NET pages and in ASP.NET code-behind classes.

2.What are Sealed Classes in C#?

Ans : The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class of another class. (A sealed class cannot also be an abstract class) .

3.What is the difference between Array and Arraylist?

Ans : As elements are added to an ArrayList, the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling TrimToSize or by setting the Capacity property explicitly.

4.What is Jagged Arrays?

Ans : A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an “array-of-arrays.”

5.Which method is used to redirect the user to another page without performing a round trip to the client?

Ans : Server.Transfer method.

6.Is it possible to debug java-script in .NET IDE? If yes, how?

Ans : Yes, simply write “debugger” statement at the point where the breakpoint needs to be set within the javascript code and also enable javascript debugging in the browser property settings.

7.How many ways can we maintain the state of a page?

Ans : Client Side - Query string, hidden variables, viewstate, cookies

Server side - application , cache, context, session, database.

8.Will the finally block be executed if an exception has not occurred?

Ans : Yes it will execute.

9.What is the base class of all web forms?

Ans : System.Web.UI.Page .

10.Can we force the garbage collector to run?

Ans : Yes, using the System.GC.Collect(), the garbage collector is forced to run in case required to do so.

11.What does the virtual keyword in C# mean?

Ans : The virtual keyword signifies that the method and property may be overridden.

12.Whats the difference between web.config and app.config?

Ans : Web.config is used for web based asp.net applications whereas app.config is used for windows based applications.

13.What is the difference between a session object and an application object?

Ans : A session object can persist information between HTTP requests for a particular user, whereas an application object can be used globally for all the users.

14.Is it possible to perform forms authentication with cookies disabled on a browser?

Ans : No, it is not possible.

15.Which control has a faster performance, Repeater or Datalist?

Ans : Repeater.

16.What technique is used to figure out that the page request is a postback?

Ans : The IsPostBack property of the page object may be used to check whether the page request is a postback or not. IsPostBack property is of the type Boolean.

17.How can we force a thread to sleep for an infinite period?

Ans : Call the Thread.Interupt() method.

18.What’s the difference between Response.Write() andResponse.Output.Write()?

Ans : Response.Output.Write() allows you to write formatted output.


19.Describe the difference between inline and code behind.

Ans : Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

20.What is the lifespan for items stored in ViewState?

Ans : Item stored in ViewState exist for the life of the current page. This includes postbacks (to the same page).

21.What is PostBack & Callback?

Ans : One technique that current ASP.NET 1.0/1.1 developers use to overcome this postback problem is to use the Microsoft XMLHTTP ActiveX object to send requests to server-side methods from client-side JavaScript. In ASP.NET 2.0, this process has been simplified and encapsulated within the function known as the Callback Manager. The ASP.NET 2.0 Callback Manager uses XMLHTTP behind the scenes to encapsulate the complexities in sending data to and from the servers and clients. And so, in order for the Callback Manager to work, you need a web browser that supports XMLHTTP. Microsoft Internet Explorer is, obviously, one of them.

22.What is singlecall and singleton ?

Ans : Differneces between Single Call & Singleton. Single Call objects service one and only one request coming in. SingleCall objects are useful in scenarios where the objects are required to do afinite amount of work. Single Call objects areusually not required to store state information, and they cannot hold state information between method calls. However, SingleCall objects can be configured in aload-balanced fashion.

Singleton objects are those objects that service multiple clients and hence share data by storing state information between client invocations. They are useful in cases in which data needs tobe shared explicitly between clients and also in which the overhead of creating and maintaining objects is substantial.

23.What is Machine.config File ?

Ans : As web.config file is used to configure one asp .net web application, same way Machine.config file is usedto configure application according to a particular machine. That is, configuration done in machine.configfile is affected on any application that runs on a particular machine. Usually, this file is not alteredand only web.config is used which configuring applications.

24.What debugging tools come with the .NET SDK?

Ans : 1. CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch.

2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR.

25.What does assert() method do?

Ans : In debug compilation, assert takes in a Boolean condition as a parameter, and shows the errordialog if the condition is false. The program proceeds without any interruption if the conditionis true.

Author: ngocbd
• Tuesday, December 30th, 2008

1.What method do you use to explicitly kill a users session?

Ans : Syntax: Session.Abandon()

Note : The Abandon method destroys all the objects stored in a Session object and releases their resources.If you do not call the Abandon method explicitly, the server destroys these objects when the session times out.

2.What methods are fired during the page load?

Ans : Init() ,Load(),PreRender(),Unload().

3.What data type does the RangeValidator control support?

Ans : Integer,String and Date.

4.Which method do you invoke on the DataAdapter control to load your generated dataset with data?

Ans : Fill() method.


5.Which control would you use if you needed to make sure the values in two different controls matched?

Ans : CompareValidator Control


6.What base class do all Web Forms inherit from?

Ans : The Page class.

7.Explain the differences between Server-side and Client-side code?

Ans : Server-side code executes on the server. Client-side code executes in the context of the clients’ browser.
8.do you store the information about the user’s locale?

Ans : System.Web.UI.Page.Culture

9.Can you edit data in the Repeater control?

Ans : No, it just reads the information from its data source.

10.Which template must you provide, in order to display data in a Repeater control?

Ans : ItemTemplate.

11.How can you provide an alternating color scheme in a Repeater control?

Ans : AlternatingItemTemplate.

12.Name two properties common in every validation control?

Ans : ControlToValidate property and Text property.

13.Is String is Value Type or Reference Type in C#?

Ans : String is an object (Reference Type).

14.What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?

Ans : Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client’s browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user’s browser to another page or site. This performas a trip back to the client where the client’s browser is redirected to the new page. The user’s browser history list is updated to reflect the new address.

15.What is the Global.asax used for?

Ans : The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.

16.How many classes can a single .NET DLL contain?

Ans : It can contain many classes.


17.What is portable executable (PE)?

Ans : 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.


18.What is strong name?

Ans : 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.


19.What is Code Access Security (CAS)?

Ans : CAS is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running. For example, it is CAS that will prevent a .NET web applet from formatting your hard disk.

20.What are the different types of assemblies?

Ans : Private, Public/Shared, Satellite

21.Which namespace is the base class for .net Class library?

Ans : system.object

22.How do you create threading in .NET? What is the namespace for that?

Ans : System.Threading.Thread .


23.What is the difference between ref & out parameters?

Ans : An argument passed to a ref parameter must first be initialized. Compare this to an out parameter, whose argument does not have to be explicitly initialized before being passed to an out parameter.


24.What are indexers?

Ans : Indexers are similar to properties, except that the get and set accessors of indexers take parameters, while property accessors do not.

25.What are the access-specifiers available in c#?

Ans : Private, Protected, Public, Internal, Protected Internal.

Chôm từ : fordevs.com

No comments: