.NET Interview Questions – Part 8

1. What is the difference between OLEDB Provider and SqlClient ?

SQLClient .NET classes are highly optimized for the .net / sqlserver combination and achieve optimal results. The SqlClient data provider is fast. It’s faster than the Oracle provider, and faster than accessing database via the OleDb layer.

2. What is the use of Parameter Object?

In ADO Parameter object provides information about a single parameter used in a stored procedure or query.

3. What is DataAdapter?

DataSet contains the data from the DataAdapter which is the bridge between the DataSet and Database. DataAdapter provides the way to retrieve and save data between the DataSet and Database. It accomplishes this by means of request to the SQL Commands made against the database.

4. What does ADO mean?

ADO stands for ActiceX Data Objects.It was introduced few years ago as a solution to accessing data that can be found in various forms, not only over a LAN but over the internet. It replaced the data access technologies RDO(Remote Data Objects) and DAO (Data Access Objects).

5. Name some ADO.NET Objects?

Connection Object
DataReader Object
Command Object
DataSet Object
DataAdapter Object

6. What is Data Provider?

A set of libraries that is used to communicate with data source. Eg: SQL data provider for SQL, Oracle data provider for Oracle, OLE DB data provider for access, excel or mysql.

7. What is the DataTableCollection?

An ADO.NET DataSet contains a collection of zero or more tables represented by DataTable objects. The DataTableCollection contains all the DataTable objects in a DataSet.

8. What are the benefits of ADO.NET?

ADO.NET offers several advantages over previous versions of ADO and over other data access components. These benefits fall into the following categories:

9. How to creating a SqlConnection Object?

SqlConnection conn = new SqlConnection(“Data Source=DatabaseServer;Initial Catalog=Northwind;User ID=YourUserID;Password=YourPassword”);

10. How to creating a SqlCommand Object?

It takes a string parameter that holds the command you want to execute and a reference to a SqlConnection object.
SqlCommand cmd = new SqlCommand(“select CategoryName from Categories”, conn);

11. How to load multiple tables into dataset?

SqlDataAdapter da = new SqlDataAdapter(“Select * from Id; Select * from Salry”, mycon);
ds.Tables[0].TableName = “Id”;
ds.Tables[1].TableName = “Salary”;

12. What is the provider and namespaces being used to access oracle database?


13. What is the difference between SqlCommand and SqlCommandBuilder?

SQLCommand is used to retrieve or update the data from database.SQLCommandBuilder object is used to build & execute SQL (DML) queries like select insert update& delete.

14. What is the use of SqlCommandBuilder?

SQL CommandBuilder object is used to build & execute SQL (DML) queries like select insert update& delete.

15. What are managed providers?

A managed provider is analogous to ODBC driver or OLEDB provider. It performs operation of communicating with the database. ADO.NET currently provides two distinct managed providers. The SQL Server managed provider is used with SQL server and is a very efficient way of communicating with SQL Server. OLEDB managed provider is used to communicate with any OLEDB compliant database like Access or Oracle.

16. How do I delete a row from a DataTable?


17. What inside in DataSet?

Inside DataSet much like in Database, there are tables, columns, constraints, relationships, views and so forth.

18. Explain ADO.Net Architecture?

ADO.NET provides the efficient way to manipulate the database. It contains the following major components. 1. DataSet Object 2. Data Providers :
Connection Object
Command Object
DataReader Object
DataAdapter Object.

19. What is the difference between int and int32?

Both are same. System.Int32 is a .NET class. Int is an alias name for System.Int32.

20. What is the role of the DataReader class in ADO.NET connections?

It returns a read-only, forward-only rowset from the data source. A DataReader provides fast access when a forward-only sequential read is needed.

21. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?

SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix. OLE-DB.NET is a .NET layer on top of the OLE layer, so it’s not as fastest and efficient as SqlServer.NET.

22. What are acid properties?


23. What is DataRowCollection?

Similar to DataTableCollection, to represent each row in each Table we have DataRowCollection.

24. What is the use of Ado.net connection?

Establishes a connection to a specific data source.

25. What are basic methods of Dataadapter?


26. What are the various methods provided by the dataset object to generate XML?

ReadXML : Read’s a XML document in to Dataset.
GetXML : This is a function which returns the string containing XML document.
WriteXML : This writes a XML data to disk.

27. What is DataSet Object?

Dataset is a disconnected, in-memory representation of data. It can contain multiple data table from different database.

28. What is difference between Optimistic and Pessimistic locking?

In Pessimistic locking when user wants to update data it locks the record and till then no one can update data. Other user’s can only view the data when there is pessimistic locking
In Optimistic locking multiple users can open the same record for updating, thus increase maximum concurrency. Record is only locked when updating the record.

29. What is Execute Non Query?

The ExecuteNonQuery() is one of the most frequently used method in SqlCommand Object, and is used for executing statements that do not return result sets (ie. statements like insert data , update data etc.).

30. What providers does Ado.net uses?

The .NET Framework provides mainly three data providers, they are Microsoft SQL Server, OLEDB, ODBC.

31. What is role based security?

By default, ASP.NET will store the session state in the same process that processes the request, just as ASP does. If cookies are not available, a session can be tracked by adding a session identifier to the URL.

32. What is the difference between Asp and Asp.net?

ASP (Active Server Pages) and ASP.NET are both server side technologies for building web sites and web applications, ASP.NET is Managed compiled code – asp is interpreted. and ASP.net is fully Object oriented.ASP.NET has been entirely re-architected to provide a highly productive programming experience based on the .NET Framework, and a robust infrastructure for building reliable and scalable web applications.

33. What methods are fired during the page load?

Init() – when the page is instantiated.
Load() – when the page is loaded into server memory.
PreRender() – the brief moment before the page is displayed to the user as HTML.
Unload() – when page finishes loading.

34. What is the difference between Value Types and Reference Types?

Value Types uses Stack to store the data.where as Reference type uses the Heap to store the data.

35. What is Side-by-Side Execution?

The CLR allows any versions of the same-shared DLL (shared assembly) to execute at the same time, on the same system, and even in the same process. This concept is known as side-by-side execution.

36. What is the base class of Asp.net?


37. what is use of web.config?

Web.config is used connect database from front end to back end.
Web.config is used to maintain the Appsettimgs instead of static variables.

38. What is RangeValidator?

RangeValidator – checks whether a value falls within a given range of number, date or string.

39. What is ValidationSummary?

ValidationSummary – It show a summary of errors raised by each control on the page on a specific spot or in a message box.

40. How do you indentify that the page is post back?

By checking the IsPostBack property. If IsPostBack is True, the page has been posted back.

41. what are the types of ASP Objects?

There are various types of Asp objects
Session Object
Application Object
Server Object
Request Object
Request Object
Response Object
Object Context
Error Object

42. What are remotable objects in .NET Remoting?

Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.

43. What is the difference between ASP Session and ASP.NET Session?

Asp.net session supports cookie less session & it can span across multiple servers.

44. How do you turn off cookies for one page in your site?

Use the Cookie. Discard Property which Gets or sets the discard flag set by the server. When true, this property instructs the client application not to save the Cookie on the users hard disk when a session ends.

45.What does assert () do?

In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.

46. What is cookie less session? How it works?

By default, ASP.NET will store the session state in the same process that processes the request, just as ASP does. If cookies are not available, a session can be tracked by adding a session identifier to the URL.

47. What is the difference between Compiler and Interpreter?

Compiler:A compiler is a program that translates program (called source code) written in some high level language into object code.A compiler translates high-level instructions directly into machine language and this process is called compiling.
Interpreter:An interpreter translates high-level instructions into an intermediate form, which it then executes. Interpreter analyzes and executes each line of source code in succession, without looking at the entire program; the advantage of interpreters is that they can execute a program immediately.

48. Where is View State information stored?

In HTML Hidden Fields.

49. What is the top .NET class that everything is derived from?


50. What is Marshalling?

Marshaling is a process of making an object in one process (the server) available to another process (the client). There are two ways to achieve the marshalling.
Marshal by value
Marshal by reference.

51. What is a Static class?

Static class is a class which can be used or accessed without creating an instance of the class.

52. What is sealed class

Sealed classes are those classes which can not be inherited and thus any sealed class member can not be derived in any other class.A sealed class cannot also be an abstract class.

53. What are the components of web form in ASP.NET?

Server controls
HTML controls
Data controls
System components.

54. Which template is to be provided in the Repeater control in order to display a data?


55. What are the advantages of an assembly?

Increased performance.
Better code management and encapsulation.
It also introduces the n-tier concepts and business logic.

56 What is an ArrayList?

The ArrayList object is a collection of items containing a single data type values.

57. What is the difference between a Thread and a Process?

A thread is a path of execution that run on CPU, a proccess is a collection of threads that share the same virtual memory.
A process have at least one thread of execution, and a thread always run in a process context.

58. What’s the difference between the Debug class and Trace class?

Documentation looks the same.
Use Debug class for debug builds.
use Trace class for both debug and release builds.

59. What’s the difference between Response.Write () and Response.Output.Write()?

Response.Outout.Write allows us to write the formatted out put.

60. What is the difference between inline and code behind?

Inline code written along with the html and design blocks in an .aspx page.
Code-behind is code written in a separate file (.cs or .vb) and referenced by the .aspx page.

61. What is Common Langauge Specification?

CLS also known as Common Language Specification defines the rules which all language must support, in order to be a part of .Net framework. The Common Language Specification is a set of constructs and constraints that serves as a guide for library writers and compiler writers.

62. Which class deals wit the user’s locale information?


63. What is the lifespan for items stored in ViewState?

Items stored in a ViewState exist for the life of the current page, including the post backs on the same page.

64. What is strong-typing versus weak-typing?

Strong typing implies that the types of variables involved in operations are associated to the variable, checked at compile-time, and require explicit conversion
Weak typing implies that they are associated to the value, checked at run-time, and are implicitly converted as required.

65. What is namespace used for loading assemblies at run time and name the methods?


66. How big is the datatype int in .NET?

32 bits

67. What is difference between abstract classes and interfaces?

Abstract classes can have concrete methods while interfaces have no methods implemented.
Interfaces do not come in inheriting chain, while abstract classes come in inheritance.

68. How do you turn off cookies in one page of your asp.net application?

We may not use them at the max, However to allow the cookies or not, is client side functionality.

69. What is web.config file?

Web.config file is the configuration file for the Asp.net web application. There is one web.config file for one asp.net application which configures the particular application. Web.config file is written in XML with specific tags having specific meanings.It includes databa which includes connections,Session States,Error Handling,Security etc.

70. What is the difference between in-proc and out-of-proc?

An Inproc is one which runs in the same process area as that of the client giving tha advantage of speed but the disadvantage of stability becoz if it crashes it takes the client application also with it.
Outproc is one which works outside the clients memory thus giving stability to the client, but we have to compromise a bit on speed.

71. What is a PostBack?

The process in which a Web page sends data back to the same page on the server.

72. Which control would you use if you needed to make sure the values in two different controls matched?

CompareValidator is used to ensure that two fields are identical.

73. What is the difference between HTTP-Post and HTTP-Get?

The GET method creates a query string and appends it to the script’s URL on the server that handles the request.The POST method creates a name/value pairs that are passed in the body of the HTTP request message.

74. What is a Namespace? What is the use of a namespace?

Namespaces are logical grouping of classes and other types in hierarchical structure.Namespaces are useful to avoid collision or ambiguity among the classes and type names.Another use of the namespace is to arrange a group of classes for a specific purpose.

75. What’s the difference between Codebehind=”MyCode.aspx.cs” and Src=”MyCode.aspx.cs”?

Visual Studio uses the Codebehind attribute to distinguish the page source or programming logic from the design. Also the src attribute will make the page compile on every request. That is the page will not be compiled in advance and stored in the bin as a dll instead it will be compiled at run time.

76. How many classes can a single .NET DLL contain?

It can contain many classes.

77. How to view an assembly?

We can use the tool “ildasm.exe” known as “Assembly Disassembler” to view the assembly.

78. Which are the namespaces that are imported automatically by Visual Studio in ASP.Net?

There are 7 namespaces which are imported automatically.

79. What are the layouts of ASP.NET Pages?

GridLayout positions the form object on absolute x and y co-ordinates of the screen.
FlowLayout positions the form objects relative to each other.

80. What is Delegates?

Delegates are a type-safe, object-oriented implementation of function pointers and are used in many situations where a component needs to call back to the component that is using it. Delegates are generally used as basis of events, which allow any delegate to easily be registered for as event.

81. What is the Web User Control?

Combines existing Server and/or HTML controls by using VS.Net to create functional units that encapsulate some aspects of UI. Resides in Content Files, which must be included in project in which the controls are used.

82. What namespaces are necessary to create a localized application?


83. How to Manage State in ASP.Net?

There are several ways to manage a state.

84. What are the different types of Caching?

There are three types of Caching :
Output Caching: stores the responses from an asp.net page.
Fragment Caching: Only caches/stores the portion of page (User Control)
Data Caching: is Programmatic way to Cache objects for performance.

85. What base class do all Web Forms inherit from?

System.web.UI.Page class

86. What is the difference between System.String and System.Text.StringBuilder classes?

System.String is immutable.
System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

87. How to Create a Cookie?

Cookie are one of several ways to store data about web site visitors during the time when web server and browser are not connected. Common use of cookies is to remember users between visits. Practically, cookie is a small text file sent by web server and saved by web browser on client machine.The“Response.Cookies” command is used to create cookies.

88. How do you identify a Master Page?

The master page is identified by a special @ Master directive that replaces the @ Page directive that is used for ordinary .aspx pages.

89. Explain what a diffgram is and a good use for one?

The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. For reading database data to an XML file to be sent to a Web Service.

90. What is a HashTable?

The Hashtable object contains items in key/value pairs. The keys are used as indexes, and very quick searches can be made for values by searching through their keys.

91. What is CAS or Code Access Security?

Code Access Security – CAS is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running.

92. What is the Composite Custom Control?

Combination of existing HTML and Server Controls.

93. What is the use of @ Register directives?

@Register directive informs the compiler of any custom server control added to the page.

94. What is difference between abstract classes and interfaces?

Abstract classes can have concrete methods while interfaces have no methods implemented.Interfaces do not come in inheriting chain, while abstract classes come in inheritance.

95. What is GAC or Global Assembly Cache?

Global Assembly Cache (GAC) is a common place to share the .NET assemblies across many applications. GAC caches all strong named assembly references within it. All System assemblies that come with the .NET framework reside in the GAC.

96. What is the difference between javascript and vbscript?

Javascript :
JavaScript is a client-side scripting language.
JavaScript is used to create interactive web applications supported by the Netscape browser.
JavaScript is simple to use, lightweight, and dynamic. Developers can easily embed code functionality for interactive applications inside a web page.
Javascript is case sensitive and it will be run on client side.
VBScript is a server-side scripting language.
VBScript is not case sensitive and it will be run on server side.

97. What is a web server?

A web server delivers requested web pages to users who enter the URL in a web browser. Every computer on the Internet that contains a web site must have a web server program.

98. What are Cascading style sheets?

Cascading style sheets (CSS) collect and organize all of the formatting information applied to HTML elements on a Web form. Because they keep this information in a single location, style sheets make it easy to adjust the appearance of Web applications.

99. What is the base class of .net?


100. How do you create a permanent cookie?

Permanent cookies are available until a specified expiration date, and are stored on the hard disk.So Set the ‘Expires’ property any value greater than DataTime.MinValue with respect to the current datetime. If u want the cookie which never expires set its Expires property equal to DateTime.maxValue.

101. Which method do you use to redirect the user to another page without performing a round trip to the client?


102. Which method do you use to redirect the user to another page without performing a round trip to the client?


103. What tag do you use to add a hyperlink column to the DataGrid?

< asp:HyperLinkColumn > < / asp:HyperLinkColumn >



This site uses Akismet to reduce spam. Learn how your comment data is processed.