Thursday, June 19, 2008

Interview questions

Difference between Web.Config and Machine.Config File
Machine.Config:
i) This is automatically installed when you install Visual Studio. Net.
ii) This is also called machine level configuration file.
iii)Only one machine.config file exists on a server.
iv) This file is at the highest level in the configuration hierarchy.

Web.Config:
i) This is automatically created when you create an ASP.Net web application project.
ii) This is also called application level configuration file.
iii)This file inherits setting from the machine.config

What are joins?
Sometimes we have to select data from two or more tables to make our
result complete. We have to perform a join

How many types of Joins?
Joins can be categorized as:

• Inner joins (the typical join operation, which uses some comparison
operator like = or <>). These include equi-joins and natural joins.
Inner joins use a comparison operator to match rows from two tables
based on the values in common columns from each table. For example,
retrieving all rows where the student identification number is the
same in both the students and courses tables.

• Outer joins. Outer joins can be a left, a right, or full outer join.
Outer joins are specified with one of the following sets of keywords
when they are specified in the FROM clause:

• LEFT JOIN or LEFT OUTER JOIN -The result set of a left outer join
includes all the rows from the left table specified in the LEFT OUTER
clause, not just the ones in which the joined columns match. When a
row in the left table has no matching rows in the right table, the
associated result set row contains null values for all select list
columns coming from the right table.

• RIGHT JOIN or RIGHT OUTER JOIN - A right outer join is the reverse
of a left outer join. All rows from the right table are returned. Null
values are returned for the left table any time a right table row has
no matching row in the left table.

What is self join?
A table can be joined to itself in a self-join.

46. What are the differences between UNION and JOINS?
A join selects columns from 2 or more tables. A union selects rows.

49. What is Stored procedure?
A stored procedure is a set of Structured Query Language (SQL)
statements that you assign a name to and store in a database in
compiled form so that you can share it between a number of programs.
• They allow modular programming.
They allow faster execution.
• They can reduce network traffic.
• They can be used as a security mechanism.

Difference between view and stored procedure?
Views can have only select statements (create, update, truncate,
delete statements are not allowed) Views cannot have "select into",
"Group by" "Having", "Order by"

What are the difference between a function and a stored procedure?
0. Functions can be used in a select statement where as procedures cannot
1. Procedure takes both input and output parameters but Functions
takes only input parameters
2. Functions cannot return values of type text, ntext, image &
timestamps where as procedures can
3. Functions can be used as user defined datatypes in create table but
procedures cannot

Cookies in ASP.NET
How to Create a Cookie ?

HttpCookie objCookie = new HttpCookie(cookiename);
Response.Cookies.Clear();
Response.Cookies.Add(objCookie);
objCookie.Values.Add(cookiename,cookievalue);
DateTime dtExpiry = DateTime.Now.AddDays(iDaysToExpire);
Response.Cookies[cookiename].Expires =dtExpiry;

How to Read Cookie ?
string value= Request.Cookies[cookiename].Value;

How to Delete a Cookie?
Response.Cookies[cookiename].Expires = DateTime.Now.AddYears(-30);

Checking for Cookie in ASP.NET?

if (Request.Cookies[cookiename] == null)

TextBox2.Text = "No cookie found";

else

TextBox2 .Text = Request.Cookies[cookiename].Value;

Difference Between Interfaces:Abstract Class:
Interfaces:
1. Interfaces doesn’t have constructors
2. Can implement multiple inheritances.
3. Contain only abstract methods (Only method prototype is declared)
4. Can not create object for interfaces.
5. Interfaces are reference type.
6. An interface can implement by multiple classes.
7. A derived class can implement multiple interfaces, but can inherit from only one class (abstract or not).
8. Interfaces are default public.
Abstract Class:
1. Abstract classes can have constructors.
2. Can’t implement multiple inheritances.
3. Contain abstract methods and general methods also.
4. Can not create object for abstract class.
5. Abstract classes are reference type.

Difference Between dataset: datareader

1. Read write access. 1. read only access
2. support multiple table form different db. 2.support single table based on single sql query form one db
3. disconnected mode. 3. connected mode
4. Bind to multible controls. 4 bInd to a single control
5. forward & backword scanning of data. 5. forward only scanning of data

Difference Between String and StringBuilder
1. String Class
2. StringBuilder

1. Once the string object is created, its length and content cannot be modified.
2. Even after object is created, it can be able to modify length and content.
1. Slower
2.Faster

Difference between Datagrid and Reapeter Control
Repeator Control:
1)Read-only; no inherent support for selection or editing •
2)No inherent look; you lay out the list by creating templates.
3)List can be vertical, horizontal, all on one line, or in any format you specify. •
4)No default paging; all data is displayed in a single list. •
5)Separators between elements can be defined using a template
Datagrid:
1)Default look is a grid (customizable table) •
2)Can customize look of table extensively. •
3)Options for auto-formatting. •
4)Can specify output using bound columns, columns of buttons or hyperlinks, and custom columns created using templates. •
5)No separator template. However, the grid renders in a table, and you can specify table border size and color. •
6)WYSIWYG template editing •
7)Items support styles for custom look. •
8)Editable contents, including deletion •
9)Single and multiple selection •
10)Optional paged output •Support for sorting •
11)Support for custom functionality that can be applied to items


What is difference between ExecuteReader, ExecuteNonQuery and ExecuteScalar. From Ado.net Blog
ExecuteReader : Use for accessing data. It provides a forward-only, read-only, connected recordset.
ExecuteNonQuery : Use for data manipulation, such as Insert, Update, Delete.
ExecuteScalar : Use for retriving 1 row 1 col. value., i.e. Single value. eg: for retriving aggregate function. It is faster than other ways of retriving a single value from DB.
What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?
Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url.

Response.Redirect is used to redirect the user's browser to another page or site. This performas a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.

No comments: