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

Friday, June 8, 2012

Explain Authentication and authorization

Authentication: The process of verifying user credentials against a data source and create an identity is known as authentication.

Authorization : The process of checking whether the requested resource is allowed or denied for an identity is known as authorization.

All about assemblies.

An assemble is a file which contain IL(Intermediate language) code corresponds to a project.
It is also known as unit of deployment.

2 types
.exe--In process components which are capable of running on their own(Windows application).
.dll---Out process components which are not capable of running on their own(classs library)

Assembles are 2 types.
1.Private assembly
2.Shared assembly.

Shared assembly: The assemblies which are stored under the centralized location GAC(Global Assembly Cache) is known as shared assembly.

An assembly which contains 3 attributes like name,version,public key token are known as strong named assembly.

If you wish to include your assembly into GAC you need to create a public key token for that

Generating Public key token

sn -k filename
ex
sn -k key.snk.

copying assembly into GAC
hacutil -i/-u <assemblyname>  i-Install, -u-uninstall

What are the methods available in SqlCommand object??

ExecuteScalar()---> Executes 'select' statement which will returns  data in the form of rows and columns.

ExecuteScalar()--> Executes a 'select' statement which will returns single value.

ExecuteNonquery()-->Executes the DML(Data manipulation) statements and returns how many records get effected.

ExecuteXMLReader()--> Executes 'select' statement and returns data in the format of xml

System.Xml.XmlReader xmlr = cmd.ExecuteXmlReader();

What are the basic concepts(Features) of OOPs??

These are the basic concepts(Features) of OOPS.
1.Inheritance.
2.Polymorphism
3.Encapsulation.
4.Data Abstraction.
5.Reusabilty

In addition to these 5 we have Class,Objects,Message passing and delegation. these 5 are importent concepts

Inheritance: It is an approach which allows accessing members defined in a class from another class by establishing parent child relation ship.

Ex: In .Net Object class is parent class for all the classes.


Polymorphism: "entities behaves differently depending on the input they receive" is known as polymorphism.

Overloading and overriding com under polymorphism

Method Overloading: Defining same method name with the different signatures are known as overloading.
The changes in signature can be any of following.

1.Change in number of methd being passed to a method.
2.Change type of parameters being passed to the method.
3.Chane order of parameters being passed to a method.

Public void YourMethodName()
Public void YourMethodName(int x)
Public void YourMethodName(int x, string y)
Public void YourMethodName( string y,int x)

 Simply it is an approach which allows you to provide multiple behaviors to a method.


Method Overriding : A method defined in parent class is redefine under its child class with same signature and same parameters is known a s method overriding.

Public virtual void Display(int x)  -- Parent
{
//code
}


Public override void Display(int x) --Child
{
//Code
}

Here when you call Display method using child object it will calls the childs implementation

If you want to override a method you must define the method name in parent class with the virtual keyword.

Method Hiding

Rewriting a parent class method under the child class with out permission of parent is known as method hiding.

public void Show()   -------Parent
{
}


Public new void Show()--Child
{
//Code
}

Encapsulation: The process of wrapping up the data into single unit is known as Encapsulation.

Ex. Class is the best example because it hides every thing from outside.

DataAbstraction: It is the processing of representing essential feature with out representing the background details.

Ex. For a car driver he only needs to know about the how steering, accelerator,Gears and breaks work. He does not need to about how internal car engine works.


Explain state management feature in asp.net???

Session Management is a process by which you can maintain state and page information over multiple requests for the same or different pages.

The available option for session Management are

ClientSide
1.viewstate
2.Hiddenfiels
3.Cookies.
4.Querystrings

ServerSide
1.Application State
2.SessionState
3.Profile services

 Client side options store the information into a web page, a uniform resource locator or a cookie.

--I am not going to explain all the above listed options because that would be known by every one if he knows the .net

What is the difference between ResolveUrl() and ResolveClientUrl()??

ResolveUrl()-Returns url relative to site root using controls template source directory property.
ResolveClientUrl: returns url relative to the folder containing the source file in which controls are instantiated.

Prefer to use ResolveUrl()

What is the difference between Session.abondon and sessiom.Clear??

Session.Abondon() will end current session by firing Session_end
Session.Clear(): It just clears the sessions with out killing it.

What is smart navigation??

The cursor position is maintained when the page gets refreshed due to server side validation and the page gets refreshed.

What is caching

It is the technique of storing an in memory copy of some information that is frequently used items in server memory and expensive to create (Interms of performance).

Types of caching
Page output caching.-- setting at the page level
Data Caching.-- Caching the simple variable as we place in session
Fragment Caching. -- It means caching a portion of page(Usually a user controls data).
Data Source Caching.-- Some data source like sql data source can support caching.

Cache objects have 2 types of expirations.

Absolute expiration.
Sliding expiration.

Absolute Expiration: A date time object that identifies when the data should be removed fro the cache.
If you want to use sliding expiration then specify cach.NoAbsoluteexpiration.

Sliding Expiration. A time span object how much the data should be in cache.


Scevaning : It is process of removal of cache items from the cache if server memory is very low . Here it will remove the items based on the priority.

Cache dependency
1. Dependencies on other cache items
2.Dependencies on files and folders.
3.Dependencies on db query.



"OnRemoveCallBack" delegate in the application is used to notify when items are removed from the cache.

What is webfarm and webgarden

A web application runs on a single server that has multiple cpus is called webgarden.

A web application running on multiple servers is called a webfarm.


In both webfarms and web gardens client requests are redirected to asp.net process that is currently busy that means a single client can interact with the different servers over the course of his or her session.



Session state variables are by default stores inproc(within server memory) state by default..

2 built in ways to share session state information across webgarden or web farm.
1.StateServer : Simple to implement and does not require to install sql server
2.Sql Server

Differences between Server.Transfer and Response.Redirect

Server.Transfer can navigates you to the pages which are available in your application where as Response.Redirect can navigates you to external applications also.

When we use server .Transfer the redirection happens on server where as in case Response.Redirect redirection happens in browser.

Server.Transfer is faster as there is no round trip while navigating from one page to another.

Cookies in ASP.net

Cookie : Cookie is a small key value pair which is used to store the small piece of user information.
2 types are cookies are available in asp.net.
Session Cookie and persistent cookie
Session Cookie: These are stored in in-memory during the client browser session when the browser is closed the session cookies are lost.
Ex
HttpCookie sCookie=New HttpCookie("uname","Anji");
Response.cookies.add(sCookie);

//Code to read the cookie
string name= Request.cookies["uname"].value;

Persistent cookies are same as session cookies except that persistent cookies have an expiration date.These are generally used to store info that identifies a returning user to web site like user name or logid.

Creation of persistent cookies
HttpCookie pCookie=New HttpCookie("uname","Anji");
pCookie.Expires=DateTime.Now.AddDays(10);
Response.cookies.add(pCookie);


Cookie Dictionary : It is a single cookie object which can store multiple pieces of information You can use values properties to access and assign new values to cookiedictionary.

Advantages:
Easy to implement.
Does not require server resources.

Dis Advantages:
User can delete the cookie.
Browser can refuse the cookies.
Cookies are not secure.
Any one can view your cookie data once he logged in into your machine.

ASP.net page life cycle.

1)PreInit: The entry point of page life cycle is the pre-initialization phase called preinit. This is only event where you can access master page and themes programatically. You can dynamically set values of master pages and themes in this event. You can also create dynamic controls in this event.
Preinit()
{
//Set master pages and themes dynamically
}

2)Init(): This event fires after each control has been initialized ,each controls unique id is set and skin settings have been applied. Yo can use this event to change initialization values for controls.
3)InitComplete: Raise omnce all initializations of page and its controls have been completed. till now viewstate values are not yet loaded hence you can use this event to change viewstate that you want make sure are persistested after the next post back.

4)PreLoad(): Raised after the page loads viewstate for itself and for all controls and after it processes post back data that is included with the request instance.
LoadsViewstate, Postbackdata.

5)Load(): In this event the page will be restored to previous state incase of postbacks. Code in this page checks fr the postback and then set control properties appropriately.This is the first place in page lifecycle where ll the controls values are restored.

6)ControlEvents : ASP.net now calls any event on the page or its cntrols that caused postback to occur.

7)LoadComplete:  This signals end of load is completed.

8)SaveViewStateComplete: Prior to this event the viewstate for the page and its controls will be set. Any changes of page controls at this point or beyond are ignored.

9)Render: This is method of page object and its controls. At this point asp.net calls methods on each page controls to get its output. the Render method generates client-side html ,Dhtml and script that are necessary to dispay a controsl at browser.

10)Unload : This is for the clean up code. After this page's html is renderes and the objects are disposed off during this event.

--If you find it is hard to remember every thing first tell all the events and next starts explain each of them. when you said all the events the interviewer will be satisfy with that if you are lucky.



Differences between an abstract calss and interface.

An abstract class may contain abstract or non abstract methods.
Interface can contain only method signature.
An abstract class can inherit from a class and one or more interfaces.
An Interface can only inherit from another interface.
An abstract class can contain fields,constructors and destructors.
An Interface cannot contain fields,constructors and destructors.
An abstract class cannot inherit from structures.
An Interface can inherit from structures.
An abstract class does not support multiple inheritance.
An Interface can support multiple inheritance.

What are the differences between constant and read only?

A constant cannot be static while read only can be static.
A constant need to declare and initialize at the declaration only while read only can be initialized at declaration or by code on constructor.
A constant value is evaluated at the design time , while a readonly value is evaluated at the run time.