Friday, December 17, 2010

Interview Questions-3

1) If you have two text boxes one is multi line and other is single line and both have MaxLength 10. What will be the difference in behavior of both?

In multi line text box Max Length property has been ignored. The reason is that multi line text box converted into textarea and text area does not support max length property.While in single line it consider max length and you can not type more than 10 characters in that. If any how you want to implement MaxLength in multi line text box you can use Validator control or java script validation for that.

2) Can we define Optional Parameter in Stored Procedure in SQL Server?
Yes, We can define optional parameter in a stored procedure following way.

CREATE Procedure sp_User
(
@Name as varchar(20),
@Age int = null
)
AS
INSERT INTO table1
SELECT FROM table2
WHERE table1.Name= @Name
and (@Age is null or Age= @Age)

3) What is equivalent of Variant in VB .Net?
There is no "Variant" type in VB.NET. The closest you can get to that is type Object,which is the Mother Type from which all types descend.

If you define

Dim Var

than Var will work as a Variant also.

If you are calling a Com method which take 5 parameters 3 of them are optional. In VB .Net you can pass only three parameters but in C# it will give compile time error method not found with that signature. In C# you can use

object objVal = Type.Missing.

4) What is .Xap file ?
.xap file is the compressed output file for the Silverlight application. The .xap file includes AppManifest.xaml, compiled output assembly of the Silverlight project (.dll) and any other resource files referred by the Silverlight application.

Web pages like .aspx files and .html files use the Silverlight components by loading the .xap files using the <object> tag in the HTML or by using <asp:Silverlight> tag in the ASP.NET pages.

".xap" files (pronounced "zap") use the standard .zip compression algorithm to minimize client download size. A "hello world" .NET Silverlight application (built using VB or C#) is about 5KB in size.

5) How we define constructor and destructor in VB.Net?
In VB .Net we have Finalize method in place of destructor in C#. we can define it like :-

Protected Overrides Sub Finalize()
Try
Finally
MyBase.Finalize() 'define the destructor
End Try
End Sub

And constructor can be define like :-

Public Sub New() ' define the constructor
End Sub

6) What is the Role of Set NoCount in SQL Server?
When SET NOCOUNT is ON, the count (indicating the number of rows affected by a Transact-SQL statement) is not returned. When SET NOCOUNT is OFF, the count is returned.

Actually when you fire any sql query it returns two things actual result and number of rows affected. Suppuse you have fired a select query. This query returns the rows as a result and in message part it will return number of rows return. It is an extra overhead we can suppress the second message with the use of NoCount.

7) Can we define our global variables in SQL Server?
SQL Server provides a wide range of global variable. But you can not define your own global variables in SQL Server.Some global variables are..

* @@ERROR
* @@IDENTITY
* @@MAXCHARLEN
* @@ROWCOUNT
* @@SERVERNAME
* @@SPID
8) What is Referential Integrity?
Referential integrity is a database concept that ensures that relationships between tables remain consistent. When one table has a foreign key to another table, the concept of referential integrity states that you may not add a record to the table that contains the foreign key unless there is a corresponding record in the linked table. It also includes the techniques known as cascading update and cascading delete, which ensure that changes made to the linked table are reflected in the primary table.

No comments:

Followers

Link