Monday, 23 September 2013

Interview Questions & Answers

Q) What is the use of Global.asax File?

A) 
The Global.asax, also known as the ASP.NET application file, is used to serve application-level and session-level events.
There Application level events Application_Start,Application_End and Application_Error to handle the events and execute the code when Application starts  like initializing global

variables and terminating the database connection when application ends, also to handle the Error in Application_error event.
There Session level events like Session_start and Session_end to handle user level code.



Q) What is the difference between Response.Write and Response.Output.Write?

A) 
Response.Write() and Response.Output.Write() both are used for print output on the screen.
But they differ in the following aspects:
1. Response.Output.Write()  allows us to print formatted output but Response.Write() can't print formatted output.
Example:

Response.Output.Write(".Net{0},"ASP"); // Its Correct

Response.Write(".Net{0},"ASP"); // Its Wrong

2. As Per Asp.Net 3.5, Response.Write() Has 4 overloads, with Response.Output.Write()
has 17 overloads


Q) Can we have more than 1 machine.config file?
A)No. There can be only one machine.config file in a website.


Q) Difference of custom control and user control?
A)
Custom Control:

  1. A loosely coupled control w.r.t code and UI
  2. Derives from Control                                  
  3. Defines UI in a ResourceDictionary
    UI is skinable
  4. Has dynamic layout
    UI can be changed in different projects
    Has full toolbox support
  5. Defines a single control
  6. More flexible                                              

==============

User Control:


  1. A tightly coupled control w.r.t code and UI
  2. Derives from UserControl
  3. Defines UI as normal XAML
    Child controls are skinable
  4. Has static layout
    UI is fixed and can't have different looks in different project
    Can't be added to the toolbox
  5. Defines a set of controls
  6. Not very flexible like a Custom Control

Q) How custom controls are compiled?
A) Custom controls are deployed as individual assemblies. They are compiled into a dynamic link library (DLL) and used as any other ASP.Net server control.  

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =





Q) What is the use of "USE" keyword in sql?
A) It is use to access database object
Example: use databaseName


Q) When will you use outer join in SQL?
A) Use the SQL OUTER JOIN whenever multiple tables must be accessed through a SQL SELECT statement and results should be returned independent of matching criteria between the JOINed tables.


Q) What is meant by SELECTION,PROJECTION,INTERSECTION and EXCEPT in sql?
A)

SELECT ID, NAME  FROM PRODUCTS  WHERE PRICE > 100;
Selection: The selection to the filter you define in your where clause, here the selection corresponds to the price filter


Projection: The projection corresponds to the columns you select, Here the projection corresponds to the ID and NAME columns.

Intersection:  It is used to get common rows from multiple queries, it mostly gives same output as of inner join but the order and number of columns selected in each query should be same and the datatypes should be compatible.
 
Example: use AdventureWorks

SELECT VendorID,ModifiedDate FROM Purchasing.VendorContact
INTERSECT
SELECT VendorID,ModifiedDate FROM Purchasing.VendorAddress

Except: EXCEPT returns any distinct values from the left query that are not also found on the right query, i.e it gives difference of rows from both the queries.
Example: 

USE AdventureWorks;
GO
SELECT ProductID FROM Production.Product
EXCEPT
SELECT ProductID FROM Production.WorkOrder

Q) What will be the output of the following query:
select mst_country.countryname,mst_state.statename from mst_country,mst_state.

A) It will cross join the Countryname with each statename from the respective table.
The query is same as the following:
select mst_country.countryname,mst_state.statename from mst_country CROSS JOIN mst_state

No comments:

Post a Comment