Interview Questions Part 4 – Answers

 

TCS Mumbai

—————-

Locks
Concurrency
Error handling in Sql server 
      @@Rowcount , @@Error

Error handling in .Net                                                                                                                                                             Ans: try catch block can be used
How to pass parameters in stored procedures
     IN , OUT parameters

 

Passing Input and output parameters to SP:

create procedure sproc_employees

(
  @a1 int,
  @a1 int out
)
as
begin
set @a1 =(select count(*) from employees_u where employeeID<@a1)
return @a1
end

Declare @op int
EXEC sproc_employees 5,@op OUT
PRINT @op

create proc sp_nam( @a1 IN, @a1 OUT)
     Can we used the same parameter name as input and output.?

    Ans: No,we cannot give same parameter as input and output,it will throw error- “Variable names must be unique within a query batch or stored procedure”

 

 

 

Using the same parameter as input and output:

 

 

CREATE  PROCEDURE [dbo].[SP_GetEmpDetails]
(
@name  varchar(50) output,
@Empsalary varchar(50) output
)
as
BEGIN
 set  @name =(select EmployeeID from employees_u where LastName=@name)
 set  @Empsalary =(select Title from employees_u where EmployeeID=@name)
select @name,@Empsalary
End

 

Declare @op int
EXEC SP_GetEmpDetails ‘usha’,@op OUT

 

Here the first paramter is used as both input and output parameter.

 

Can we configure the Server of our application with 2 different versions of      
     Asp.net

What is Polymorphism?
In function overloading can we  write as below:
 

  i. functionname(int a1)

         samefunctionname(float a1)

      ii. function(int a1)

          samefunction(int a1,int b1)

 

Can we remove global.asax file from our application?                                                                                                    Ans: When we create a new web application global.asax file is not added automatically so even if the file is not there the application works fairly well.we can add the file explicitly.
What is the use of global.asax file                                                                                              http://msdn.microsoft.com/en-us/library/1xaas8a2(VS.71).aspx                                                                                                                                                       Ans:The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules. The Global.asax file resides in the root directory of an ASP.NET-based application.The Global.asax file is optional. If you do not define the file, the ASP.NET page framework assumes that you have not defined any application or session event handlers.     
What are the events in global.asax file                                                                                                                            Ans: http://www.dotnetcurry.com/ShowArticle.aspx?ID=126&AspxAutoDetectCookieSupport=1#                                                                               
The Global.asax, also known as the ASP.NET application file, is located in the root directory of an ASP.NET application. This file contains code that is executed in response to application-level and session-level events raised by ASP.NET or by HTTP modules. You can also define ‘objects’ with application-wide or session-wide scope in the Global.asax file. These events and objects declared in the Global.asax are applied to all resources in that web application.
Methods corresponding to events that fire on each request
Application_BeginRequest() – fired when a request for the web application comes in.
Application_AuthenticateRequest –fired just before the user credentials are authenticated. You can specify your own authentication logic over here.
Application_AuthorizeRequest() – fired on successful authentication of user’s credentials. You can use this method to give authorization rights to user.
Application_ResolveRequestCache() – fired on successful completion of an authorization request.
Application_AcquireRequestState() – fired just before the session state is retrieved for the current request.
Application_PreRequestHandlerExecute() – fired before the page framework begins before executing an event handler to handle the request.
Application_PostRequestHandlerExecute() – fired after HTTP handler has executed the request.
Application_ReleaseRequestState() – fired before current state data kept in the session collection is serialized.
Application_UpdateRequestCache() – fired before information is added to output cache of the page.
Application_EndRequest() – fired at the end of each request
Methods corresponding to events that do not fire on each request
Application_Start() – fired when the first resource is requested from the web server and the web application starts.
Session_Start() – fired when session starts on each new user requesting a page.
Application_Error() – fired when an error occurs.
Session_End() – fired when the session of a user ends.
Application_End() – fired when the web application ends.
Application_Disposed() – fired when the web application is destroyed.
                                           
Can we have more than 2 machine.config files in IIS servers?
         Ans: 2 machine.config files  can be present in a machine ,machine.config files will be located  in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG and it depends on the numver of .NET framework versions installed in the machine.

       Can we install 2 IIS versions in one system?

 what is the use of web.config and machine.config files? What is the difference between these 2 files?
What is the difference between HTML server control and Web Server control?
Say something about Datagrid? What is the use of Bound Columns? We gave AutoGenerateColumns = True and we have 3 BoundColumns out of 5 columns. How many columns are displayed in the grid? Ans: 5
 What is the use of autogenerate columns?                                                                                                                   Ans: If the DataGrid control’s AutoGenerateColumn property is set to true, the control will generate and display a bound column for each bindable column in the data source, the column names in the grid can be specified explicitly by setting it to false
Which one is better DataReader/DataSet in terms of performance?                           Ans:http://www.dotnetfunda.com/articles/article74.aspx                                                                                                               We should use a DataSet populated by SqlDataAdapter when
1. We require a disconnected memory-resident cache of data so that we can pass to different component or layers
2. We are working wtih data retrived from multiple data sources.
3. We want to update some of all retrieved rows using batch updated provided by SqlDataAdapter
4. We want to perform data binding against a control that requires a data source that spport IList such as GridView, Repeater etc.                                                                   
We should use SqlDataReader by calling ExecuteReader method of SqlCommand object when
1. We are dealing with large volumes of data – too much to maintain in single cache.
2. We want to reduce the memory occupied by the application (using DataSet consumes memory)
3. We want to perform data binding with a control that supports a data source that implements IEnumerable
 Can we pass null values to stored procedures?
 Difference b/w Order BY and GROUP BY in SQL?                                                                                                            Ans: Groupby: It is a way to sub-total your results,or perform some other ‘aggregate’ functions on them.
Orderby: It is a simply a way to sort your results. It doesn’t affect what shows up in your result set,only what order it is displayed.                       http://stackoverflow.com/questions/1277460/what-is-the-difference-between-group-by-and-order-by-in-sql
How to submit one page information to another? Which methods are used? Ans: POST and GET 
POST  : Request.Form

GET :    Request.QueryString

 

If we are using Request then what is the default method it takes?

Ans : QueryString (doubt)  .Default Method of form is GET

Difference b/w Response.Redirect and Server.Transfer?
Ans:http://www.dotnetspider.com/resources/30822-Server-Transfer-Server-Execute.aspx

http://www.dotnetspider.com/forum/ViewForum.aspx?ForumId=21599

Server.Transfer processes the page from one page directly to the next page without making a round-trip back to the client’s browser. This way is faster, with a little less overhead on the server. However, it does NOT update the clients url history list or current url.

Response.Redirect, as expected, is used to redirect the user’s browser to another page or site. It DOES perform a trip back to the client where the client’s browser is actually redirected to the new page. The browser history list is updated to reflect the new address.
 

Can we connect 2 different databases of Sqlserver to our application? How to connect?
Can we connect oracle and sqlserver at the same time?
In web.config  <errors mode=Debug ,none,remote
In web.config <trace  mode = verbose, none
In web.config <sessionstate mode=sqlserver , stateserver inproc,outproc,stateserver
How to debug javascript function in frontend?  Ans: IE -> Tools -> Internet Options-> Advanced ->Uncheck  “Disable Script Debugging (IE)” and “Disable Script Debugging (others)”.
 <Compilation debug = true / false > ie Debug and Release.
In terms of performance which one is better? Ans: In the application itself we have bin folder. In Debug mode dll size is more and release mode dll is small.

Use Release mode in production as it removes breakpoints and dll size is less.

 What is viewstate?
 Can we write nested try catch blocks?
           we can write n number of catch blocks for a single try block. If errors occurs  

            only the related catch executes.

 Can we compare two dates in Asp.net? How?  Which control to use?  Eg: RegularExpression validator.  Don’t use Comparevalidator control (it is for string,int)
Repeater control
What do you know XML?
Diff b/w custom controls and user controls
Diff b/w Stored Procedure and function
select * from functionname …….. Can we write like this if the function is returning some table. Ans : Yes .
What are table valued, scalar valued functions.. Diff functions in Sqlserver
How do u execute Scalar Valued and table Valued functions in Sqlserver
Ans : select * from fucntionname …. (Table Valued function .. It returns table)

           Exec function functionname   .. (Scalar valued function .. It returns single value)

 

 

Gujarat Ahmedabad company

1.      How to provide pagination in Datagrid? Ans: AllowPaging = true ..Event(PageIndexChanging) to be written in codebehind.

2.      DBCC commands

3.      Viewstate . How they implemented ? Ans : Hidden value

       It is specific to the page

       What is the difference between ViewState and Hidden Values. 

4.      Sql Profiler

5.      What are views? Security

Read Only Views

If we change any value in view will it effect the backend table?

6.      What are Cursors? Types of Cursors?

7.      What is Stored Procedure? Give an example?

8.      How to submit one page information to another?

Session , Cache, QueryString, Cross Page post back

Get Post

9.      What are directives in Asp.net?   Different directives?

10.  Difference b/w Response.Redirect/ Server.Execute and Server.Transfer?

11.  What are joins? Types of Joins?

12.  Does C# supports multiple inheritance?

13.  What is an interface?

14.  Difference b/w interface and abstract class?

15.  What is a webservice?

16.  What is the formatting protocol used in Webservices ? Ans: SOAP

17.  Which one of the following is used in Webservices  – DataReader / DataSet/DataList    Ans: DataSet

18.  What is the difference b/w function overloading/ overriding?

19.  What is the difference b/w system.string and system.stringbuilder

Mutable .. immutable

20.  Difference b/w System.Int32 and int?

21.  Difference b/w String and string

22.  C# access modifiers

23.  What is normalization ? Different types of normalizations ?  Give examples?

24.  What is Denormalization? Why and when to denormalize?

25.  Dotnet features?

26.  Dotnet assemblies and types of assemblies

27.  What is the transmission protocol used in webservices ? Ans: HTTP

28.  What are the differences b/w ASP and ASP.Net?

29.  What is ADO.NET

30.  How many languages supports .Net?

 

INDPRO  (9/9/2006)

 

1.      What are SqlCommand objects methods? What is the difference b/w ExecuteNonQuery and ExecuteScalar?

2.      What is the diff b/w DataRepeater and DataList?

3.      What is the diff b/w Container.DataBind , Eval, Bind

Ans:  Eval for formatting the data like date format

           Bind directly binds and displays the db data as  it is.

4.      What is the diff b/w Array and ArrayList

5.      Difference b/w Hash Table and ArrayList

6.       What are Enumerations , Collections

7.      For raising an event of a control (which is present in usercontrol) where to write the code ( In usercontrol or webform)

8.      Page Life Cycle Events

9.      Mention Application and Sessions events of Global.asax

10.  When viewstate is loaded in  Page Life Cycle (Is it Init or Page Load)

11.   Template column in DataGrid? How hyperlink is used in Asp.net datagrid?

12.  What is the use of webserver controls

13.  Page Directives

 

1.      Diff b/w interface and Abstract  class

2.      What is viewstate and where it is stored

3.      Purpose of FXCOP

4.      What is unmanaged code? How CLR executes Unmanaged code

5.      Write a SP that returns the largest of two numbers

 

 

EMids Technologies Pvt Ltd

1.      In FXCOP can we define our own custom rules? How ?

2.      Diff b/w Sqlserver 2000 and 2005

3.      Equals method comes under {String} class

 

Tostring, Equals,GetHashCode , GetType .. default  methods of an Object

4.      What is the default base class for all classes  Ans: System.Object

5.      Base class for Asp.net pages

6.      Base class for Windows Forms

7.      What is the diff b/w Class and object? Real world example?

8.      Diff b/w HTML Server control and Web server control? What is the base class for these two controls? Can we convert HTML server control to webserver control?

9.      How to call javascript function?  Where we will write the code for calling the function

10.  There is an Employee table. What are the steps involved in populating the datagrid with this table

Employee IDs from 1 to 5000 are there. Without changing the query in the above example fill the datagrid with values Empid < 100

Ans: Use Dataview for filtering the records in dataset

11.  Diff b/w Stored Procedure and function

12.  What are the parameters of SP ? What is the default parameter in SP. Ans: In,Out, INOUT and default is IN

13.  Two textboxes and submit button is there. Which validation control in Asp.net to be used to validate those textboxes. What are the properties to be set in validation controls? Ans: ControlToValidate and ErrorMessage

Without using validation controls how to validate the above things.Any properties are there.? How to validate controls through coding

 

 

FCG (5/12/2006)

1.      Diff b/w Interface and Abstract class? When to use these ?

2.      What is an Assembly

3.      Diff b/w custom and user controls

4.      Diff b/w DataSet and DataReader

5.      Diff b/w DataSet and DataTable

6.      Diff b/w Overloading and Overriding with example codes

7.      What is runtime polymorphism  and compile time polymorphism

8.      What is Static Binding, Dynamic Binding

9.      What is Late and Early Binding

10.  What are the different ways of using NEW operator

11.  What is AS,IS in C#

Ans: AS is for type casting

    IS is for comparing objects

12.  What are Transactions in Sqlserver and in ADO.Net

13.  What are ACID properties?

14.  What are LOCKS. Diff Locks

15.  Concurrency

16.  Isolation levels

17.  Diff b/w Convert.ToString() and ToString()

18.  diff b/w ParseInt and int.Parse() and what is IsParseInt

19.  If two developers are updating data into the same dataset then how the dataset will update the data

20.  What is Biztalk Orchestration?

21.   How to use the webservice to get the document from Document Library in SharePoint

22.  Want to give some permissions to the documents in the document library so that users can see only particular documents. How to achieve this?

23.  What is base class for ASP.Net Page ? Ans: System.Web.UI.Page

24.  System.Object – >  a. GetType

                                b. GetHashCode

                                c. ToString

                                 d. Equals

25.   Types of Polymorphism?

26.  Types of Caching and with example code

27.  Session Management

28.  What are the conditions to use INPROC/OutProc

          InProc …. When we want to work with only one webserver

          OutProc…. When we have multiple webservers

29.  NUNIT, FXCOP . Write unit test cases in NUNIT

30.  C# access specifiers. What is default Access Specifier Ans: Public

31.  Diff b/w internal and Protected Internal

32.  What are Out and Ref parameters in C#

         For out no need to initialize , Ref needs initialization

33.  What is Call By Value and Call By Reference

34.  Specify default base classes for following controls

Control Name
 Base Class
 
WebControls
 System.Web.UI.WebControls
 
HTML Controls
 System.Web.UI.HTMLControls
 
Class
 System.object
 
Form
 System.Windows.Form
 
Asp.Net page
 System.Web.UI.Page
 
Asp.Net WebPart
 System.Web.UI.WebControls.WebPart
 

35.  What is Implicit Type Conversion

Ans: Converts smaller datatype to higher datatype

36.  What is Garbage Collection

In C# explain

What are the namespaces

GC.Collect

Different Periods in GC

37.  How to use these tools

 

NCOVER – Code Coverage

NUNIT  – Unit Testing tool

FXCOP – Code Analysis Tool

NTYPE
NDOC

NANT – deployment scripting tool

 

 

IBS(24/12/2006)

 

1.      What is the use of FileUpload Control? Default file size: 4 MB.Cane we increase the     default file size?

Ans: Yes by using MaxRequestLimit

2.      What is transaction? Ans: Process following ACID rules

3.      When to use interface?Can we overwrite virtual functions? How multiple inheritance is possible in C#?

4.      function overloading is early binding,function overriding is late binding

5.      Diff  b/w XML Serialization & binary serialization.

Ans: XML Serialization – Webservices

         SOAP Serialization for Remoting

6.      How to refresh an aspx page automatically. Ans : by using meta tag

7.      Is clustered index created automatically?                                                                                                                                                         Ans: when we are create primary key on a table.

8.      Diff b/w dispose and finalize?

9.      Diff b/w Web services and Remoting

10.  what is a delegate? what are event delegates?

11.  How to avoid SQL Injection?

 

 

US Technologies

 

1.      Diff b/w interface and abstract class? Can we create an instance for abstract class?

       Ans: http://geekswithblogs.net/mahesh/archive/2006/07/05/84120.aspx

        When to use: In short,

       We can go with a normal class when the class contains the core business logic,if not we can use either abstract class or interface.

        If the base class have some default behavior which applies to all its derived classes the abstract class is to be used.

        If there is no default behavior and every derived has its own implementation then interface is better.

      Some more extra points not covered in the above article:

        In case of interface to implement the methods we use ‘override’key word, But in case of abstract class we use’ virtual’ keyword.
     A class may implement several interfaces but A class may extend only one abstract class.

 

 

2.      How to create a web part and how to place the web part in Share point portal?

3.      How to GAC the dll? What happens when we GAC a DLL? Where the DLL is stored?

4.      What is the use of stored procedure? What happens when a SP is compiled?

5.      Types of Joins.

        Ans: Inner Join, Left Outer Join, Right Outer Join, full join Cross Join, Self Join.

6.      Use of Createchildcontrols and RenderContents methods of web part creation

7.      Bubbling Events:

        Event bubbling is used by the data-bound controls (Repeater, DataList, and DataGrid)

      8.   What is the namespace that is used for sending email?

             Ans: System.Net.Mail

 

      9. How to use user controls in web.config

         <pages>
            <controls>
                 <add tagPrefix=”scottgu” src=”~/Controls/Header.ascx” tagName=”header”/>
                <add tagPrefix=”scottgu” src=”~/Controls/Footer.ascx” tagName=”footer”/>
                <add tagPrefix=”ControlVendor” assembly=”ControlVendorAssembly”/>
           </controls>
         </pages>

          we can use custom controls as well in web.config file

 

 

 

 

Leave a comment