MY bLOG

Thursday, 19 December 2013

Interview questions and answers for dotnet developers

1.You need to identify
Is Always a number
Is Always greater than 
      a.int32
      b.int64
      c.system.unit16
      d.system.unit32
2.You have created an assembly that utilizes unmanaged code to access external resources. You need to deploy the assembly with the appropriate permissions. Which permission set should you use?
  1. safe
  2. unsafe
  3. EXTERNAL_ACCESS
  4. Default Permission set

3.You have an application that is used by international clients. All clients connect by using Windows Authentication. You need to ensure that system and user-defined error messages are displayed in the localized language for the clients.

  1. Use @@LANGUAGE function
  2. Use the "set language" option of sp_configure
  3. Use default language for each login

Use default language for each login and another option is Use @lang parameter of sp_addmessage

4.Your application uses two threads, named threadOne and threadTwo. 
You need to modify the code to prevent the execution of threadOne 
until threadTwo completes execution. 
What should you do?

  1. Configure threadOne to run at a lower priority.
  2. Call the Sleep method of threadOne.
  3. Configure threadTwo to run at a higher priority.
  4. Use a WaitCallback delegate to synchronize the threads.

you have to use a waitcallback delegate to synchronize the threads

5.You need to create a method to clear a Queue named q.

  1. foreach(object e in q){q.Dequeue();
  2. foreach(object e in q){q.Enqueue(null);
  3. q.clear();
  4. q.Dequeue();

Queue method will clear while using q.clear();

6.You need to write a multicast delegate that accepts a DateTime argument 
which code type you can choose

  1. public delegate int PowerDeviceOn(bool result, DateTime autoPowerOff);
  2. public delegate void PowerDeviceOn(DataTime autoPowerOff);
  3. public delegate bool PowerDeviceOn(object sender, EventsArgs autoPowerOff);
  4. public delegate bool PowerDeviceOn(DataTime autoPowerOff);

public delegate void PowerDeviceOn(DataTime autoPowerOff);

7.Differentiate between a page theme and a global theme?

Page Theme: 
Where as Page theme applies to a particular web pages of the project. It is stored inside a subfolder of the App_Themes folder. 

Global Theme: 
Where as Global theme applies to all the web applications on the web server. It is stored inside the Themes folder on a Web server.


8.Which of the following is NOT used for getting auto-incremented value of a IDENTITY Column in SQL Server?

  1. SCOPE_IDENTITY()
  2. @@IDENTITY
  3. IDENT_CURRENT('TableName')
  4. MAX(id).

SCOPE_IDENTITY(), @@IDENTITY, IDENT_CURRENT('TableName') are used for getting auto incremented value from recent INSERT statement in SQL Server

9.ASP .Net Page class, in which of them would you attach an event handler to an event published by a control on the web page?


  1. onload()
  2. OnPageload()
  3. OnInit().
  4. OnPostback()

OnInit() method is called when an ASP.Net page is  intialized , this would be the most appropriate place to attach an event to its event handler.

10.Why can't you open a new browser window from within server code?

Server code executes on the server, where as the new window is created on the client.You need to use the client-side code to do things that affect the client,such as upload Files ,display new windows or navigate back in history.

11.What is the main difference between the Button server control and the Button Html control?

when clicked the Button server control triggers are asp.net click event procedure on the server.The Button HTML control triggers the event procedure indicated in the buttons onclick attribute,which runs on the client.

12.List the EmpNo,EName,Sal Daily Sal of all Emps in the ascending order of annual salary?

Select EmpNo,EName,Sal,Sal/30,12 * Sal annual salary from Emp order by annual salary 
you can detect by this query.


13.write a query the name ends with 'i' using sql server?

select * from emp where name like '%i' 
output: 
aswini 
aluri 
devi 

the query displays the person name ends with i only


14.write a query name starts with 's' using sql server?

select * from emp where name like 's%' 
output: 
siri 
spandu 
seshu 

The query displays the name starts with s only


15.write a query allow only 4 characters in name column using sql server?

select name from salary where name like '____' 
after like 4 dashes with in single quote 

o/p::ashu 

siri 
hari 

the output will shown like that it can show only 4 characters.


16.How to allow only alphabets using regular expression validator?

  1. "[a-zA-Z]"
  2. "^[a-zA-Z]+$".
  3. [A-za-z]

Validation Expression="^[a-zA-Z]+$"
it can allow only alphabets

17.How many generations in Gc within managed heap and what are the default sizes?

  1. 3geneartions, sizes-45kb.45mb,7mb
  2. 3Generations Sizes-128kb,2mb&10 mb.
  3. 2 Generations Sizes-222kb,455mb

Maximum number of generations allowed are only three
In general always generation 2memory size is bigger than the generation 1 memory size and generation 1 memory size is bigger than the generation 0 memory size.

18.what is the max size of rows in a particular table

  1. 1024
  2. 8060.
  3. 1824

8060 rows only

19.how to detect the product level,product version and edition in sql server 2008

select serverproperty('product level') 
select serverproperty('productversion') 
select serverproperty('edition') 
By using three queries you can get the product level,product version and edition


20.In.Net which is the parent class to create all windows service?

  1. Eventloginstaller
  2. Service Installer
  3. servicebase.

The service base class is the parent class to create all windows service
21.how to change the database owner?
  1. sp_helptext owner
  2. sp_changeowner
  3. sp_changeDBowner 'sa'.

sp_changeDBowner 'sa'


22.What is the maximum size of columns in a particular table?
  1. 65,535
  2. 8060
  3. 1024.

for a table it can allow only 1024 columns in sql server

23.What is the maximum size of columns in a particular table?

  1. 65,535
  2. 8060
  3. 1024.

for a table it can allow only 1024 columns in sql server

24.How to convert server name to host name?

convert server name to host name using this query 
sp_drop server hcl 
sp_add server'hcl/infotech','local'

25.How can you detect the host name and Ip address?

>xp_cmdshell hostname--for hostname 
-->xp_cmdshell Ipconfig---for ip address.

26.How can you detect the servername ?

  1. select* servername
  2. select @servername
  3. select@@servername

to detect server name using this query on your db
select@@ servername

27.How can you detect the version properties?

by using this query you can achieve. 

-->select @@ version

28.How can you detect the how many mdf & ndf & ldf files in your database?

  1. sp_helptext
  2. sp_helpindex
  3. sp_helpdb'text'

by using sp_helpdb'text' you can detect your mdf&ndf&ldf files

29.can one dll contain the compiled code of more than one programming language?

  1. Yes
  2. No
  3. both a&b

no,a dll file contain the compiled code of only one programming language.

30.How many web servers are needed for a web site?

There is only one web server are required for a web site.But large web sites like yahoo ,google,msn etc will have millions of visitors every minute one computer cannot process such huge data ,so they will have a hundreds of servers then it can give the fast response

31.How many web sites can be hosted in one server?

A web server can host hundreds of web sites.Most of the small web sites in the Internets are shared on web servers.They are several web hosting companies who offer shared web hosting  from a web hosting company,they will host your web site along with their web server along with several other web sites. 

Ex Of web servers applications are: 
1.IIS
2,Apache

32.Is validation is done by server side or client side validation?

Server side Validation

  1. ClientSide validation
  2. both 1&2.

by default it is done by client side ,server side validation is possible when you switch off the client side.

33.Difference between Typed DataSet and UnTypedDataSet

Typed DataSet is a Custom class generated by visual studio 
It adds things like named properties that match column and row data in the tables. It's generated code and not a part of .NET, so you can't use typed datasets without Visual studio unless you copy all of the code and manually customize it for your project. An untyped dataset is an object of the DataSet class. It's a part of .NET and you can use it even if you don't have Visual Studio. 
typed dataset is generally used as it is easy to use and moreover gives errors at compile time...compared to untyped which gives on run time

34.Difference between label and literal controls in asp.net?

label: 
Label control renders text within span tag to browser. It is possible to apply style and style sheet class to label. 
Literal: 
Literal will render it's text that is assign to text property. It cannot render any additional html tag. Default mode for literal is “Transform”. Best practice to set Mode="Encode" for literal control 

It is best practice to use literal instead of Label control wherever it possible in asp.net application..

35.If i write system.exit(0);at the end of try block is finally block will execute?

No,the finally block can't execute in this case because when you mention system.exit(0); 
the control goes out of the program and the finally block never execute.

36.How to find out which index is defined on table?

  1. sp_tablename
  2. sp_helpindex
  3. sp_helpindextablename.

sp_helpindextablename

37.In which events controls are fully loaded?

In page load events all controls are loaded 
controls are accessed in page_init event but you see that view state is not fully loaded during this event

38.which statements is used to replace multiple if-else statements in code?

In Vb.net the select case statement is used to replace multiple if-else statement. 
and in c# the switch-case statement is used to replace multiple if-else statement.

39.Is it possible to host web site from desktop?

  1. No
  2. Yes.
  3. Some Times It can be

Yes you can host web site from desktop

40.why we are using distinct keyword in sql server?

The DISTINCT keyword in SQL allows you to select only those records that contain unique values for the columns requested in a Select statement,. Duplicate values are ignored and only displayed once. 
Ex:- using emp table 
Emp ID EmpName 
1 Aswini A 
2 Aswini A 
3 Aluri 


then 
select distinct EmpName from emp 
then it displays 
only 
EmpName 
Aswini A 
Aluri

41.ACID rules in sql server?

Atomicity 
Consistency
Isolation
Durablity 

Atomicity: 
Modification on the data in the database either fail or succeed. The beginning of such a modification starts with a transactionand ends when a transaction finishes (either by a commit or arollback). A software crash entails an implicit rollback. 
Consisyency: 
Modification on the data in the database either fail or succeed. The beginning of such a modification starts with a transactionand ends when a transaction finishes (either by a commit or arollback). A software crash entails an implicit rollback. 

Isolation: 
One transaction does not interfere with another. The 'executor' of a transaction has the feeling that he has the entire database for himeself. 
Durablity: 
A commited transaction will not be lost.


42.What is the difference between Dot Net 4.0 and 4.5 Framework .

As practically the difference between dot net 4.0 and 4.5 are mentioned below- 
>> You can compile an application for .NET 4.5 and run it on the 4.0 runtime – that is a new feature of 4.5, that doesn’t exist on 4.0. 
<configuration> 
<startup> 
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> 
</startup>

43.Can you split the one column in to two columns 
For Ex:FullName:Aswini Aluri 
It must split into firstname: Aswini. 
LastName :Aluri

Create splitS(FullName NVARCHAR(50)) 
select LEFT(fullname, CHARINDEX(' ', fullname + ' ') -1), 
STUFF(fullname, 1, Len(FullName) +1- CHARINDEX(' ',Reverse(fullname)), '') 
from splits.

I hope it will help you

This questions are asked in many interviews.