Introduction
I appeared for an interview that was for 2 years of experience and had 4 technical rounds. Here my purpose is to share the questions that I encountered. However, I have given brief answers just for reference.
Question 1: Get the highest-earning salesman in each department.
Orders table
OrderId int Checked
Deptno int Checked
Amount int Checked
sales table
orderId int Checked
salesmanId int Checked
Answer
select salesmanId, Deptno from sales inner join orders on sales.orderId=orders.OrderId where the amount in (select MAX(Amount) from sales inner join orders on sales.orderId=orders.OrderId group by Deptno)
Question 2: When will union and union all behave the same?
Answer
Union will give a record only once even if it occurs several times. Union all will give a record as many times as it occurs. So union and union all will behave the same when each record is distinct in all the participating tables.
select name, id from Emp1 union select name, id from Emp2
select name, id from Emp1 union all select name, id from Emp2
Case 1
Emp1
| ID | Name |
| 11 | N1 |
| 12 | N2 |
Emp2
| ID | Name |
| 21 | p1 |
| 22 | p2 |
Union Output and union all output:
| ID | Name |
| 11 | N1 |
| 12 | N2 |
| 13 | p2 |
| 14 | p2 |
Case 2
Emp1
| ID | Name |
| 11 | N1 |
| 12 | N2 |
| 11 | N1 |
Emp2
| ID | Name |
| 21 | p1 |
| 22 | p2 |
Union all output:
| ID | Name |
| 11 | N1 |
| 12 | N2 |
| 11 | N1 |
| 21 | p1 |
| 22 | p2 |
Union output:
| ID | Name |
| 11 | N1 |
| 12 | N2 |
| 21 | p1 |
| 22 | p2 |
Case 3
Emp1
| ID | Name |
| 11 | N1 |
| 12 | N2 |
Emp2
| ID | Name |
| 21 | p1 |
| 22 | p2 |
| 12 | N2 |
Union all output:
| ID | Name |
| 11 | N1 |
| 12 | N2 |
| 21 | p1 |
| 22 | p2 |
| 12 | N2 |
Union output:
| ID | Name |
| 11 | N1 |
| 12 | N2 |
| 21 | p1 |
| 22 | p2 |
In case 1 both union and union will behave the same. But, for case 2 and case 3 union and union, all will behave differently.
Question 3: What are SQL joins?
Answer
- Inner join
When you want only matching records of both tables, use inner join. - Outer join
When we expect both matching and unmatching records of both tables, we need to join using an outer join. Again, outer join is of different types, depending on unmatching records of which table is expected. - Left outer join
When matching records of the right table and all records of the left table is expected. - Right outer join
When matching records of the left table and all records of the right table is expected. - Full outer join
When all records of both tables are expected.
If you want to learn more about SQL Joins, check out SQL Joins.
Question 4: When does a session actually start?
Answer
A session actually starts when a visitor requests your site for the first time. A new session starts when the request doesn't contain any SessionID or the sessionID references an expired session. The Session_OnStart event in Global.asax can be used for tracking session-related information.
Question 5: How is a session maintained?
Answer
When a web app is requested for the first time, the server creates a sessionID and saves it in the cookie of the client browser. This sessionID is sent to the server in all the subsequent requests. If cookieless is made true, sessionID is sent in the URL else the cookie file is sent. This way the session is maintained with SessionID.
Question 6: What are the various session modes in ASP.NET?
- In-proc
Session data is stored in the same machine as that of the server. So session data is lost, when the server restarts. Session data is overhead on the server. - State server
Session data is stored in a separate machine. - SQL Server
Session data is stored in a SQL Server database and kept centrally.
Question 7: You have a user control that has 2 fields. The user will enter data and you need to validate this data and show valid/invalid data in a page. Tell the various ways to do this.

Answer
You can cache the element on the page, process data on the user control, and then write the response on the cached element. This can be done by both AJAX and postback.
Question 8: Write a method to reverse each word of a string without using predefined functions. You can use ToCharArray().
Answer
private static string ReverseEachWord(string StringToReverse)
{
StringToReverse += " ";
StringBuilder ReversedString = new StringBuilder();
char[] ArrStr = StringToReverse.ToCharArray();
StringBuilder WordToReverse = new StringBuilder();
StringBuilder ReversedWord = new StringBuilder();
foreach(char Temp in ArrStr)
{
if(Temp != ' ')
{
WordToReverse.Append(Temp);
}
else
{
for(int i=WordToReverse.Length-1; i>=0 ; i--)
{
ReversedWord.Append(WordToReverse[i]);
}
if(ReversedString.Length == 0)
{
ReversedString.Append(ReversedWord);
}
else
{
ReversedString.Append(" " + ReversedWord);
}
WordToReverse = new StringBuilder();
ReversedWord = new StringBuilder();
}
}
return ReversedString.ToString();
}
Question 9: Name the ActionResults you know
Answer
- View
- PartialView
- Content
- Empty
- JSON
- Redirect
- RedirectToRoute
- File
Question 10: What are Html helpers?
Answer
Html helpers are like ASP controls, but these are lightweight.
Question 11: Why do we need HTTP handlers and models?
Answer
To process requests in a way different than the regular IIS way.
Question 12: The default order in which the view is searched
Answer
If Home/Index is requested, views will be searched in the following order:
~/Views/Home/Index.cshtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Home/Index.cshtml
Question 13: Session.Abandon() vs Clear()
Answer
Session.Abandon() destroys the current session by firing a Session_End event. It releases the SessionState object and its items to free the resources.
Session.Clear( ) just clears the session data (gives a null value to the session) without killing it. It still holds the SessionState and the resources associated with it.
Session ID will remain the same in both of the cases as long as the browser is not closed.
Question 14: What are the various ways to send data from a controller to view?
Answer
- ViewBag: It is a dynamic property.
Controller:: ViewBag.Name = “Rasmita”;
View:: @ViewBag.Name
- ViewData: It is a Dictionary object derived from the ViewDataDictionary class. It requires typecasting and null checks for complex data types.
Controller:: ViewData[“Name”] = “Rasmita”;
View:: @ViewData[“Name”]
ViewBag and ViewData span for a service call.
- TempData: It is a dictionary derived from the TempDataDictionary class. It stores data in a short live session and spans an HTTP request. It is used when moving from one controller to another or from an action method to another. It is for the current and subsequent requests only. It requires typecasting and null checks for complex data types.
ViewBag-ViewData-TempData
Question 15: How to retain a TempData value
Answer
Using Peek and Keep.
If you read the TempData and then call the Keep() or you read the TempData by using Peek(), the TempData will be persisted.
@TempData[“Name”];
TempData.Keep(“Name”);
Or
TempData.Peek(“Name”)
Question 16: Stored Procedure vs Function
Answer
- A Stored Procedure can return zero, single or multiple values. But, a function must return a single value.
- A Stored Procedure can have both input and output parameters whereas Functions can have only input parameters.
- Functions allow only a SELECT command whereas a Stored Procedure allows SELECT and other DML commands (INSERT, UPDATE and DELETE).
- A Stored Procedure can call a function, but a function can't call a Stored Procedure.
- A Stored Procedure can use a try-catch block to handle exceptions. But try-catch is not allowed in functions.
- Functions can be used in a SELECT statement, but procedures are not allowed in a select statement.
- SQL transactions can be used in Stored Procedures but not in Functions.
Question 17: What are the various ways to send content from one page to another?
Answer
Response. Redirect()
Server.Transfer()
WebClient.DownloadFile()
Question 18: How to call a code behind a method asynchronously
Answer
- Create a public static method and decorate it with the WebMethod Attribute.
- Add an asp: ScriptManager control with “EnablePageMethods = true” in the aspx page.
- Now either you can make a jQuery ajax request to it or can call from JavaScript using the PageMethods class.
[WebMethod]
public static string Operate()
{
return “Hi”;
}
<asp:ScriptManager runat=”server” EnablePageMethods = true></asp:ScriptManager>
Window.PageMethods.Operate();
Question 19: What does asp: ScriptManager do to call a WebMethod?
Answer
JavaScript proxies are automatically generated by the ScriptManager that can call the page methods in the code-behind page. The proxy is accessed on the client side using a special class generated by the ScriptManager called PageMethods.
ScriptManager
Question 20: What are all the things that AJAX can't do?
Answer
- AJAX is not supported by old browsers that don't support the XMLHttpRequest JavaScript object.
- AJAX will not work if JavaScript is disabled in the browser.
- Back functionality will not work with ajax since dynamic pages don't register themselves with the browser history engine.
- If the page is bookmarked, the content implemented with AJAX will not reflect.
Question 21: What are Session Modes' advantages over the others?
Answer
- InProc
Session data is stored in the same web server. Performance-wise it's the best mode. But session data will be lost once the server is restarted. Again, since session data is stored in the same server, it’s an overhead on the server, so more data can’t be saved in the session.
- StateServer
Session data is serialized and stored in a separate server so an issue with IIS will not hamper the session data. The aspnet_state.exe service needs to be up and running. Due to serialization and de-serialization, performance-wise it’s slow.
- SqlServer
This is a secure and reliable mode. Session data is serialized and saved in a SQL Server database. The overhead is with serializing and de-serializing data. Since data is stored in the database, it’s centrally available. This is preferred if frequent server restarts are needed or data must be shared with multiple servers.
Question 22: Two interfaces have the same method. A class implements both of these interfaces. You need to override both of these methods in your class. How can you do this? If another class inherits this class, how can you call both of these methods?
Answer
public interface Interface1
{
void Add();
}
public interface Interface2
{
void Add();
}
public class BaseClass : Interface1, Interface2
{
void Interface1.Add()
{
Console.WriteLine("interface1");
}
void Interface2.Add()
{
Console.WriteLine("interface2");
}
}
class Program: BaseClass
{
static void Main(string[] args)
{
var Obj = new BaseClass();
var ObjIface1 = (Interface1)Obj;
var ObjIface2 = (Interface2)Obj;
ObjIface1.Add();
ObjIface2.Add();
}
}
Question 23: What is late binding?
Answer
This comes with inheritance and is done with the same method name and signature in both the base and child classes. The Virtual keyword is in the base class method and the override keyword is in the child class method. This is also known as dynamic polymorphism or method overriding.
Question 24: What will be the output?
Given:
Class test
{
String str1 = “Hello”;
Public static void Main()
{
Str1 +=” World”;
Console.WriteLine(Str1);
}
}
Answer
Compilation error: non-static fields can’t be accessed in a static context
Question 25: Sealed vs Static
Answer
A Sealed class can’t be inherited. A static class can’t be instantiated.
Question 26: virtual vs override
Answer
When you want a base class method to be overridden in a child class, the method in the base class should have the “virtual” key and the method in the child class should have the “override” keyword.
Question 27: The usage of partial keyword
Answer
The “partial” keyword is used with a class, interface, or structure when you want to have its definition split within the same namespace. A partial class can have a partial method when you need to have the method declaration in one partial class and its body in another partial class. More...
Question 28: What is OOP?
Answer
Object Oriented Programming with the following main features:
- Encapsulation- Enclosing all data members (fields and properties) and actions on them (methods) together in a class.
- Abstraction- Exposing the operations, while hiding their internal implementation details.
- Inheritance- Reusing properties and methods of a class in another.
- Polymorphism- The same method behaves differently in different scenarios.
Question 29: How to secure a WCF service
Answer
There are 2 ways to secure a WCF service: Securing the message sent over and securing the transmission medium.
If you know the application domain or IP of the WCF client, UrlReferrer can be used to allow only the respective applications to request your WCF service.
In the operation contract, you can put an if condition for the main logic such as-
ArrAllowedClients.Contains(HttpContext.Current.Request.UrlReferrer.AbsoluteUri)
where ArrAllowedClients holds the set of allowed IPs or application domains.
Question 30: Describe the Page life cycle
Answer
- PreInit: Sets the Master page and theme property dynamically.
- Init: Each controls the UniqueID set. This event is fired first for the innermost element in the DOM, then the parent controls, and finally for the page itself.
- InitComplete: Changes to the view state and any functionality that requires all the controls to be loaded can be done here.
- PreLoad: ViewState of the page and all the controls are loaded. Postback data is also loaded.
- Load: The Load event is raised for the page object itself and then recursively for all the child controls until the page itself and all its controls are loaded.
Dynamic controls can be created here.
IsPostBack andIsValid values can be checked to avoid redundant code.
Here all the control values are restored.
- PreRender: Allows final changes to the page and its controls. This event is fired for the page first and then for the controls.
- Render: Generates the client-side HTML, DHTML, and script that are necessary to display the page on the browser.
- UnLoad: This event is fired for the controls and then for the page itself. All the unused objects are disposed of.
Question 31: MVC life cycle?
Answer
The RouteTable collection is created when the MVC application is requested for the first time. For the subsequent requests, UrlRoutingModule intercepts the request. From the requested URL, this module determines which controller and which action method is requested and executes the respective ActionMethod.
Question 32: What does AutoEventWireUp in the page directive tag mean?
Answer
If “AutoEventWireUp = true”, you don’t need to attach event handlers to the events. Automatically, the event handler will be executed when the event fires up. You just need to override the required event handler.
Question 33: If you have 10 users requesting your application, how many times Application_Start event will be fired?
Answer
Application_Start will be fired only once at the application level. In other words, when the application is requested for the first time.
Question 34: Property vs field
Answer
Fields are private elements whereas properties are public elements with a getter and/or setter.
Question 35: for vs foreach
Answer
foreach is generally used with a collection.
for uses, lesser stack space than foreach since foreach creates a local copy of the item to traverse through and the item that changes in the loop.
Question 36: String is immutable. What does that mean? Explain with an example.
Answer
A string value can’t be changed. Each time you change a string variable, it actually creates a new string instance and dereferences the old value.

Now, Str1 will have the value “Hello World”. But, “Hello ” also exists in memory but it is not referenced by any variable.
Question 37: How to declare a global variable in JavaScript?
Answer
Either you can define the variable outside functions or you can simply skip the “var” keyword in the variable declaration.
Question 38: alert (5+”5”)
Answer
55 as JavaScript is not a strongly typed language. Here is an example of string concatenation that shows why the answer here is 55:
5+5+”5” => 105
5+”5”+5 => 555
More Interview Questions
- Azure Interview Questions
- ASP.NET MVC Interview Questions
- C# interview questions
- ASP.NET interview questions
- Bootstrap interview questions
- Html 5 interview questions
- WCF interview questions and answers
- WPF interview questions and answers
- CSS interview questions and answers
- Angularjs interview questions
- SQL Server interview questions
- ADO.NET interview questions and answers
- Interview question on.NET framework or clr
- Javascript interview questions
- Important.NET interview questions and answers
- Software Testing Interview Questions/
- Dot.NET interview questions for experienced and fresher
- SQL interview questions
- C# interview questions and answers
- jQuery interview question and answer with practices part 2
- Python interview questions

Sanghdeep SanghratnePosted Feb 28, 2020, 12:43 PM
Very nice article...
Divyanshu SaxenaPosted Jan 2, 2020, 11:57 PM
Another solution without using temporary table is :- select * from orders A1 join(select Deptno, Max(Amount) Amount from orders group by Deptno) D on A1.Amount=D.Amount and A1.Deptno=D.Deptnojoin sales on B.orderID=A1.Orderid
Divyanshu SaxenaPosted Jan 2, 2020, 5:03 AM
First question Answer is wrong. Correct answer is :- Select Deptno,max(amount) amount into #temp from orders group by Deptno select salesmanid,a.deptno from sales b inner join orders a on a.orderid = b.orderid inner join #temp t on a.Deptno = t.Deptno and a.Amount = t.amount
Pankaj SinghPosted Jul 9, 2019, 7:13 AM
This very helpful content for Interview..thanks for sharing
Ravindra BabladePosted Jun 26, 2019, 3:58 AM
Good article ........................
Former memberPosted May 20, 2019, 4:35 AM
Nice article...............
Former memberPosted Mar 19, 2019, 1:52 AM
Good interview questions, keep it up
SURAJ KSHIRSAGARPosted Mar 5, 2019, 7:38 AM
Very useful..Nice Content
Ramzanali MominPosted Oct 31, 2018, 12:45 AM
Nice one, keep it up..
Ankita HirvePosted Jun 8, 2018, 6:16 AM
Q.2 Can be solved using CTE also :WITH CTE AS (SELECT ROW_NUMBER() OVER (PARTITION BY ORDERS.DEPTNO ORDER BY AMOUNT DESC)AS ROWNUMB,ORDERS.ORDERID,DEPTNO,AMOUNT,SALESMANIDFROM ORDERS INNER JOIN SALES ON SALES.ORDERID = ORDERS.ORDERID) SELECT DEPTNO,SALESMANID,AMOUNT FROM CTE WHERE ROWNUMB = 1
Satish BPosted Mar 15, 2018, 6:36 AM
Question 8:static void Main() { string name="name"; char[] arr=name.ToCharArray(); int len=arr.Length; string rev=string.Empty; for(int i=len-1;i>=0;i--) { rev+=arr[i]; } Console.Write(rev); }
Ravi PatelPosted Jan 28, 2018, 11:09 AM
Good one thanks for sharing
Upendra Pratap ShahiPosted Nov 20, 2017, 6:35 AM
Nice one, keep it up..
Gopal SharmaPosted Nov 19, 2017, 1:49 PM
In question no 2 order is completely ignore. One of the big difference which many developer ignore is union force sorting automatically and the order of the sort is from column 1 to last column of the select statement. Hence union become more heavier. In case of distinct record in both table order of the union and union all output differ. Select 'b' as NAME, 3 as ID Union all Select 'a' as NAME, 2 as ID union all Select 'c' as NAME, 3 as ID Select 'b' as NAME, 3 as ID Union Select 'a' as NAME, 2 as ID union Select 'c' as NAME, 3 as ID
Gopal SharmaPosted Nov 19, 2017, 1:28 PM
Please validate your answer 1 in below scenario Order Table DataOrderId Deptno Amount 1 1 4000 2 1 4000 3 2 4000 4 1 5000 sales table Data orderId salesmanId 1 1 2 2 3 2 4 1
Gopal SharmaPosted Nov 19, 2017, 1:10 PM
Answer of the question 1 is totally wrong.
Pankaj Kumar SinghPosted Aug 23, 2017, 6:02 AM
Question 8: To long and complex, could be shorter and simple
Suraj RotkarPosted Jul 18, 2017, 9:40 AM
Thanks, Very usefull for interview.
Scott HannenPosted Jul 4, 2017, 2:11 PM
At the risk of splitting hairs, UNION and UNION ALL will never behave the same way. In some cases they might happen to have the same output.
Patt R.Posted May 22, 2017, 10:43 PM
Thanks for sharing. This is good for refreshing the old memories!
Ashish GopePosted Mar 12, 2017, 3:12 PM
The query of First question is not enough. As the Salesman table is considering Orders.orderid as the key column in the join process. But this kind of question can give anyone a better insight about queries. Thanks for sharing.
Goruen SoghomonianPosted Mar 11, 2017, 4:10 PM
Thank you very much :)
Ahmad Fayez MalkawiPosted Dec 4, 2016, 8:09 AM
Select MAX (amount), deptId from sales inner join orders on orders.orderId = sales.orderId group by deptId
Ahmad Fayez MalkawiPosted Dec 4, 2016, 8:09 AM
Single select statement is enough
Ahmad Fayez MalkawiPosted Dec 4, 2016, 8:08 AM
Question 1: its not the best answer!
Kelwin Gavidia C.Posted Nov 14, 2016, 11:00 AM
Thank, it's very contribution...
SubashPosted Nov 10, 2016, 9:45 PM
Thank you very useful for interview preparation and refreshing
Amatya AgyeyPosted Sep 1, 2016, 2:12 AM
Very Fantastic Rasmita .. Keep it up
Sairam NPosted May 16, 2016, 1:17 AM
Fantastic article..
Ravi PatelPosted Nov 30, 2015, 10:44 AM
good one
sholak userPosted Nov 30, 2015, 8:43 AM
you can get real interview sql server questions on forums which help me lot in clearing interviews. refer sitewww.winmilestone.com interviews questions on forums->interviews->
show jamPosted Sep 28, 2015, 9:52 AM
nice sql interview questions @ https://intellipaat.com/interview-question/sql-developer-interview-questions/
Parth DavePosted Jul 24, 2015, 2:02 PM
Very Nice Rasmita. Very marvellous efforts. Keep doing ....
sreenivasa kPosted Jun 24, 2015, 2:06 PM
thx for sharing
Dominique CejaPosted Jun 23, 2015, 10:20 AM
Great article. Very helpful for a young developer!
Debendra DashPosted Jun 23, 2015, 6:27 AM
Thanks Rasmita.......
Ravi PatelPosted Jun 22, 2015, 6:26 AM
good one
Lalit RaghavPosted Jun 15, 2015, 3:11 AM
Thank you Rasmita
Nimit JoshiPosted Jun 4, 2015, 1:27 AM
Thanks for sharing..
Dharmendra YadavPosted Jun 3, 2015, 8:53 AM
thanks Rasmita Dash to share your interview questions......
Dharmendra YadavPosted Jun 3, 2015, 8:50 AM
Answer of Question 8 can be more simple.... string Reverse() { string name = "DHARMENDRA"; string revers = ""; for (int i = name.Length - 1; i>=0;i--) { revers = revers + name[i]; } return revers; }
Muhammad Abdul MananPosted Jun 1, 2015, 1:02 PM
Nice Collection of Questioning
Upendra Pratap ShahiPosted May 30, 2015, 11:45 PM
Nice .....
Sibeesh VenuPosted May 30, 2015, 1:14 PM
Good one.
Santhakumar MunuswamyPosted May 30, 2015, 12:36 PM
kindly make good series...
Santhakumar MunuswamyPosted May 30, 2015, 12:36 PM
Thanks for sharing.. keep it up .
NitinPosted May 30, 2015, 10:16 AM
Good one
Shailesh UkePosted May 30, 2015, 9:21 AM
Nice ...
RakeshPosted May 30, 2015, 8:36 AM
Good one
Dinesh BeniwalPosted May 30, 2015, 8:00 AM
Thanks for sharing Rashmita ;)
Nanhe SiddiquePosted May 30, 2015, 2:58 AM
good set of question ans answer
Abhishek JaiswalPosted May 30, 2015, 1:03 AM
Nice set of questions. Thanks for sharing!! :)
Santhakumar MunuswamyPosted May 29, 2015, 1:21 PM
Thanks for sharing
Gakenh01Posted May 29, 2015, 8:59 AM
Very good questions and answers! This will be helpful to many levels of programmers.
Pankaj Kumar ChoudharyPosted May 29, 2015, 7:48 AM
Thanks for sharing ........... This article is very helpful for me and others students .... who are doing study now and face the interview in future............. this is a best demo of interview questions........