Wednesday, 3 August 2011

Common Interview Questions

Basics


Explain the differences between Server-side and Client-side code?
  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.


What is the use of a multicast delegate?
Ans. A multicast delegate may be used to call more than one method.




What is the use of Singleton pattern?
Ans. A Singleton pattern .is used to make sure that only one instance of a class exists.


What is the use of a private constructor?
Ans. A private constructor may be used to prevent the creation of an instance for a class


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.




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


What is an .ashx file?
Ans. It is a web handler file that produces output to be consumed by an xml consumer client (rather than a browser). 


What is a Delegate?
Ans. A delegate is a strongly typed function pointer object that encapsulates a reference to a method, and so the function that needs to be invoked may be called at runtime.




What’s a strong name? 

Strong Name:-A strong name includes the name of the assembly, version number, culture identity, and a public key token.

How do I make a DLL in C#? 

To make a Dll in C# we need to use the /target:library compiler option



What is the difference between const and static read-only? 

The difference is that static read-only can be modified by the containing class, but const can never be modified and must be initialized to a compile time constant. To expand on the static read-only case a bit, the containing class can only modify it: -- in the variable declaration (through a variable initializer). -- in the static constructor (instance constructors if it's not static). 









Are MSIL and CIL the same thing?
Ans. Yes, CIL is the new name for MSIL.


  What is a Satellite Assembly?
Ans. Satellite assemblies contain resource files corresponding to a locale (Culture + Language) and these assemblies are used in deploying an application globally for different languages.




How to register a client side script from code-behind?
Ans. Use the Page.RegisterClientScriptBlock method in the server side code to register the script that may be built using a StringBuilder. 


How to instruct the garbage collector to collect unreferenced data?
Ans. We may call the garbage collector to collect unreferenced data by executing the System.GC.Collect() method. 


How to set the default button on a Web Form?
Ans. <asp:form id="form1" runat="server" defaultbutton="btnGo"/>


What is Boxing and Unboxing?
Ans. Boxing is the process where any value type can be implicitly converted to a reference type object while Unboxing is the opposite of boxing process where the reference type is converted to a value type.


What is the access modifier of a member function of in an Interface created in .NET?
Ans. It is always public, we cant use any other modifier other than the public modifier for the member functions of an Interface.




What is a HashTable in .NET?
Ans. A Hashtable is an object that implements the IDictionary interface, and can be used to store key value pairs. The key may be used as the index to access the values for that index.


What is an ArrayList in .NET?
Ans. Arraylist object is used to store a list of values in the form of a list, such that the size of the arraylist can be increased and decreased dynamically, and moreover, it may hold items of different types. Items in an arraylist may be accessed using an index.


What does the virtual keyword in C# mean?
Ans. The virtual keyword signifies that the method and property may be overridden.


What is the use of Finalize method in .NET?
Ans. .NET Garbage collector performs all the clean up activity of the managed objects, and so the finalize method is usually used to free up the unman-aged objects like File objects, Windows API objects, Database connection objects, COM objects etc.



How do you save all the data in a dataset in .NET?
Ans. Use the AcceptChanges method which commits all the changes made to the dataset since last time Acceptchanges was performed.




Can we achieve operator overloading in VB.NET?
Ans. Yes, it is supported in the .NET 2.0 version, the "operator" keyword is used.




How to prevent inheritance of a class in .NET?
Ans. Use the keyword NotInheritable in VB.NET and sealed in C#.


How to prevent overriding of a class in .NET?
Ans. Use the keyword NotOverridable in VB.NET and sealed in C#.


Is it possible to create a shared event in .NET?
Ans. Yes, but shared events may only be raised by shared methods.


Is it possible to specify an access specifier to an event in .NET?
Ans. Yes, though they are public by default.


How to refer to the current thread of a method in .NET?
Ans. In order to refer to the current thread in .NET, the Thread.CurrentThread method can be used. It is a public static property.


What does AddressOf in VB.NET operator do?
Ans. The AddressOf operator is used in VB.NET to create a delegate object to a method in order to point to it.






Is there a way to suppress the finalize process inside the garbage collector forcibly in .NET?
Ans. Use the GC.SuppressFinalize() method.




In .NET, is it possible for two catch blocks to be executed in one go?
Ans. This is NOT possible because once the correct catch block is executed then the code flow goes to the finally block. 




What is the use of the dispose() method in .NET?
Ans. The Dispose method in .NET belongs to IDisposable interface and it is best used to release unmanaged objects like File objects, Windows API objects, Database connection objects, COM objects etc from the memory. Its performance is better than the finalize() method.


Is there any difference between System.String and System.StringBuilder classes?
Ans. System.String is immutable by nature whereas System.StringBuilder can have a mutable string in which plenty of processes may be performed.


What is the difference between Web.config and Machine.Config in .NET?
Ans. Web.config file is used to make the settings to a web application, whereas Machine.config file is used to make settings to all ASP.NET applications on a server(the server machine).




Is it possible to stop the clientside validation of an entire page?
Ans. Set Page.Validate = false;


How do we enable tracing in .NET applications?
Ans. <%@ Page Trace="true" %>




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.


Validation


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






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




How many ways can we maintain the state of a page?
Ans. 1. Client Side - Query string, hidden variables, viewstate, cookies
2. Server side - application , cache, context, session, database




ADO.NET


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


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

No comments:

Post a Comment