Wednesday, February 2, 2011

Interview Questions


 ASP.NET

Part I


1. How many web.configs can an application have?
There can only be 1 web.config in an application.

2. Differences between application and session ?
The application level variable hold value at the application level and their instances are destroyed when the no more client access that application, whereas session corresspond to a individual user accessing the application.

3. What is web application virtual directory?
Virtual directory is the physical location of the application on the machine.
By defalut it’s - inetpub/wwwroot

4. If cookies is disabled in client browser, will session tracking work?
No, maintaning value in cokkie woont be possible. In that case you have to make use of other ways to maintain state of the data on page. you can check whether client support cookies or not by using Request.Browser.Cookies property.

5. What is a Process, Sesion and Cookie?
Process - Instance of the application
Session - Instance of the user accessing the application
Cookie - Used for storing small amount of data on client machine.

6. Explain serialization?
Serialization is a process of converting an object into a stream of bytes.
.Net has 2 serializers namely XMLSerializer and SOAP/BINARY Serializer.
Serialization is maily used in the concept of .Net Remoting.

7. What is the difference between overloading and overriding ? how can this be .NET?
Very simple way to remember the diff between them.
Overriding - Method has the same signature as the parent class method.
Overloading - Method having diff parameters list or type or the return type may be different.

8. How do you set language in weg.config?
In Web.Config under element we can set the ‘defaultlanguage’ attribute.

9. What is isPostback property?
This property is used to check whether the page is being loaded and accessed for the first time or whether the page is loaded in response to the client postback.
Example: Consider two combo boxes
In one lets have a list of countries
In the other, the states.
Upon selection of the first, the subsequent one should be populated in accordance. So this requires postback property in combo boxes to be true.

10. Where do you store connection string?
Database connection string can be stored in the web config file.

11. What are the collection classes?
The .NET Framework provides specialized classes for data storage and retrieval.
Queue, Stack, BitArray, HashTable, LinkedList, ArrayList, NameValueCollection, Array, SortedList , HybridDictionary, ListDictionary, StringCollection, StringDictionary

12. What is difference between interface inhertance and class inheritance?
Interface inheritance -
1. The accessibility modifier in Interface is public by defalut.
2. All the methods defined in the interface class should be oveririden in the child class.
Class Inheritance -
1. There is not restriction on the acessibility modifier in a class.
2. Only the method that are defined virtual should be overriden.

13. Explain the life cycle of an ASP .NET page.
Stage Events/Method
Page Initialization Page_Init
View State Loading LoadViewState
Postback data processin LoadPostData
Page Loading Page_Load
PostBack Change Notification RaisePostDataChangedEvent
PostBack Event Handling RaisePostBackEvent
Page Pre Rendering Phase Page_PreRender
View State Saving SaveViewState
Page Rendering Page_Render
Page Unloading Page_UnLoad

14. What are object-oriented concepts?

Class: The formal definition of an object. The class acts as the template from which an instance of an object is created at run time. The class defines the properties of the object and the methods used to control the object’s behaviour.
Object: An object is an instance of a class.
Encapsulation: hides detailed internal specification of an object, and publishes only its external interfaces. Thus, users of an object only need to adhere to these interfaces. By encapsulation, the internal data and methods of an object can be changed without changing the way of how to use the object.
Inheritance: A class that derives from another class - known as the base class - inherits the same methods and properties. This promotes reuse and maintainability.
Abstraction: the describing of objects by defining their unique and relevant characteristics (properties). Whilst an object may have 100s of properties normally only those properties of importance to the situation are described. (eg life policies premiums are normally important; whereas the time of day a policy was purchased is not usually of value).
Polymorphism: Allows objects to be represented in multiple forms. Even though classes are derived or inherited from the same parent class, each derived class will have its own behavior. (Overriding and hiding methods)

15. When is web.config called?
Web.config is an xml configuration file. It is never directly called unless we need to retrieve a configurations setting.

16. What are the types of threading models?Single Threading: This is the simplest and most common threading model where a single thread corresponds to your entire application’s process.
Apartment Threading (STA): This allows multiple threads to exist in a single application. In single threading apartment (STA), each thread is isolated in it’s own apartment. The process may contain multiple threads (apartments) however when an object is created in a thread (i.e. apartment) it stays within that apartment. If any communication needs to occur between different threads (i.e. different apartments) then we must marshal the first thread object to the second thread.
Free Threading: The most complex threading model. Unlike STA, threads are not confined to their own apartments. Multiple treads can make calls to the same methods and same components at the same time.

17. Differences between application and sessionThe session object maintains state on a per client basis whereas the application object is on a per application basis and is consistent across all client requests.

18. ASP.NET OBJECTS?
Application,Request,Responce,server and session

19. Optimization technique description1) Avoid unnecessary use of view state which lowers the performance.
2) Avoid the round trips to server.
3) Use connection pooling.
4) Use stored procedures.

19. What is dictionary base class?Provides the abstract base class for a strongly typed collection of key/value pairs.
Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)

20. What are indexes .NET?Indexes are set up as a subset of data from the column it is created in an index table and a set of pointers to the physical table itself. The index tables are updated when data is inserted, updated or deleted. This can actually have negative performance impact if indexes are unnecessarily created. The overuse of indexes can become as much as burden to the application as not having indexes.

21. What is the difference between overloading and overriding ? how can this be .NETA.1.Overloading: Refers to two methods with same name but different Signature(varing parameters).
2.Overriding: Refers to inherit methods from base class with different same name as well as Signature.

22. What are the 2 types of polymorphism supports in .NET?
1. Interface Polymorphism
2. Inheritance Polymorphism

23. What are indexes .NET?
It is a way to make your class iterate like an array. i.e if you have have a class Car then you can access its object like mycar[0], mycar[1] …

24. Describe the difference between a Thread and a Process?
Thread is a light weight process, which is initialized itself by a process. Light weigt processes does not loads resources required by it itself, these are loaded by its parent process which has generated it.

25. How does output caching work in ASP.NET?Output caching is a powerful technique that increases request/response throughput by caching the content generated from dynamic pages. Output caching is enabled by default, but output from any given response is not cached unless explicit action is taken to make the response cacheable.
To make a response eligible for output caching, it must have a valid expiration/validation policy and public cache visibility. This can be done using either the low-level OutputCache API or the high-level @ OutputCache directive. When output caching is enabled, an output cache entry is created on the first GET request to the page. Subsequent GET or HEAD requests are served from the output cache entry until the cached request expires.
The output cache also supports variations of cached GET or POST name/value pairs.
The output cache respects the expiration and validation policies for pages. If a page is in the output cache and has been marked with an expiration policy that indicates that the page expires 60 minutes from the time it is cached, the page is removed from the output cache after 60 minutes. If another request is received after that time, the page code is executed and the page can be cached again. This type of expiration policy is called absolute expiration - a page is valid until a certain time.

No comments:

Post a Comment