Interview Question and Answer For experience person
I think these questions are very helpful for the people who are trying to get the job on .NET The most common question for experience persons isWhy would you like to change the company?
1). I am looking for a more challenging career in a firm with a larger employee base such as yours.
2). Keeping in mind my career goals, the time has come for me to move onto the next rung of the ladder and make a mark for myself. This can be achieved in a company like this.
3). It is just a career move to enhance my knowledge in my own area of interest.After completion of this question only interview will go for further questions
2). Keeping in mind my career goals, the time has come for me to move onto the next rung of the ladder and make a mark for myself. This can be achieved in a company like this.
3). It is just a career move to enhance my knowledge in my own area of interest.After completion of this question only interview will go for further questions
Difference between stored procedure and function
1) . Procedure can return zero or n values whereas function can return one value which is mandatory.
2) . Procedures can have input, output parameters for it whereas functions can have only input parameters.
3) . Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
4) .Functions can be called from procedure whereas procedures cannot be called from function.
5) .Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
6) .We can go for transaction management in procedure whereas we can't go in function.
7) .Procedures cannot be utilized in a select statement whereas function can be embedded in a select statement.
2) . Procedures can have input, output parameters for it whereas functions can have only input parameters.
3) . Procedure allows select as well as DML statement in it whereas function allows only select statement in it.
4) .Functions can be called from procedure whereas procedures cannot be called from function.
5) .Exception can be handled by try-catch block in a procedure whereas try-catch block cannot be used in a function.
6) .We can go for transaction management in procedure whereas we can't go in function.
7) .Procedures cannot be utilized in a select statement whereas function can be embedded in a select statement.
Difference between Abstract and Interface
Abstract:-Abstract class provides a set of rules to implement next class
-Rules will be provided through abstract methods
-Abstract method does not contain any definition
-While inheriting abstract class all abstract methods must be override--If a class contains at least one abstract method then it must be declared as an “Abstract Class”
-Abstract classes cannot be instantiated (i.e. we cannot create objects), but a reference can be created
-Reference depends on child class object’s memory
-Abstract classes are also called as “Partial abstract classes”
-Partial abstract class may contain functions with body and functions without body
-If a class contains all functions without body then it is called as “Fully Abstract Class” (Interface)
Interface:
-If a class contains all abstract methods then that class is known as “Interface”
-Interfaces support like multiple inheritance
-In interface all methods r public abstract by default
-Interfaces r implementable
-Interfaces cannot be instantiated, but a reference can be created
-Rules will be provided through abstract methods
-Abstract method does not contain any definition
-While inheriting abstract class all abstract methods must be override--If a class contains at least one abstract method then it must be declared as an “Abstract Class”
-Abstract classes cannot be instantiated (i.e. we cannot create objects), but a reference can be created
-Reference depends on child class object’s memory
-Abstract classes are also called as “Partial abstract classes”
-Partial abstract class may contain functions with body and functions without body
-If a class contains all functions without body then it is called as “Fully Abstract Class” (Interface)
Interface:
-If a class contains all abstract methods then that class is known as “Interface”
-Interfaces support like multiple inheritance
-In interface all methods r public abstract by default
-Interfaces r implementable
-Interfaces cannot be instantiated, but a reference can be created
Index types in SQL Server
Clustered IndexOnly 1 allowed per table physically rearranges the data in the table to confirm to the index constraints for use on columns that are frequently searched for ranges of data for use on columns with low selectivity. Non-Clustered Index Up to 249 allowed per table creates a separate list of key values with pointers to the location of the data in the data pages For use on columns that are searched for single values
A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages. A non-clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non-clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.
A clustered index is a special type of index that reorders the way records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages. A non-clustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a non-clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.
What is strong-typing versus weak-typing? Which is preferred? Why?
Strong typing: It checks the type of variables as soon as possible, usually at compile time. It prevents mixing operations between mismatched types.
A strong-typed programming language is one in which: All variables (or data types) are known at compile time There is strict enforcement of typing rules (a String can't be used where an Integer would be expected)
All exceptions to typing rules results in a compile time error
Weak Typing: While weak typing is delaying checking the types of the system as late as possible, usually to run-time. In this you can mix types without an explicit conversion.
A "weak-typed" programming language is simply one which is not strong-typed.
which is preferred depeneds on what you want. for scripts and good stuff you will usually want weak typing, because you want to write as much less code as possible. in big programs, strong typing can reduce errors at compile time.
A strong-typed programming language is one in which: All variables (or data types) are known at compile time There is strict enforcement of typing rules (a String can't be used where an Integer would be expected)
All exceptions to typing rules results in a compile time error
Weak Typing: While weak typing is delaying checking the types of the system as late as possible, usually to run-time. In this you can mix types without an explicit conversion.
A "weak-typed" programming language is simply one which is not strong-typed.
which is preferred depeneds on what you want. for scripts and good stuff you will usually want weak typing, because you want to write as much less code as possible. in big programs, strong typing can reduce errors at compile time.
What is the basic functionality of Garbage Collector in Microsft.Net?
The Common Language Runtime (CLR) requires that you create objects in the managed heap, but you do not have to bother with cleaning up the memory once the object goes out of the scope or is no longer needed. The Microsoft .NET Framework Garbage Collector provides memory management capabilities for managed resources. The Garbage Collector frees objects that are not referenced and reclaims their memory. You should set your references to Nothing(null) as soon as you are done with them to ensure your objects are eligible for collection as soon as possible.
Here are the list of some tasks performed by the Garbage collector: . Garbage collector reserves a piece of memory as the application starts for the managed heap.
. Garbage collector controls the managed heap memory currently used and available to an application.
. Garbage collector allocates memory for new objects within the application.
. The Garbage Collector attempts to reclaim the memory of objects that are not referenced.
Here are the list of some tasks performed by the Garbage collector: . Garbage collector reserves a piece of memory as the application starts for the managed heap.
. Garbage collector controls the managed heap memory currently used and available to an application.
. Garbage collector allocates memory for new objects within the application.
. The Garbage Collector attempts to reclaim the memory of objects that are not referenced.
What are differences between Array list and Hash table?
Ans: 1) Hash table store data as name, value pair. While in array only value is store.
2) To access value from hash table, you need to pass name. While in array, to access value, you need to pass index number.
3) you can store different type of data in hash table, say int, string etc. while in array you can store only similar type of data.
2) To access value from hash table, you need to pass name. While in array, to access value, you need to pass index number.
3) you can store different type of data in hash table, say int, string etc. while in array you can store only similar type of data.
What are differences between system.stringbuilder and system.string?
The main difference is system.string is immutable and system.stringbuilder is a mutable. Append keyword is used in string builder but not in system.string.
Immutable means once we created we cannot modified. Suppose if we want give new value to old value simply it will discarded the old value and it will create new instance in memory to hold the new value.
Immutable means once we created we cannot modified. Suppose if we want give new value to old value simply it will discarded the old value and it will create new instance in memory to hold the new value.
What are the differences between Application object and session object?
Ans: The session object is used to maintain the session of each user.
If one user enter in to the application then they get session id if he leaves from the application then the session id is deleted.
If they again enter in to the application they get different session id.
But for application object the id is maintained for whole application.
If one user enter in to the application then they get session id if he leaves from the application then the session id is deleted.
If they again enter in to the application they get different session id.
But for application object the id is maintained for whole application.
What are the different types of indexes?
Ans: Two types of indexes are there one is clustered index and non-clustered index.
How many types of memories are there in .net?
Two types of memories are there in .net stack memory and heap memory.
Is it possible to set the session out time manually?
Yes we can set the session out time manually in web.config.
Can you Explain Page lifecycle in .net?
The life cycle starts when a user requests a web page through his/her browser. The Web server than process the page through a sequence of steps before response is sent back to the user's browser.
The steps are as: 1. Page Request
2. Start
3. Page Initialization
4. Load
5. Validation
6. PostBack Event Handling
7. Render
8. Unload
The below figure shows the Page Life Cycle of an ASP.NET and its controls
Page Request
The page request occurs before the page life cycle begins. When a user requests the page, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
Start
In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page's UICulture property is set.
Page Initialization
During page initialization, controls on the page are available and each control's UniqueID are generated but not their properties. Any themes are also applied to the page.
Developers have access to the Init, InitComplete and PreLoad methods in this stage. The methods are as follows:
Init: This event is raised after all controls have been initialized and any skin settings have been applied. This event is used to read or initialize control properties.
InitComplete: The Page object raises this event. This event is used for processing tasks that require completion of all initialization.
PreLoad: Use this event if you need to perform processing on your page or control before the Load event. After the Page raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance.
Load
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state. The OnLoad event method is fired during this stage.
This is where you will want to set properties for all of the server controls on your page, request query strings, and establish database connections.
Validation
During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page. PostBack Event Handling
If the request is a postback, any event handlers are called. The event handling for server controls occurs during this stage.
Render
During rendering, view state is saved to the page and then the page calls on each control to contribute its rendered output to the OutputStream of the page's Response property. Render is not really an event. The HTML of the page and all controls are sent to the browser for rendering.
Unload
Unload is called when the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed. The cleanup includes routines such as closing database connections and file streams, or, event logging and other tasks.
Conclusion
When a Web page is requested, the server creates objects associated with the page and all of its child controls objects and uses these to render the page to the browser. Once the final stage is complete, the web server destroys these objects, to free up resource to handle additional request.
The steps are as: 1. Page Request
2. Start
3. Page Initialization
4. Load
5. Validation
6. PostBack Event Handling
7. Render
8. Unload
The below figure shows the Page Life Cycle of an ASP.NET and its controls
Page Request
The page request occurs before the page life cycle begins. When a user requests the page, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
Start
In the start step, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Additionally, during the start step, the page's UICulture property is set.
Page Initialization
During page initialization, controls on the page are available and each control's UniqueID are generated but not their properties. Any themes are also applied to the page.
Developers have access to the Init, InitComplete and PreLoad methods in this stage. The methods are as follows:
Init: This event is raised after all controls have been initialized and any skin settings have been applied. This event is used to read or initialize control properties.
InitComplete: The Page object raises this event. This event is used for processing tasks that require completion of all initialization.
PreLoad: Use this event if you need to perform processing on your page or control before the Load event. After the Page raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance.
Load
During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state. The OnLoad event method is fired during this stage.
This is where you will want to set properties for all of the server controls on your page, request query strings, and establish database connections.
Validation
During validation, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page. PostBack Event Handling
If the request is a postback, any event handlers are called. The event handling for server controls occurs during this stage.
Render
During rendering, view state is saved to the page and then the page calls on each control to contribute its rendered output to the OutputStream of the page's Response property. Render is not really an event. The HTML of the page and all controls are sent to the browser for rendering.
Unload
Unload is called when the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and any cleanup is performed. The cleanup includes routines such as closing database connections and file streams, or, event logging and other tasks.
Conclusion
When a Web page is requested, the server creates objects associated with the page and all of its child controls objects and uses these to render the page to the browser. Once the final stage is complete, the web server destroys these objects, to free up resource to handle additional request.
what is managed and unmanaged code ?
Code that executes under CLR environment is called Managed code for example code written in c# needs CLR Environment to execute it.
Unmanaged code is a code that can execute without any CLR environment Just like code written in c,c++ languge.
Unmanaged code is a code that can execute without any CLR environment Just like code written in c,c++ languge.
how to use multiple web.config files in asp.net application or working with more than one web.config file in asp.net application ?
Introduction:
Here I will explain how to use multiple web.config files in single application using asp.net
Description:
I attended one interview at that time they asked one question that is it possible to use multiple web.config files in single asp.net application? For that question answer is Yes we can use multiple web.config files in single web application but how? By creating web.config file in sub root folders we can use multiple web.config files in our application but each folder should contains only one web.config file. Here I will explain step by step how we can use multiple web.config files in our application...
First create one new web application that contains Default.aspx page and one web.config file. Now right click on your application and select New folder after creation of new folder right click on new folder select Add new item and add one aspx page and one web.config file to this folder that files structure like this
After that write the following code in root folder web.config file appsettings section like this
<appSettings>
Here I will explain how to use multiple web.config files in single application using asp.net
Description:
I attended one interview at that time they asked one question that is it possible to use multiple web.config files in single asp.net application? For that question answer is Yes we can use multiple web.config files in single web application but how? By creating web.config file in sub root folders we can use multiple web.config files in our application but each folder should contains only one web.config file. Here I will explain step by step how we can use multiple web.config files in our application...
First create one new web application that contains Default.aspx page and one web.config file. Now right click on your application and select New folder after creation of new folder right click on new folder select Add new item and add one aspx page and one web.config file to this folder that files structure like this
After that write the following code in root folder web.config file appsettings section like this
<appSettings>
<add key="rootfolder" value="Root Folder web.config"/>
<add key="test1" value="Testing the application for root folder web.config"/>
</appSettings >
After that open Default.aspx page in root folder and write the following code
<html xmlns="http://www.w3.org/1999/xhtml">
After that open Default.aspx page in root folder and write the following code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>RootFolder web.config</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<b>
Root Folder values
</b>
</div>
<br />
<div>
AppKey value:
<b>
<asp:Label ID="lbltxt" runat="server" Text="<%$appSettings:rootfolder %>"/>
</b>
<br />
Appkey Test value:
<b>
<asp:Label ID="Label1" runat="server" Text="<%$appSettings:test1 %>"/>
</b>
</div>
</form>
</body>
</html>
Now run your application and check the output for root folder
Output
After that open the sub root folder web.config file and write the following code in appsettings section like this
<appSettings>
Now run your application and check the output for root folder
Output
After that open the sub root folder web.config file and write the following code in appsettings section like this
<appSettings>
<add key="subrootfolder" value="Sub Root Folder web.config"/>
<add key="test1" value="Testing the application for sub root folder web.config"/>
</appSettings >
After that open ChildPage.aspx page in sub root folder and write the following code
<html xmlns="http://www.w3.org/1999/xhtml">
After that open ChildPage.aspx page in sub root folder and write the following code
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>SubRoot Folder web.config</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<b>
SubRoot Folder values
</b>
</div>
<br />
<div>
AppKey value:
<b>
<asp:Label ID="lbltxt" runat="server" Text="<%$appSettings:subrootfolder %>"/>
</b>
<br />
Appkey Test value:
<b>
<asp:Label ID="Label1" runat="server" Text="<%$appSettings:test1 %>"/>
</b>
</div>
</form>
</body>
</html>
Now run your application and check the output for sub root folder
OUTPUT
If you observe above outputs Default.aspx page getting values from root folder web.config file and ChildPage.aspx page getting values from subroot folder web.config file.
In this way we can use multiple web.config files in asp.net web application. I hope it helps you.Please give a feedback if you like this..
Now run your application and check the output for sub root folder
OUTPUT
If you observe above outputs Default.aspx page getting values from root folder web.config file and ChildPage.aspx page getting values from subroot folder web.config file.
In this way we can use multiple web.config files in asp.net web application. I hope it helps you.Please give a feedback if you like this..
Thanks for sharing
ReplyDelete