| | | |
|
|
Very nice interview questions for .NET Developers |
 |
|
- What is a web farm?
The most basic definition of a web farm: Running the same web application on multiple servers by having load balancing between them while sharing session, cache, application, etc. objects. along all servers. Note: A users session can start in one of the servers in the web farm and continue on another.
- Do you have any web farm implementation? Please describe.
- What is web garden?
A webgarden is a process model responsible for 'distributing the work to several processes, one per CPU, each with processor affinity set to its CPU'. This means in a nutshell that each Aspnet worker process will run on its dedicated cpu something called cpu affinity.
- Do you have any web garden implementation? Please describe.
- What is the difference between web garden and web farms?
Web Farm is distributing work among servers where in web garden it is distributing work on processes (one per each CPU)
- What is remoting?
Remoting is basically distributing layers of a solution among servers and from the presentation layer making calls to those assemblies explicitly. For this purpose we can use System.Reflection namespace in .NET environment.
- Did you do remoting?
- What are the 4 different Session state modes that is used in ASP.NET?
<!-- sessionState Attributes: mode="[Off|InProc|StateServer|SQLServer]" stateConnectionString="tcpip=server:port" stateNetworkTimeout="timeout for network operations with State Server, in seconds" sqlConnectionString="valid System.Data.SqlClient.SqlConnection string, minus Initial Catalog" cookieless="[true|false]" timeout="timeout in minutes" lockAttributes="sqlConnectionString, stateConnectionString" --> <sessionState mode="InProc"stateConnectionString="tcpip=127.0.0.1:42424"stateNetworkTimeout="10"sqlConnectionString="data source=127.0.0.1;Integrated Security=SSPI"cookieless="false"timeout="20"/>
- Where do you set these methods?
Web.Config or Machine.Config
- Which one is the best method for Web farms?
StateServer or SQLServer
- What is N-tier?
N-tier = Multi tiered applications. Basically multiple layers of an application. In general 3 tiers solves most of the web applications but sometimes, depending on the project you may have n numbers of layers. The most common layers are data access, business logic and presentation layers. The main idea behind layering is when the project grows 1 server may not be enough to handle all processes so in this case you place layers(assemblies) on different servers and by using remoting you can use the server collection for 1 single multi tier application.
- Please describe most popular application layers.
data access, business logic and presentation layers
- Describe the difference between a Thread and a Process?
A process can contain multiple threads. In most multithreading operating systems, a process gets its own memory address space; a thread doesn't. Threads typically share the heap belonging to their parent process.
The most basic application is the single thread application, so each process consists of at least 1 thread.
- What is GC? What problem does it solve?
GC is garbage collector. It detects and releases unused objects from memory, therefore prevents memory leak problems. But it is recommended to release objects from memory when you are finished with them using .Dispose() method.
- Have you ever used using statement? (Not using a namespace)
- What is using statement?
Using statement gives the ability to declare a member and use this member within the statement, and when you end the statement, it automatically disposes that member (as a result releases it from the memory) This usage is a good programming practice.
- Please describe the common classes that can be used with using statement.
Any class which implements IDisposable can be used in using statement.
- What is strong-typing versus weak-typing?
Generally when you need to use a collection which retrieves data from some source, you need to give the name of the retrieved data's attribute to use the value inside it. This usage is weakly typing as it does not prevent you to compile the project if you have any typos. However in the run time your application may throw and exception and stop if you made any typos or wrong type settings. On the other hand, in strongly typed data collections, you define these attributes in to the objects with their respective types. Therefore you prevent the option to make a typo or wrong type settings. Even if you try to cast these strongly typed fields, you will get compiler error therefore you will prevent a lot of production environment run-time errors. Plus you do not need to remember the exact name of the attribute.
- Which is preferred? Why?
Preference depends on the projects size. If you are doing something very small, then you do not bother implementing the strongly typed object. As the project is small enough you can make testing faster to find out any problems you may have. In larger projects strongly typing is preferred to prevent errors in the long run. And don't forget, no need to remember all the names when it is strongly typed.
- What is a PID?
PID = Process ID. This is the process id used in the operating system which identifies you application.
- What is Reflection?
Reflection is the namespace used in .NET as System.Reflection for remoting.
- What is the difference between in-proc and out-of-proc?
In-proc means in the same server's process, when it is out-of-proc the object/data you are using resides in another server. The object residing on the other server must be serilizable.
- When do you use in-proc?
When you have small applications which does not require a lot of memory or any application which is not used by a lot of users. And the advantage is that, it is faster as you do not need to
- serilize the objects
- no network connection
- No additional objects used to call it (No 3rd party connectors)
- What problem does out-of-proc solve?
When you have the same application being served by multiple servers, you need to keep the out-of-proc objects to be served from a shared server by all the other server for keeping the shared data consistent.
- Is string a value type or a reference type?
Reference type.
- Explain the use of virtual, sealed, override, and abstract.
virtual: Declare a method or an accessor whose implementation can be changed by an overriding member in a derived class. sealed: the method is not overridable by any inherited class. override: Provide a new implementation of a virtual member inherited from a base class. abstract: Indicate that a class is intended only to be a base class of other classes. - What are the differences between an abstract class and interface?
Abstract class may have implementation of methods, where in interface all methods are definitions no implementation can take place. The second difference is, a class can inherit from only 1 abstract class where it can inherit multiple interfaces.
- What is a PostBack?
ASP.NET pages have a form and when we post this form, it posts it back to the same page's codebehind rather than another page. This is called a postback.
- What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?
Viewstate is the hidden form element which holds the state(value etc.) of server controls. It is encoded with Base64 algorithm. It is only available for the very same page only. It is required mostly to get the latest values of server controls in a postback. - What is the default event triggered method in a user control (ascx) page?
Page_Load
- Please describe Life Cycle of a Web Forms Page. In a postback event, please provide the steps handled in the codebehind? Describe the methods firing order.
ASP.NET Page Framework Initialization >> The page's Page_Init event is raised, and the page and control view state are restored. Validation >> The Validate method of any validator Web server controls is invoked to perform the control's specified validation. Event Handling >> If the page was called in response to a form event, the corresponding event handler in the page is called during this stage. Cleanup >> The Page_Unload event is called because the page has finished rendering and is ready to be discarded. - From constructor to destructor (taking into consideration Dispose() and the concept of non-deterministic finalization), what the are events fired as part of the ASP.NET System.Web.UI.Page lifecycle. Why are they important? What interesting things can you do at each?
| Phase | What a control needs to do | Method or event to override |
|---|
| Initialize | Initialize settings needed during the lifetime of the incoming Web request.
| Init event (OnInit method) | | Load view state | At the end of this phase, the ViewState property of a control is automatically populated. A control can override the default implementation of the LoadViewState method to customize state restoration. | LoadViewState method | | Process postback data | Process incoming form data and update properties accordingly. Note Only controls that process postback data participate in this phase. | LoadPostData method (if IPostBackDataHandler is implemented) | | Load | Perform actions common to all requests, such as setting up a database query. At this point, server controls in the tree are created and initialized, the state is restored, and form controls reflect client-side data. | Load event (OnLoad method) | | Send postback change notifications | Raise change events in response to state changes between the current and previous postbacks. Note Only controls that raise postback change events participate in this phase. | RaisePostDataChangedEvent method (if IPostBackDataHandler is implemented) | | Handle postback events | Handle the client-side event that caused the postback and raise appropriate events on the server. Note Only controls that process postback events participate in this phase. | RaisePostBackEvent method (if IPostBackEventHandler is implemented) | | Prerender | Perform any updates before the output is rendered. Any changes made to the state of the control in the prerender phase can be saved, while changes made in the rendering phase are lost.
| PreRender event (OnPreRender method) | | Save state | The ViewState property of a control is automatically persisted to a string object after this stage. This string object is sent to the client and back as a hidden variable. For improving efficiency, a control can override the SaveViewState method to modify the ViewState property.
| SaveViewState method | | Render | Generate output to be rendered to the client. | Render method | | Dispose | Perform any final cleanup before the control is torn down. References to expensive resources such as database connections must be released in this phase. | Dispose method | | Unload | Perform any final cleanup before the control is torn down. Control authors generally perform cleanup in Dispose and do not handle this event. | UnLoad event (On UnLoad method) |
- What is the most important events that is fired when binding data to a data web control? What are they good for?
ItemDataBound is the most important event fired while binding. This is fired for each and every datarow that is being binded to the control. It is really important because you only assign attributes to web server controls in code behind not in HTML code itself. Also it is very important when you need to manipulate some data based on a previous binded data,
- What is the OO relationship between an ASPX page and its CS/VB code behind file in ASP.NET 1.1? in 2.0?
ASPX page inherits its server code from its codebehind class which makes the OO relationship.
- What is CLR?
CLR means Common Language Runtime. The CLR is a multi-language execution environment. There are currently over 15 compilers being built by Microsoft and other companies that produce code that will execute in the CLR. - Why is it good?
Vastly simplified development Seamless integration of code written in various languages Evidence-based security with code identity Assembly-based deployment that eliminates DLL Hell Side-by-side versioning of reusable components Code reuse through implementation inheritance Automatic object lifetime management Self describing objects - What is MSIL?
Microsoft Intermediate Language. No matter which language you write your code in VS.NET, at the time of compilation, your code is converted into MSIL and this is recorded in compiled assemblies. Therefore it helps a great deal in code conversions between languages, and in System.Reflection. Because all the compiled codes are in the same MSIL language, it is very easy to interact with those assemblies from any kind of .NET language.
- What is an inline code? Is it good or bad? Why?
Inline code is the code that you write in aspx or ascx page. It is handled at the runtime, so it is not compiled. The benefit of it is, you do not need to build your project for an inline code, you can change it on the fly. However it reduces the performance of your applications since it is not compiled. However especially for your Data Web Controls, this is essential. You cannot get away from it, if you want to make easy to read projects with data web controls.
- Have you ever heard of SqlHelper or Microsoft DataAccess Blocks? What is it?
It is a set of ready methods, provided by Microsoft to ease the SQL data handling steps. You can download it freely from Microsoft.com
- What is the default value for Date object in code behind?
Defatul Date is equal to DateTime.MinValue, which is equivalent to 00:00:00.0000000, January 1, 0001. - Can DateTimes be null?
No.
- What is VB.NET Me in C#?
this - What is the equivalent of C# static in VB.NET?
shared - What is the difference between readonly and const?
A constfield can only be initialized at the declaration of the field. A readonlyfield can be initialized either at the declaration or in a constructor. Therefore, readonlyfields can have different values depending on the constructor used. Also, while a const field is a compile-time constant, the readonly field can be used for runtime constants as in the following example: public static readonly uint l1 = (uint) DateTime.Now.Ticks;
- What is overloading?
Overloading is declaring the same method more than once with different input parameters and sequence in the same class. You can also overload inherited methods as they allow you to do so. Also the return value types can be different in overloaded methods.
- What is overwriting?
When you inherit a class and if this base class has a virtual method or property, and you want to change the implementation then you write the same method/property with the same names with overwrite modifier and implement. This is called overwriting. Or in other words: Provide a new implementation of a virtual member inherited from a base class. - What are attributes?
You can use attributes to describe your code in practically any way conceivable and to affect run-time behavior in creative new ways. Attributes allow you to add your own descriptive elements to C#, Microsoft Visual Basic .NET, or any other language that targets the runtime, without having to rewrite your compiler.
- How do you handle cross browser compability? Which browsers do you know and use?
If you follow W3 recommendations for DOM implementation other than just following Microsoft, then you will be
- What is a linked list?
Linked list is an object, which is pointing a new instance of itself by an instance member which is generally called "tail".
- Please define and explain details of 5 System.Collection objects.
ArrayList:: Is an array objects with unknown size. It is not guaranteed to have the same type of object in each element. Queue: Is a collection which implements FIFO (First In First Out) principle. Enqueue and Dequeue are object specific methods. Hashtable: Is a name value collection. Main interface it implements is IDictionary. Calls its containing elements by keys. Sortedlist: The same as hashtable. The difference between them is in sortedlist, objects are sorted by the key values. Stack: Is a collection which implements LIFO (Last In First Out) principle. Push and Pop are object specific methods. - Please lest 5 most common interfaces that System.Collections has.
ICollection, IDictionary, IEnumerable, IList, IComparer, IEnumerator, IDictionaryEnumerator, IHashCodeProvider
- What do you need to implement in IDisposable inherited object?
Dispose() method must be implemented.
- What is the recommended last statement in Dispose() method?
GC.SuppressFinalize(this); E.g. // Implement IDisposable. // Do not make this method virtual. // A derived class should not be able to override this method. public void Dispose() { Dispose(true); // This object will be cleaned up by the Dispose method. // Therefore, you should call GC.SupressFinalize to // take this object off the finalization queue // and prevent finalization code for this object // from executing a second time. GC.SuppressFinalize(this); }
- What exactly is SSL?
Secure Sockets Layer. When you implement SSL, it ensures that the connectivity between client and server is secure and the application provider company is a trusted company that will not use your information (generally payment details like credit card number etc.) other that the service requested by the client. For this purpose SSL certificates are issued by certified authorities.
- What is P3P?
P3P stands for Platform for Privacy Preferences Project. This is a kind of certificate that identifies a websites privacy policy in an xml document and a human readable web document, which can be detected by web browsers and parsed to verify the privacy policy of the site. Therefore P3P XML document must follow the standards provided by W3C.
- Have you written any mobile web applications?
- How do you handle Session in mobile web applications?
URL munging.
- What are DataGrid, DataList and Repeaters?
They are data web controls and most popular controls in ASP.NET.
- What are their differences and when do you prefer one to another. Please give examples
A Datagrid is a complex table which lists your IEnumerable object in a table. Your resulting HTML output is always a HTML table, unless you don't have any datasource. - DataList is an object which lists your IEnumerable object, vertically or horizontally in the template that you provide in the item template and alternating item template. However the container of your template is always a table cell. DataList also outputs an HTML table at all times but unlike DataGrid, the layout of Datalist can be vertical, horizontal or both, where in Datagrid it is always vertical.
- Repeater is an object which lists your IEnumerable object like DataList.The major difference in Repeater is, You do not have to have a table containing your object data. In repeaters you define the template of the output and it repeats this output without adding any extra line of HTML code. In this sense it is much more efficient than DataList.
- How do you handle transactions?
This totally depends of your application and data design. When you have a single table involved in an update or fairly low amount of tables/data involved it is acceptable to handle transactions in SQL server. Also in some cases you need to handle some transactions in SQL server. If you do not have business logic in SQL procedures, then it is recommended to handle transactions on .NET DataAccess Layer but if you moved significant amount of BL into SQL, then it is more advisable to handel transactions in SQL Server.
- What is RegEx?
RegEx stands for Regular Expressions and you can reach it through System.Text.RegularExpressions
- Where is machine.config located?
C:\WINDOWS\Microsoft.NET\Framework\v*****\CONFIG\ folder
- What is Event-Driven Model and Linear Processing Model?
In Linear Processing model, page is processed in a top-to-bottom sequence, however in Event-Driven Model, page is processes in the order of events. - In ASP.NET which model is used?
ASP.NET uses Event-Driven Model.
- Can you change from one model to the other one?
No
- How can you override an event in an ASP.NET page?
To override an EventName event, override the OnEventName method (and call base. OnEventName). E.g.base.OnPreRender(new System.EventArgs());
- What is caching?
- How can we clear the cache?
- Invalidate cache?
- What is output caching?
- How can we invalidate cache?
-
More and better questions can be found at : Scott Hanselman's weblog Difficult to answer general questions can be found here.
|
|
 | | www.Sevder.com provides tips and techniques for asp.net, csharp, sql, stored procedures to developers from developer. |
| | |
|