dotnet difference questions & answers compiled-1(updated)

93
1) What are the differences between DataReader and DataAdapter? S.No DataReader DataAdapter 1 Works in Connected Mode Works in Disconnected Mode 2 Can have only one record at a time Can have more than 1 records 3 Is ForwardOnly and Readonly Can navigate front and back and editable 4 Faster Slower 2) What are the differences between DataSet and DataReader? S.No DataSet DataReader 1 Works in Disconnected Mode Works in Connected Mode 2 Can navigate back and forth Can navigate forward only 3 Data is editable Data is Readonly 4 Can contain more than one table and relationships Can contain only one row at a time 5 Slower as having more overhead Faster when compared with DataSet 3) What is the difference between DataSet.Copy() and DataSet.Clone()? S.No DataSet.Copy() DataSet.Clone() 1 DataSet.Copy() copies both the structure and data DataSet.Clone() copies the structure of the DataSet, including all DataTable schemas, relations, and constraints and it does not copy any data 4) What are the differences between RecordSet and DataSet? S.No RecordSet DataSet 1 RecordSet provides data of one row at an instant DataSet is a data structure which represents the complete table data at the same time 2 RecordSet always needs an Open connection to read the data from data sources DataSet needs connection only for retrieving the data. After retrieve the data connection is not necessary 3 RecordSet is able to load the structure and data of only one table at a time DataSet has the capability to store the structure and data of multiple tables at a time 4 RecordSet does not support constraints of Databases DataSet enforces data integrity by using Constraints 5) What are the differences between ADO and ADO.Net? S.No ADO ADO.Net

Upload: umar-ali

Post on 15-Jan-2015

3.587 views

Category:

Technology


1 download

DESCRIPTION

This provides huge collection (150+) of DOTNET Technology FAQs which are of "Difference Between" type. For further updates, please visit my blog @ http://onlydifferencefaqs.blogspot.in/

TRANSCRIPT

Page 1: Dotnet difference questions & answers Compiled-1(updated)

1) What are the differences between DataReader and DataAdapter?

S.No DataReader DataAdapter1 Works in Connected Mode Works in Disconnected Mode2 Can have only one record at a time Can have more than 1 records3 Is ForwardOnly and Readonly Can navigate front and back and editable4 Faster Slower

2) What are the differences between DataSet and DataReader?

S.No DataSet DataReader1 Works in Disconnected Mode Works in Connected Mode2 Can navigate back and forth Can navigate forward only3 Data is editable Data is Readonly4 Can contain more than one table

and relationshipsCan contain only one row at a time

5 Slower as having more overhead Faster when compared with DataSet

3) What is the difference between DataSet.Copy() and DataSet.Clone()?

S.No DataSet.Copy() DataSet.Clone()1 DataSet.Copy() copies both the

structure and dataDataSet.Clone() copies the structure of the DataSet, including all DataTable schemas, relations, and constraints and it does not copy any data

4) What are the differences between RecordSet and DataSet?

S.No RecordSet DataSet1 RecordSet provides data of one row

at an instantDataSet is a data structure which represents the complete table data at the same time

2 RecordSet always needs an Open connection to read the data from data sources

DataSet needs connection only for retrieving the data. After retrieve the data connection is not necessary

3 RecordSet is able to load the structure and data of only one table at a time

DataSet has the capability to store the structure and data of multiple tables at a time

4 RecordSet does not support constraints of Databases

DataSet enforces data integrity by using Constraints

5) What are the differences between ADO and ADO.Net?

S.No ADO ADO.Net

Page 2: Dotnet difference questions & answers Compiled-1(updated)

1 It supports connected model It supports disconnected model2 It uses record set It uses data set3 XML support is less XML support is more

Page 3: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between Typed DataSet and Untyped DataSet

S.No Typed DataSet Untyped DataSet

1 It provides additional methods, properties and events and thus it makes it easier to use.

It is not as easy to use as strongly typed dataset.

2 They have .xsd file (Xml Schema definition) file associated with them and do error checking regarding their schema at design time using the .xsd definitions.

They do not do error checking at the design time as they are filled at run time when the code executes.

3 We will get advantage of intelliSense in VS. NET.

We cannot get an advantage of intelliSense.

4 Performance is slower in case of strongly typed dataset.

Performance is faster in case of Untyped dataset.

5 In complex environment, strongly typed dataset's are difficult to administer.

Untyped datasets are easy to administer.

6 Typed DataSets use explicit names and DataTypes for their members.

ex:northwindDataSet.Products.ProductNameColumn.Caption = "pnames";

UnTyped DataSets use table and column collections for their members

ex:ds.Tables["emp"].Columns["eno"].ReadOnly=true;

2.Difference between DataView and DataTable

S.No DataView DataTable

1 Read-only i.e., DataView can be used to select the data.

Read/Write i.e., Datatable can be used to edit or select or delete or insert a data.

2 Is a reference to an existing DataTable. Cannot be populated from scratch; must be instantiated with a reference to an existing DataTable.

Can be created empty and then populated

3 Data is a reference to an existing DataTable, and does not consume space.

Data takes storage space.

Page 4: Dotnet difference questions & answers Compiled-1(updated)

4 Can sort or filter rows without modifying the underlying data. Rows and columns can be hidden and revealed repeatedly.

Can add/edit/delete rows, columns, and data, and all changes are persistent.

5 Can return a DataTable version of the view

Can be cloned

6 A live reference to a DataTable; any changes in the DataTable data is immediately reflected in the view.

Is source data; does not contain references

7 Supports calculated columns, which are columns with a value calculated on the fly by combining or manipulating other columns.

Does not support calculated columns

8 Can hide or show selected columns

No row or column hiding

3.Difference between Connected and Disconnected Environment

S.No Connected Environment Disconnected Environment

1 Connected Environment needs a constantly connection of user to data source while performing any operation.

Disconnected Environment does not need any connection.

2 Only one operation can be performed at a time in connection Environment.

Multiple operations can be performed.

3 DataReader is used in Connection Environment.

DataSet is used in it.

4 It is slower in speed. Disconnected Environment has a good speed.

5 We get updated data in it. There is a problem of dirty read.

Please visit my blog @ http://onlydifferencefaqs.blogspot.in/

Page 5: Dotnet difference questions & answers Compiled-1(updated)

1) What are the differences between Inline code and Code Behind Code?S.No Inline code Code Behind Code1 Its within .aspx file Its in a external class file2 Dynamically compiled Compiled prior to deployment and

linked with .aspx file

2) What are the differences between Global.asax and Web.Config?S.No global.asax web.config1 It is a class file It is an XML file2 There can be only one for an

applicationThere can be many if under different sub-folders

3 Can have Application and Session events

Cannot have Application and Session events

4 Need to be recompiled when changes are made

No need to compile when changes are made

3) What are the Differences between Server.Transfer and Response.Redirect?S.No Server.Transfer Response.Redirect1 The navigation happens on the

server-side ,so client history is not updated

The navigation happens on the client-side ,so client history is updated

2 Data can be persist across the pages using Context.Item collection

Context.Items loses the persistence

3 No Round-trips Makes a Round-trip4 Has Good encapsulation No

4) What is the difference between a custom control and a user control?S.No User Control Custom Control1 Is a file with the .ascx extension Is a file with the .dll extension2 Can be only used with the

applicationCan be used in any number of applications

3 Language dependent They are language independent, a controlcreated in c# can be used in vb.net

4 Cannot be added to Visual studio Toolbox

Can be added to Visual studio Toolbox

5 Inherits from Server controls and easy to create

We have to develop from scratch , so comparativelydifficult

6 Generally used for static content Used when dynamic content is required

5) What is the difference between Caching and Application?S.No Caching Application1 Cache have expire policy Application does not have expire

policy2 Cache does not require explicit

lockingApplication require explicit locking

3 Cache has the Property of timeout, Application variables exist as long as

Page 6: Dotnet difference questions & answers Compiled-1(updated)

which allows us to control the duration of the Objects so cached

the application is alive

4 Output can be cached in 4 ways, Page Output Caching Page Partial Caching DataSource Caching Data Caching

Application does not have options as like Cache object

5 It is accessible to page level to all the users

It is accessible to both page level and application level to all the users

6) What is the difference between web farm and web garden?S.No Web farm Web garden1 A web application running on

multiple servers is called a web farm

A web application running on a single server that has multiple CPUs is called a web garden

7) What is the difference between Application and Session Events?S.No Application Event Session Event1 Application events are used to

initialize objects and data that we do want to make available to all the current sessions of our web application

Session events are used to initialize data that we want to keep throughout individual sessions, but that we do not want to share between sessions

8) What is the difference between Session Cookies and Persistent Cookies?S.No Session Cookies Persistent Cookies1 Session Cookies do not have

expiration datePersistent Cookies have an expiration date. The expiration date indicates to the browser that it should write the cookie to the client’s hard drive

9) What are the differences between Server Controls and HTML Controls?S.No Server Controls HTML Controls1 Server Controls can trigger

control-specific events on the server

HTML Controls can trigger only page-level events on server (postback)

2 Data entered in a server control is maintained across requests. Server controls retain state

Data is not maintained in an HTML control. Data must be saved and restored using page-level scripts

3 The Microsoft .NET Framework provides a set of properties for each server control. Properties allows us to change the server control’s appearance and behavior within server-side code

HTML controls have HTML attributes only

4 Server controls automatically detect browser and adapt display as appropriate

We must detect browser in code or write for least common denominator

10) What are the differences between ViewState and Hidden fields?S.No ViewState Hidden fields1 This is used for pages that will

postback to itselfThis is used for pages that will postback to itself or to another page

Page 7: Dotnet difference questions & answers Compiled-1(updated)

2 This is built in structure for maintaining state of a page

This is not an inbuilt structure

3 Security is more as data is hashed, compressed and encoded

Security is less when compared to ViewState

11) What is the difference between SQL Cache Notification and SQL Cache Invalidation?S.No SQL Cache Notification SQL Cache Invalidation1 Using SQL Cache Notification,

we can generate notifications when the data of a database on which a cached item depends changes

Using SQL Cache Invalidation, we can make a cached item invalid that depends on the data stored in a SQL server database, when the data in the SQL server database is changed

12) What is the difference between absolute time expiration and sliding time expiration?S.No Absolute time expiration Sliding time expiration1 In absolute time expiration, a

cached item expires after the expiration time specifies for it, irrespective of how often it is accessed

In sliding time expiration, the time for which the item is cached is each time incremented by its expiration time if it is accessed before completion of its expiration time

13) What is the difference between adding items into cache through Add() method and Insert() method?S.No Cache.Add() Cache.Insert()1 Cache.Add() method also returns

an object representing the item we have added in the cache ,besides adding the item in the cache

Cache.Insert() method adds only the item in the cache

2 It is not possible to replace an existing item in the cache using the Cache.Add() method

We can replace an existing item in the cache using the Cache.Insert() method

14) What is the difference between page-level caching and fragment caching?S.No Page-level caching Fragment caching1 In Page-level caching, we cache

a whole pageIn Fragment caching, we cache parts of the web page such as a user control added to the web page

15) What is the difference between Label control and Literal control?S.No Label control Literal control1 Final HTML code of a Label

control has an HTML tagFinal HTML code of a Literal control contains only text, which is not surrounded by any HTML tag

16) What is the difference between HyperLink control and LinkButton control?S.No HyperLink control LinkButton control1 A HyperLink control do not have

Click and Command eventsA LinkButton control have Click and Command events, which can be handled in the code behind file of the web page

Page 8: Dotnet difference questions & answers Compiled-1(updated)

17) What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control?S.No HtmlInputCheckBox control HtmlInputRadioButton control1 We can select more than one

HtmlInputCheckBox control from a group of HtmlInputCheckBox controls

We can select only a single HtmlInputRadioButton control from a group of HtmlInputRadioButton controls

18) How a content page differs from a master page?

S.No Content page Master page1 A content page does not have

complete HTML source codeA master page has complete HTML source code inside its source file

19) How will you differentiate a submaster page from a top-level master page?S.No Submaster page Top-level master page1 Like a content page, a submaster

page also does not have complete HTML source code

Top-level master page has complete HTML source code inside its source file

20) What is the difference between a page theme control and a global theme?S.No Page theme Global theme1 A page theme is stored inside a

subfolder of the App_Themes folder of a web application

A global theme is stored inside the Themes folder on a web server

2 It can be applied to individual web pages of the web application

It can be applied to all the web sites on the web server

21) What is the difference between a default skin and a named skin?S.No Default skin Named skin1 A default skin does not have a

SkinId attributeA named skin has a SkinId attribute

2 It is automatically applied to all the controls of the same type present on a web page

It is applied to a control explicitly by setting the SkinId property of the control from the Properties window

22) Differentiate Globalization and LocalizationS.No Globalization Localization1 Globalization is the process of

identifying the specific portion of a web application that needs to be different for different languages and isolating that portion from the core of the web application

Localization is the process of configuring a web application to be supported for a specific language or locale

23) What are the differences between web.config and machine.config?S.No web.config machine.config1 This is automatically created

when we create an ASP.Net web application project

This is automatically installed when we install Visual Studio. Net

2 This is also called application level configuration file

This is also called machine level configuration file

Page 9: Dotnet difference questions & answers Compiled-1(updated)

3 We can have more than one web.config file

Only one machine.config file exists on a server

4 This file inherits setting from the machine.config

This file is at the highest level in the configuration hierarchy

Page 10: Dotnet difference questions & answers Compiled-1(updated)

Difference between Web site and Web application

S.No Web site Web application

1 Can mix vb and c# page in single website.

We can't include c# and vb page in single web application.

2 Can not establish dependencies. We can set up dependencies between multiple projects.

3 Edit individual files after deployment.

Can not edit individual files after deployment without recompiling.

4 Right choice when one developer will responsible for creating and managing entire website.

Right choice for enterprise environments where multiple developers work unitedly for creating,testing and deployment.

i.e.,In web site development, decoupling is not possible.

i.e.,In Web application, different different groups work on various components independently like one group work on domain layer, other work on UI layer.

5 Web site is easier to create than Web application

Web application is more difficult to create than a Web site

Difference between Local storage and cookies

S.No Local storage Cookies

1 Good to store large amount of data, up to 4MB

Good for small amount of data, up to 4KB

2 Easy to work with the JavaScript Difficult to work with JavaScript 3 Local storage data is not sent to the

server on every request (HTTP header) as it is purely at the client side

All data is transferred to and from server, so bandwidth is consumed on every request

4 No way to specify the time out period as the Cookies have

Can specify timeout period so that cookies data are removed from browser

Difference between Session and Cache

S.No Session Cache

1 Ssession retains state per user Cache is used for retaining state for application scoped items.

2 Items put into a session will stay there, until the session ends

Items in the cache can expire (will be removed from cache) after a specified amount of time. And also there is no guaranty that objects will not be removed before their expiration times as ASP.NET remove items from cache when the amount of available memory gets small. This process is called as Scavenging.

3 The session state can be kept external (state server, SQL server) and shared between several instances of our web app (for load balancing).

This is not the case with the cache.

Page 11: Dotnet difference questions & answers Compiled-1(updated)

Difference between Datalist and Repeater

S.No Datalist Repeater

1 Datalist supports multiple columns displaying and using repeat columns property

Repeater doesn't support multiple columns display,no repeat columns property

2 Datalist supports styles for formating templates data[headerstyle,...]

Repeater does not provide styles

3 Datalist rendering output[html content]will be slow compare with repeater.

Repeater performanace is better than Datalist

Summary:

If the requirement can achieve using repeater and datalist,choose repeater for better performance

Page 12: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between ASP.NET and PHP

S.No ASP.NET PHP

1 Technology Availability:

ASP.NET was launched by Microsoft in the year 2002.

Technology Availability:

PHP was launched by Rasmus Lerdorf in the year 1995.

2 Database:

ASP.Net uses MS-SQL for connecting database but MS-SQL can not be availed free from Microsoft.

Database:

For point of database connectivity PHP uses MySQL for the purpose of database connectivitybecasue its highly flexiblilty nature. Another important fact is that it will incurextra expenditure because MySQL can be accessed for free.

3 Cost: We need to install Internet Information Server (IIS)on a Windows server platformif you want to run ASP.Net program. As Windows server platform is not a free product,the cost of production is bounded to be increased.

Cost:

Linux can be used for running PHP programs and Linux is free operating system. Therefore,the cost of developing a website in PHP language is remarkably low

4 Run Time :

It has been observed that ASP.Net code runs slower than PHP code. This is becauseASP.Net utilizes server space while running

Run Time: Whereas inbuilt memory space is used by PHP while running.

5 Coding Simplicity:

ASP.Net codes are somewhat complicated and a web developer needs to work hard to get the hang of it

Coding Simplicity: PHP codes are very simple and a programmer does not haveto make a diligent effort because it is comparatively easier than other types of programming languages.

6 Platform Connectivity Issue :

ASP.NET codes are usually run on Windows platforms but if you install ASP-Apache inthe server than it can run on Linux platform as well.

Platform Connectivity Issue: PHP has a unique advantagein this issue. Its codes can be linked with different types of platforms such asWindows, Linux and UNIX.

7 Cost of Tools : Cost of Tools :

Page 13: Dotnet difference questions & answers Compiled-1(updated)

There is no such free tools are available for ASP.Net.

PHP codes are available for free in various forums and blogs as it is a open source software. Furthermore, some useful tools that can be used in PHP are also availablefor free

8 Language Support :

The syntax of ASP.Net is more or less similar to that of Visual basic syntax and this is all but simple.

Language Support :

The codes that are used in PHP are very much similar to that of C++ language and its syntax resembles the syntax used in C and C++. Therefore, if you have a fair knowledge in C++ or C, you will not face any difficulty while coding PHP language.

9 Security :

ASP. Net is reputedfor creating sophisticated techniques to ensure the safety of confidential data.This is the reason why government organizations opt for ASP.Net.

Security :

Though PHP can offer enough measures for ensuring data security

2.Difference between ASP and ASP.NET

S.No ASP ASP.NET

1 ASP is a request response model. ASP.NET is a programming model that is event driven.

2 ASP code is an interpreted language that is interpreted by the script engine.

ASP.NET is a compiled CLR code that will be executed on the Server.

3 HTML and the coding logic are mixed in ASP.

The code and design logic is separated in ASP.NET.

4 To develop and debug ASP application, there are very limited tools.

ASP.NET application can be developed and debugged using various tools including the leading Visual Studio .NET tool.

5 ASP has limited support to Object Oriented Programming principles.

ASP.NET is a complete Object Oriented Programming language.

6 Session management and application state management is

ASP.NET extends complete support for session management and

Page 14: Dotnet difference questions & answers Compiled-1(updated)

very limited in ASP. application state management.

7 Error handling system is poor in ASP.

ASP.NET offers complete error handling and exception handling services.

8 ASP does not offer any in-built support for the XML.

In ASP.NET, data exchange is easily performed using XML support.

9 Data source support is not fully distributed in ASP.

Data source support is fully distributed in ASP.NET.

3.Difference between ASP.NET and VB.NET

S.No ASP.NET VB.NET

1 ASP.NET is web technology that is used in building web applications and websites.

VB.NET is a language that is used in writing programs that are utilizing the ASP.NET framework.

2 ASP.NET is a server side technology that is language independent. Any .NET languages such as C#, VB.NET can be used to develop web applications through ASP.NET.

VB.NET is a .NET programming language. VB.NET is used to create ASP.NET web applications or windows applications using Visual Studio Windows Forms Designer or mobile applications or console applications or applications for variety of other purposes.

3 ASP.NET is included within the .NET framework.

For example, ASP.NET contains the text boxes and the controls that can be dragged and dropped into a web form.

VB.NET is not part of .NET framework.

For example, VB.NET is the code that is written on various events of text boxes and controls to make them function as per the requirement.

4 ASP.NET contains server controls.

VB.NET does not include server controls.

5 ASP.NET can support all .NET languages.

VB.NET can support only scripting languages.

Page 15: Dotnet difference questions & answers Compiled-1(updated)

4.Difference between Java and .NET

S.No Java .NET

1 JAVA is developed by ‘Sun Microsystem‘

.NET is developed by ‘Microsoft’.

2 JAVA is a programming language

.NET is a framework that supports many programming languages like C#,ASP,VB.

3 In JAVA, JVM(Java Virtual Machine) execute the code and convert source code to byte code.

In .NET CLR(common language Runtime) execute the code with two phase compilation.

4 JAVA can run on any operating system

.NET can run only on windows/IIS.

5 But in JAVA it depends upon the programmer to destroy the garbage memory.

Although .NET support both explicit and implicit garbage collection,especially,in .NET the garbage collector destroy the garbage value in an efficient manner as compared to JAVA.

6 JDBC is used for database connection in JAVA

ADO .NET is use for database connection in .NET.

7 For java many third party IDEs are available.

.net has a standard development IDE i.e. Microsoft Visual Studio

8 But web application in java run on any operating system.

Both windows and web applications can developed by .net but it will be more better to go for windows application with .NET . you can also go for web application with .NET but it will only hosted on windows server.

9 Exception Handling in Java is harder than .NET

Exception Handling in .NET is simpler than JAVA.

10 JAVA uses bootclasspath for completely trusted codes.

.NET uses GAC(Global Assembly Cache) and keep trusted assemblies.

11 Java is less secure than .NET while providing security

JAVA and .NET both have similar security goals. But .NET is more secure because of its simple and clean designs.

12 Java JDBC which requires multiple round trips to data base. Hence, performance is lesser than .NET

.Net due to disconnected data access through ADO.Net has high level of performance against Java JDBC

Page 16: Dotnet difference questions & answers Compiled-1(updated)

13 Development is comparatively slower.

Due to Microsoft Visual Studio, development is faster.

14 Java applications development can be done on even less configuration computer system.

Microsoft Visual Studio installation requires higher configuration system.

15 Java can only communicate with java programs

.Net is the platform itself for a multitude of languages. One can use C, C++ and VB to program upon .net. These programs interact with each other using common methods. these common methods are defined by .Net, and are used by the programs to communicate with each other without worry about that language the program was written in. the machine running the program/s will need the .Net platform to be installed.

Please visit my blog @ http://onlydifferencefaqs.blogspot.in/

Page 17: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between HTTP and HTTPS

S.No HTTP HTTPS

1 URL begins with “http://" in case of HTTP

URL begins with “https://” in case of HTTPS.

2 HTTP is unsecured HTTPS is secured.

3 HTTP uses port 80 for communication

HTTPS uses port 443 for communication.

4 HTTP operates at Application Layer

HTTPS operates at Transport Layer.

5 No encryption is there in HTTP HTTPS uses encryption.

6 No certificates required in HTTP certificates required in HTTPS.

7 Most internet forums will probably fall into this category. Because these are open discussion forums, secured access is generally not required

HTTPS should be used in Banking Websites, Payment Gateway, Shopping Websites, Login Pages, Emails (Gmail offers HTTPS by default in Chrome browser) and Corporate Sector Websites. For example:

PayPal: https://www.paypal.comGoogle AdSense: https://www.google.com/adsense/

2.Difference between GET and POST methods

S.No GET POST

1 Post Mechanism:

GET request is sent via URL.

Post Mechanism:

Post request is sent via HTTP request body or we can say internally.

2 Form Default Method:

GET request is the default method.

Form Default Method:

We have to specify POST method within form tag like <Form method="POST".......

3 Security:

Since GET request is sent via URL, so that we can not use this method for sensitive data.

Security:

Since Post request encapsulated name pair values in HTTP request body, so that we can submit sensitive data through POST method.

Page 18: Dotnet difference questions & answers Compiled-1(updated)

4 Length:

GET request has a limitation on its length. The good practice is never allow more than 255 characters.

Length:

POST request has no major limitation.

5 Caching or Bookmarking:

GET request will be better for caching and bookmarking.

Caching or Bookmarking:

POST request is not better for caching and bookmarking.

6 SEO:

GET request is SEO friendly.

SEO:

POST request is not SEO friendly.

7 Data Type:

GET request always submits data as TEXT.

Data Type:

POST request has no restriction.

8 Best Example:

SEARCH is the best example for GET request.

Best Example:

LOGIN is the best example for POST request.

9 HTTP Request Message Format:

1 GET /path/file.html?SearchText=Interview_Question HTTP/1.02 From: [email protected] User-Agent: HTTPTool/1.04 [blank line here]

HTTP Request Message Format:

1 POST /path/script.cgi HTTP/1.02 From: [email protected] User-Agent: HTTPTool/1.04 Content-Type: application/x-www-form-urlencoded5 Content-Length: 867 Code=132

Some comments on the limit on QueryString / GET / URL parameters Length:

1. 255 bytes length is fine, because some older browser may not support more than that.2. Opera supports ~4050 characters.3. IE 4.0+ supports exactly 2083 characters.4. Netscape 3 -> 4.78 support up to 8192 characters.5. There is no limit on the number of parameters on a URL, but only on the length.6. The number of characters will be significantly reduced if we have special characters like spaces that need to be URLEncoded (e.g. converted to the '%20').7. If we are closer to the length limit better use POST method instead of GET method.

Page 19: Dotnet difference questions & answers Compiled-1(updated)

3.Difference between User Controls and Master Pages

S.No User Controls Master Pages

1 Its extension is .ascx. Its extension is .Master.

2 Code file: .ascx.cs or .ascx.vb code file: .master.cs or .master.vb extension

3 A page can have more than one User Controls.

Only one master page can be assigned to a web page

4 It does not contain Contentplaceholder and this makes it somewhat difficult in providing proper layout and alignment for large designs.

It contains ContentPlaceHolder.

5 Suitable for small designs(Ex: logout button on every .aspx page.)

More suitable for large designs(ex: defining the complete layout of .aspx page)

6 Register Tag is added when we drag and drop a user control onto the .aspx page.

MasterPageFile attribute is added in the Page directive of the .aspx page when a Master Page is referenced in .aspx page.

7 Can be attached dynamically using LoadControl method.PreInit event is not mandatory in their case for dynamic attachment.

Can be referenced using Web.Config file also or dynamically by writing code in PreInit event.

4.Difference between Build and Rebuild

S.No Build Rebuild

1 A build compiles only the files and projects that have changed.

A rebuild rebuilds all projects and files in the solution irrelevant of whether they have changed or not.

2 Build does not updates the xml-documentation files

Rebuild updates the xml-documentation files

Note: Sometimes,rebuild is necessary to make the build successful. Because, Rebuild cleans Solution to delete any intermediate and output files, leaving only the project and component files, from which new instances of the intermediate and output files can then be built.

Page 20: Dotnet difference questions & answers Compiled-1(updated)

5.Difference between generic handler and http handler

S.No Generic Handler Http Handler

1 Generic handler has a handler which can be accessed by url with .ashx extension

http handler is required to be configured in web.config against extension in web.config.It does not have any extension

2 Typical example of generic handler are creating thumbnails of images

For http handler, page handler which serves .aspx extension request and give response.

Please visit my blog @ http://onlydifferencefaqs.blogspot.in/

Page 21: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between ViewState and SessionState

S.No ViewState SessionState

1 View state is maintained in page level only.

Session state is maintained in session level.

2 View state of one page is not visible in another page.i.e., when user requests another page previous page data will be no longer available.

Session state value is available in all pages within a user session.i.e., The data will be no longer available if user close the browser or session timeout occurs.

3 View state information stored in client only.

Session state information stored in server.

4 View state persist the values of particular page in the client (browser) when post back operation done.

Session state persist the data of particular user in the server. This data available till user close the browser or session time completes.

5 View state used to persist page-instance-specific data.

Session state used to persist the user-specific data on the server side.

2.Difference between ViewState and ControlState

S.No ViewState ControlState

1 ViewState can be disabled Control State cannot be disabled.

2 ViewState is implemented by using EnableViewState property of a control to true.

Control State works even when EnableViewState is off. To use Control State (for example in a custom control) we have to override OnInit method,call RegisterRequiresControlState method in OnInit method and then override the SaveControlState and LoadControlState methods.

3 ViewState is used to maintain page-level state for large data

Control State is used for small data only. eg: maintain clicked page number in a GridView even when EnableViewState is off

Page 22: Dotnet difference questions & answers Compiled-1(updated)

3.Difference between SessionState and Cookies

S.No SessionState Cookies

1 Session can store any type of data because the value is of datatype of "object"

Cookies can store only "string" datatype

2 These are stored at Server side They are stored at Client side

3 Session are secured because it is stored in binary format/encrypted form and it gets decrypted at server

Cookie is non-secure since stored in text format at client side

4 Session is independent for every client i.e individual for every client

Cookies may or may not be individual for every client

5 There is no limitation on size or number of sessions to be used in an application

Due to cookies network traffic will increase.Size of cookie is limited to 40 and number of cookies to be used is restricted to 20.

6 For all conditions/situations we can use sessions

Only in few situations we can use cookies because of no security

7 We cannot disable the sessions.Sessions can be used without cookies also(by disabling cookies)

We can disable cookies

8 The disadvantage of session is that it is a burden/overhead on server

Since the value is string there is no security

9 Sessions are called as Non-Persistent cookies because its life time can be set manually

We have persistent and non-persistent cookies

Please visit my blog @ http://onlydifferencefaqs.blogspot.in/

Page 23: Dotnet difference questions & answers Compiled-1(updated)

New features of ASP.Net 2.0, ASP.Net 3.0 and ASP.Net 3.5- A Comparative Chart

SNo ASP.Net 2.0 ASP.Net 3.0 ASP.Net 3.51 a) Generics

b) Anonymous methods

c) Partial classd) Nullable typee) The new API gives

a fine grain control on the behavior of the runtime with regards to multithreading, memory allocation, assembly loading and more

f) Full 64-bit support for both the x64 and the IA64 hardware platforms

g) New personalization features for ASP.NET, such as support for themes, skins and webparts.

h) .NET Micro Framework

a) Windows Communication Foundation (WCF), formerly called Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services.

b) Windows Presentation Foundation (WPF), formerly called Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies.

c) Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows.

d) Windows CardSpace, formerly called InfoCard; a software component which securely stores a person's digital identities and

a) Linq for SQL, XML, Dataset, Object

b) Addin systemc) p2p base classd) Active directorye) ASP.NET Ajaxf) Anonymous types with

static type inferenceg) Paging support for

ADO.NETh) ADO.NET synchronization

API to synchronize local caches and server side datastores.

i) Asynchronous network I/O API

j) Support for HTTP pipelining and syndication feeds.

k) New System.CodeDom namespace.

Page 24: Dotnet difference questions & answers Compiled-1(updated)

provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website

Page 25: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between C# 3.5 and C# 4.0

S.No C# 3.5 C# 4.0

1 C# 3.5 does not support dynamic programming.

C# 4.0 supports dynamic programming through dynamic objects.

2 The dynamic keyword is not recognized in C# 3.5.

In C# 4.0, dynamic keyword is associated with objects to represent them as dynamic objects.

3 Dynamic variables cannot be created in C# 3.5.

C# 4.0 allows creation of dynamic variables.

4 In C# 3.5, method parameters cannot be specified with default values. C# 3.5 does not support optional parameters.

In C# 4.0, the method parameters can be specified with default values using optional parameters.

5 In C# 3.5, method parameters have to be specified in the same order as in method declaration in the method call. C# 3.5 does not provide named parameters.

C# 4.0 provides named parameters to represent the values of method parameters without following the order of declaration.

6 In C# 3.5, usage of ref keyword is mandatory while executing methods which are supplied by the COM interfaces.

In C# 4.0, usage of ref keyword is optional while executing methods which are supplied by the COM interfaces.

7 The COM object’s indexed properties are not recognized in C# 3.5.

The COM object’s indexed properties are recognized in C# 4.0.

8 Co-variance and contra-variance are not supported in Generics of C# 3.5.

C# 4.0 enhances Generics by introducing co-variance and contra-variance.

2.Difference between C# and VB.NET

S.No C# VB.NET

1 In C#, variables are declared using declarators.

In VB.NET, the variables are declared using keywords such as private, protected, friend, public, static, shared and Dim.

2 In C#, an object can only be created using new.

In VB.NET, an object can be created using new and CreateObject().

3 In C#, void is specified as the return type when a method does

In VB.NET, Sub is used in method declaration to indicate that the method

Page 26: Dotnet difference questions & answers Compiled-1(updated)

not return a value. does not return any value.

4 In C#, no keyword is required to indicate an overloaded method.

In VB.NET, Overloads keyword is used to indicate an overloaded method.

5 The current object is referred using this pointer in C#.

The current object is referred as me in VB.NET.

6 Non virtual call cannot be made in C#.

To make a non-virtual call to the current object’s virtual method, MyClass is used in VB.NET.

7 Compound data type is declared in C# using class, struct and interface.

Compound data type is declared in VB.NET using Structure.

8 In C#, constructors are used to initialize an object.

In VB.NET, Sub New() is used to initialize the newly created object.

9 Object cleanup can be explicitly done by destructor in C#.

Object cleanup can be done by using Finalize method in VB.NET.

10 In C#, an object is subject to asynchronous modification using volatile keyword.

In VB.NET, an object cannot be modified in an asynchronous way.

11 In C#, all the variables have to be declared before being used.

In VB.NET, variables can be forced for explicit declaration using Option Explicit.

12 In C#, default property is defined by using indexers.

In VB.NET, default property is defined using Default.

13 In C#, base class can be referred using the keyword ‘base’.

In VB.NET, base class can be referred using the keyword ‘MyBase’.

14 Abstract class of C# can only be inherited and not instantiated.

MustInherit keyword of VB.NET is used to denote that a class can only be inherited and not instantiated.

15 Sealed keyword of C# is used to denote that a class cannot be inherited.

NotInheritable keyword of VB.NET denotes that the class cannot involve in inheritance.

16 Division can be performed in C# using / operator.

Division can be performed in VB.NET using \ operator.

17 Remainder of division can be retrieved using mod operator of C#.

Remainder of division can be retrieved using %.

18 C# does not have exponentiation operator.

In VB.NET, exponentiation can be performed using ^ operator.

Page 27: Dotnet difference questions & answers Compiled-1(updated)

19 C# has Bitwise operators namely &,| and ^.

Bitwise operators in VB.NET are And, Or, Xor.

20 Object reference variables can be compared using == operator in C#.

Object reference variables can be compared using Is operator in VB.NET.

21 The short ciruit operators in C# are && (Boolean AND) and || (Boolean OR).

The short circuit operators in VB.NET are AndAlso (Boolean AND) and OrElse (Boolean OR).

3.Difference between C# and C++

S.No C# C++

1 C# is a high level language that is component oriented.

C++ is a low level and indeed platform neutral programming language.

2 When compiled, C# code is converted into Intermediate language code. This intermediate language code is converted into executable code through the process called Just-In-Time compilation.

When compiled, C++ code is converted into assembly language code.

3 In C#, memory management is automatically handled by garbage collector.

In C++, the memory that is allocated in the heap dynamically has to be explicitly deleted.

4 In C# Switch Statement, the test variable can be a string.

In C++ Switch Statement, the test variable cannot be a string.

5 In C# switch statement, when break statement is not given, the fall through will not happen to the next case statement if the current case statement has any code.

In C++ switch statement, when break statement is not given, the fall through will happen to the next case statement even if the current case statement has any code.

6 In addition to for, while and do..while, C# has another flow control statement called for each.

C++ does not contain for each statement.

7 C# struts can contain only value types. The struts is sealed and it cannot have a default no-argument constructor.

C++ struts behave like classes except that the default access is public instead of private.

8 In C#, delegates, events and properties can also be specified as class members.

In C++, only variables, constructors, functions, operator overloads and destructors can be class members.

Page 28: Dotnet difference questions & answers Compiled-1(updated)

Delegates, events and properties cannot be specified as class members.

9 In C#, the end of the class definition has a closing brace alone.

In C++, the end of the class definition has a closing brace followed by a semicolon.

10 The access modifiers in C# are public, private, protected, internal and protected internal.

The access modifiers in C++ are public, private, protected. C++ does not have internal and protected internal access modifiers.

11 C# has finally block in exception handling mechanism. The code statements in the finally block will be executed once irrespective of exception occurrence.

C++ does not have finally block in exception handling mechanism.

12 The exception in C# can only throw a class that is derived from the System.Exception class.

The exception in C++ can throw any class.

13 C# does not have the concept of function pointers. C# has a similar concept called Delegates.

C++ has the concept of function pointers.

Please visit my blog @ http://onlydifferencefaqs.blogspot.in/

Page 29: Dotnet difference questions & answers Compiled-1(updated)

1. Difference between Factory Pattern and Abstract Factory Pattern

S.No Factory Pattern Abstract Factory Pattern

1 Create object through inheritance Create object through composition

2 Produce only one product Produce families of products

3 Implements code in the abstract creator that make use of the concrete type that sub class produces

Concrete factories implements factory method to create product

2.Difference between Abstract Factory Pattern And Builder Pattern

S.No Builder Pattern Abstract Factory Pattern

1 In Builder Pattern, there will be one Director class which will instruct Builder class to build the different parts/properties of our object and finally retrieve the object.

Abstract Factory Pattern will return the instance directly.

2 It will have reference to the created object.

It does not keep the track of it's created object.

3.Difference between Builder Pattern And Composite Pattern

S.No Builder Pattern Composite Pattern

1 It is used to create group of objects of predefined types.

It creates Parent - Child relations between our objects.

4.Difference between MVC and MVP

S.No MVP MVC

1 MVP is a bit more complex to implement than MVC .Also, it has additional layer for view interfaces.

MVC is easier to implement than MVP.

2 The request is always received by the View and delegated to the presenter which in turn gets the data does the processing

The request is received by the controller which in turn gets the required data and loads up the appropriate view

3 The presentation and view logic an be unit tested as the view is loosely coupled.

The controller logic can be unit tested. Note: We can unit test view if we are using Razor view engine. ASPX viewengine are not that easily unit testable

4 MVP is best suitable for Windows Programming as the flow naturally tend towards this pattern.

MVC is best suitable for Web Programming.

Page 30: Dotnet difference questions & answers Compiled-1(updated)

5.Difference between Proxy Pattern and Observer Pattern

S.No Proxy Pattern Observer Pattern

1 The Proxy Pattern is used for wrapping a kind of special object with 1 or more other objects.

The Observer Pattern is used by a publisher object to notify subscriber objects with information.

2 Either because we don't always have the wrapped object or because it needs to be managed in a certain way that can be simplified via the proxy object(s). This is kind of a way to exchange the API of an existing class with a proxy class. We are not just talking events here, but whatever kind of functionality to define via the proxy object instead of the real object.

The publisher object does not know the subscribing objects - except that the conform to a certain subscriber interface. This is a very flexible pattern for distributing events, since those that wants to listen on certain object has the power to do so without changing the code of the publishing object.

6. Difference between Singleton Pattern and a static class

S.No Singleton Pattern static class

1 Singleton pattern maintains single instance.

We cannot create instance for static class.

2 A singleton can extend classes and implement interfaces.

A static class cannot .Note: It can extend classes, but it does not inherit their instance members.

3 A singleton can be initialized lazily or asynchronously.

A static class is generally initialized when it is first loaded, leading to potential class loader issues.

4 Singletons can be handled polymorphically without forcing their users to assume that there is only one instance.

static class cannot be handled polymorphically.

5 Singleton Class can have value when Class object instantiated between server and client, such a way if three client want to have a shared data between them Singleton can be used.Thats why singleton class can be used for state mangement in stateless scenarios like shopping cart scenario.

Static are always just shared and have no instance but multiple references.

6 We can pass singleton object as parameter

We cannot pass parameter in static class

7 Singleton provides flexibility and also provides sort of a mechanism to control object creation based on various requirements. They can be extended as well if need arises. In other words we are not always tied to a particular implementation. With Singleton we

Static classes once defined could not accomodate any future design changes as by design static classes are rigid and cannot be extended.

Page 31: Dotnet difference questions & answers Compiled-1(updated)

have the flexibility to make changes as when situation demands.

7.Difference between Strategy and Inversion of Control (IOC)

S.No Strategy Pattern Inversion of Control (IOC) Pattern

1 The strategy pattern is useful when we want classes to depend on the interface rather than the implementation.And we can easily swap out behavior depending on which concrete implementation we provide.

Inversion of Control/Dependency Injection (IoC/DI) comes into play when we want the concrete strategy implementation injected into a class. For example, we could use the DI Framework Ninject and configure it so that it will know which concrete strategy implementation to inject into a class in specific scenarios.

Note: Strategy is just one of the ways that IOC is implemented

8.DIfference between IDictionary and Dictionary

S.No IDictionary Dictionary

1 IDictionary is just a contract, abstraction Dictionary is concrete implementation.

2 It is recommended for example to expect as argument an IDictionary rather than concrete Dictionary, or to expose property of IDictionary rather than Dictionary, because this promotes loose coupling. Than we are able to change underlying objects in the future without affecting those who use your object.

Argument or Property is not required for Dictionary.

9.Difference between Factory Pattern and Dependency Injection

S.No Factory Pattern Dependency Injection(DI)

1 Factory is used to create objects DI is used to move the responsibility of creating an object outside the main code.

2 Some of the well known framework available for DI are

1. Unity Application Block (Microsoft)2. Ninject3. StructureMap4. Castle Windsor5. Munq/Funq6. Autofac

Page 32: Dotnet difference questions & answers Compiled-1(updated)

10.Difference between String.Clone() and String.Copy() method

S.No String.Clone() String.Copy()

1 Returns a reference to this instance of String.

i.e., it gives pointer value(ie Current memory Reference)

Creates a new instance of String with the same value as a specified String.

i.e., it creates an instance in Heap Memory and gives pointer value(ie New Memory Reference)

11.Difference between Strategy Pattern and Factory Pattern

S.No Strategy Pattern Factory Pattern

1 Strategy's sole intent to is to provide a mechanism to select different algorithm.

Factory's sole purpose is to create objects .

2 We cannot use "strategy" to create objects of "factory".

We can use "factory" to create objects of "strategy".

12.Difference between Proxy and Adaptor

S.No Proxy Pattern Adaptor Pattern

1 Proxy on the other hand represents a standin object for the real object. This is required when the real object is complex to create, is not available, or for authentication purpose. For e.g. web service proxy, proxy authentication server etc.

Proxy can be categorized into

Virtual Proxy Remote Proxy Protection Proxy

Adapter is used to adapt to incompatible interfaces. It's more directed from the client (those who consume the object) perspective. A client expects an interface to be of particular type and adapter plays a role in filling that gap.

It's more from making it easier for the client to adapt to other third party libraries within there own by adapting to it.

13.Difference between Decorator and Visitor

S.No Decorator Pattern Visitor Pattern

1 Decorator may have just a single object to customize.

Visitor has a tree of objects to be worked upon.

2 Decorator does not require a traverser for successful implementation.

Visitor requires a traverser for successful implementation.

3 Decorator pattern is a structural pattern that help us to add new function to an object in the run time , note that in the run time not design time .

Visitor pattern is Behavioral pattern that seperate the data structure from the operation (functionality ) that work on it , this mean we can add different operation on the same data structure

Page 33: Dotnet difference questions & answers Compiled-1(updated)
Page 34: Dotnet difference questions & answers Compiled-1(updated)

Difference between ASP.Net 2.0 and ASP.Net 3.5

SNo

Feature ASP.Net 2.0 ASP.Net 3.5

1 New Features

ASP.Net 2.0 includes the following as new features,

a) Master Pagesb) Profilesc) GridView Control

ASP.Net 3.5 includes the following as new features,

a) ListView Controlb) DataPager Controlc) Nested Master Pagesd) LinqDataSource Control

2 Multi-targeting

ASP.Net 2.0 does not support Multi-Targeting environment.

ASP.Net 3.5 supports multi-targeting. It means that we choose from a drop-down list whether to have Visual Studio 2008 build applications against the ASP.NET 2.0, 3.0, or 3.5 frameworks.

3 AJAX Support

There is no in-built support for AJAX in ASP.Net 2.0. Instead, it has to be downloaded and installed.

In ASP.Net 3.5, AJAX is integrated into the .NET Framework, thereby making the process of building intuitive cool user interfaces easier.

4 Siverlight Support

It does not support Siverlight.

It supports Siverlight.

5 Javascript Debugging

It does not provide Javascript debugging.

It provides Javascript debugging.

6 LINQ Support

It does not support LINQ. It Supports Language Integrated Query (LINQ).

Page 35: Dotnet difference questions & answers Compiled-1(updated)

1) What is the difference between CCW and RCW?

S.No CCW RCW1 COM to .NET communication

happens through COM Callable Wrapper

.NET to COM Communication happens through Runtime Callable Wrapper

2) What are the differences between Dll and Exe?

S.No Dll Exe1 Objects of Dlls can be created Objects of Exe cannot be created2 Dll is In-Process Exe is Out-Process3 It cannot be started as a standalone It can be started as a standalone

3) What are the differences between Managed Code and Unmanaged Code?

S.No Managed Code Unmanaged Code1 It is executed under CLR It is not executed under CLR2 It compiles to intermediate language It compiles directly to machine code3 It provides services like security,

exception handling, garbage collection etc

It does not provide security, exception handling, garbage collection etc

4 It can access both managed and unmanaged code

It can access only unmanaged code

Page 36: Dotnet difference questions & answers Compiled-1(updated)

Difference between hash table and arraylist

S.No Arraylist Hash table

1 Array List is a List Hash Table is a map

2 Here, we can only add items to the list Here, we can add data with the key

3 Retrieving data using Arraylist is slower than Hashtable because If we want to find something in a arraylist we have to go through each value in arraylist.

Retrieving by key in Hashtable is faster than retrieving in Arraylist because If we want to find something in a hashtable we dont have to go through each value in hashtable, instead search for key values and is faster.

Difference between Hash Table and Arrays

Hash Table Array

Hash table stores data as name,value pair. Array stores only value

To access value from hash table, we need to pass name.

In array, to access value , we need to pass index number.

We can store different type of data in hash table, say int,string etc.

In array ,we can store only similartype of data.

Difference between Dictionary and Hashtable

Dictionary Hashtable

Dictionary is a generic type Hashtable is not generic type.

In Dictionary we need to specify the types of both the key and the corresponding value.The value represents the actual object stored and the key represents a means to identify a particular object.

Hashtable is a collection of name/value pairs that are organised on the basis of hash code of the key being specified.

In Dictionary public static members are type safe but any instance members are not type safe.

Hashtable is thread safe for use by multiple reader threads and a single writing thread.

We cannot use Dictionary with Web Services The reason is no web service standard supports generic standard.

We can use Hashtable withWeb Services

Dictionary is aster than Hashtable because boxing is not required.

It is slower than dictionary because to retrieve a value we must cast it as its actual type, because it will be returned via object reference.

Page 37: Dotnet difference questions & answers Compiled-1(updated)

Difference between array and stack

Array Stack

An array can be multi-dimensional Stack is strictly one-dimensional

An array allows direct access to any of its elements

With a stack, only the 'top' element is directly accessible; to access other elements of a stack, we must go through them in order, until we get to the one we want

Difference between Stack and Heap

Stack Heap

Memory will be allocated at the compile time. Memory will be allocated at the run time.

Here the memory is allocated by the compiler. Here the memory is allocated by the user.

Memory will be allocated only in sequential locations.

Memory will be allocated in sequential locations and non- sequential locations.

The memory will also be deleted by the compiler.

The memory must be deleted explicitly by the user.

There is lot of chance of memory wastage. There is no chance of memory wastage if the memory is handled perfectly.

Difference between Array and ArrayList

Array ArrayList

They are fixed length. They are resizable and variable length

They are compiled strong type collection. They are flexible and can accommodate any data types.

Because arrays are of fixed size and strong type collection performance is faster.

In arraylist lots of boxing and unboxing are done there for its performance is slower.

Array is in the System namespace ArrayList is in the System.Collections namespace.

Ex:Char[] vowel=new Char[]; Ex:ArrayList a_list=new ArrayList();

Page 38: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between for and foreach loop

S.No For loop Foreach loop

1 In case of for the variable of the loop is always be int only.

In case of Foreach the variable of the loop while be same as the type of values under the array.

2 The For loop executes the statement or block of statements repeatedly until specified expression evaluates to false.

The Foreach statement repeats a group of embedded statements for each element in an array or an object collection.

3 There is need to specify the loop bounds(Minimum, Maximum).

We do not need to specify the loop bounds minimum or maximum.

4 example: using sytem; class class1 { static void Main() { int j=0; for(int i=0; i<=10;i++) { j=j+1; } Console.ReadLine(); } }

example: using sytem; class class1 { static void Main() { int j=0; int[] arr=new int[] {0,3,5,2,55,34,643,42,23}; foreach(int i in arr) { j=j+1; } Console.ReadLine(); } }

2. Difference between Covariance and Contravariance

S.No Covariance Contravariance

1 Converting from a broader type to a specific type is called co-variance.If B is derived from A and B relates to A, then we can assign A to B. Like A=B. This is Covariance.

Converting from a more specific type to a broader type is called contra-variance. If B is derived from A and B relates to A, then we can assign B to A. Like B= A. This is Contravariance.

2 Co-variance is guaranteed to work without any loss of information during conversion. So, most languages also provide facility for implicit conversion.

e.g. Assuming dog and cat inherits from animal, when you convert from animal type to dog or cat, it is called co-variance.

Contra-variance on the other hand is not guaranteed to work without loss of data. As such an explicit cast is required.

e.g. Converting from cat or dog to animal is called contra-variance, because not all features (properties/methods) of cat or dog is present in animal.

3 Example:

Page 39: Dotnet difference questions & answers Compiled-1(updated)

class Fruit { }

class Mango : Fruit { }

class Program

{

delegate T Func<out T>();

delegate void Action<in T>(T a);

static void Main(string[] args)

{

// Covariance

Func<Mango> mango = () => new Mango();

Func<Fruit> fruit = mango;

// Contravariance

Action<Fruit> fr = (frt) =>

{ Console.WriteLine(frt); };

Action<Mango> man = fr;

}

}

4 Note:

1. Co-variance and contra-variance is possible only with reference types; value types are invariant.

2. In .NET 4.0, the support for co-variance and contra-variance has been extended to generic types. No now we can apply co-variance and contra-variance to Lists etc. (e.g. IEnumerable etc.) that implement a common interface. This was not possible with .NET versions 3.5 and earlier.

Page 40: Dotnet difference questions & answers Compiled-1(updated)

3.Difference between IList and IEnumerable

S.No IList IEnumerable

1 IList is used to access an element in a specific position/index in a list.

IEnumerable is a forward only collection, it can not move backward and between the items.

2 IList is useful when we want to Add or remove items from the list.

IEnumerable does not support add or remove items from the list.

3 IList can find out the no of elements in the collection without iterating the collection.

Using IEnumerable we can find out the no of elements in the collection after iterating the collection.

4 IList does not support filtering. IEnumerable supports filtering.

4.Difference between IEnumerable and IQueryable

S.No IEnumerable IQueryable

1 IEnumerable exists in System.Collections Namespace.

IQueryable exists in System.Linq Namespace.

2 IEnumerable is best to query data from in-memory collections like List, Array etc.

IQueryable is best to query data from out-memory (like remote database, service) collections.

3 While query data from database, IEnumerable execute select query on server side, load data in-memory on client side and then filter data.

While query data from database, IEnumerable execute select query on server side with all filters.

4 IEnumerable is suitable for LINQ to Object and LINQ to XML queries.

IQueryable is suitable for LINQ to SQL queries.

5 IEnumerable does not supports custom query.

IQueryable supports custom query using CreateQuery and Execute methods.

6 IEnumerable does not support lazy loading. Hence not suitable for paging like scenarios.

IQueryable support lazy loading. Hence it is suitable for paging like scenarios.

7 Extension methods supports by IEnumerable takes functional objects.

Extension methods supports by IEnumerable takes expression objects means expression tree.

8 IEnumerable Example

MyDataContext dc = new MyDataContext (); IEnumerable list = dc.loyees.Where(p => p.Name.StartsWith("S")); list = list.Take(10);

Generated SQL statements of above query will be :

SELECT [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0] WHERE [t0].[EmpName] LIKE @p0

Page 41: Dotnet difference questions & answers Compiled-1(updated)

Note: In this query "top 10" is missing since IEnumerable filters records on client side

IQueryable Example

MyDataContext dc = new MyDataContext (); IEnumerable list = dc.loyees.Where(p => p.Name.StartsWith("S")); list = list.Take(10);

Generated SQL statements of above query will be :

SELECT TOP 10 [t0].[EmpID], [t0].[EmpName], [t0].[Salary] FROM [Employee] AS [t0] WHERE [t0].[EmpName] LIKE @p0

Note: In this query "top 10" is exist since IQueryable executes query in SQL server with all filters.

5.Difference between IEnumerable and IEnumerator

S.No IEnumerable IEnumerator

1 The IEnumerable interface is a generic interface that provides an abstraction for looping over elements. In addition to providing foreach support, it allows us to tap into the useful extension methods in the System.Linq namespace, opening up a lot of advanced functionality The IEnumerable interface contains an abstract member function called GetEnumerator() and return an interface IEnumerator on any success call.

IEnumerator provides two abstract methods and a property to pull a particular element in a collection. And they are Reset(), MoveNext() and Current The signature of IEnumerator members is as follows: void Reset() : Sets the enumerator to its initial position, which is before the first element in the collection. bool MoveNext() : Advances the enumerator to the next element of the collection. object Current : Gets the current element in the collection

2 IEnumerable does not remember the cursor state i.e currently row which is iterating through

IEnumerator does remember the cursor state

3 IEnumerable is useful when we have only iterate the value

IEnumerator is useful when we have to pass the iterator as parameter and has to remember the value

Page 42: Dotnet difference questions & answers Compiled-1(updated)

1) What are differences between XML and HTML?

S.No XML HTML1 XML provides user definable tags HTML provides defined set of tags

designed for web display2 XML is content driven HTML is format driven3 End tags are essential in a well

formed XML document. In a well formed document, elements can be defined as single tag or a pair of tags like <student/> or the <student>…</student> pair

End tags are not always required.<HTML> tag needs an equivalent </HTML> tag but <br> tag does not require </br> tag

4 Quotes required around attribute values

Quotes are not required for the values of attributes

5 Slash required in empty tags Slash not required6 XML is used for describing data HTML is used for designing pages

Page 43: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between LINQ and SQL

S.No LINQ SQL

1 LINQ Stands for language integrated query.

SQL stands for Structured Query Language.

2 LINQ Statements are verified during compile time.

SQL statements can be used in a application gets verified for their syntaxes only in the run time.

3 To use LINQ we can depend upon our .Net Language syntaxes and also we can consume base class library functionalities.

To use SQL we need to be familiar with SQL syntaxes and also the pre-defined functions of SQL like MAX,MIN,LEN and SUBSTRING etc...

4 LINQ Statements can be debugged as they execute under framework environment. SQL .

As SQL statements execute on Database server debugging of the code is not possible.

2.Difference between LINQ to SQL and Entity Framework

S.No LINQ to SQL Entity Framework

1 It only works with Sql server. It works with variety of db products.

2 Used for rapid application development.

Cannot used for rapid application development.

3 It does not support for complex type.

It provides support for complex type.

4 It cannot generate db from model. It can generate db from model.

5 Mapping type ( class to single table)

Mapping type ( class to multiple tables)

6 We can query data using DataContext.

We can query data using esql,object services,entity client and linq to entities.

Another Good Reference:

http://jinaldesai.net/linq-to-sql-vs-entity-framework/

(OR)

http://www.slideshare.net/jinaldesailive/linq-to-sql-vs-entity-framework-jinal-desai

Page 44: Dotnet difference questions & answers Compiled-1(updated)

3.Difference between LINQ and Stored Procedures

S.No LINQ Stored Procedures

1 As LINQ is part of .NET, we can use visual studio’s debugger to debug the queries

It is really very hard to debug the Stored Procedure

2 With LINQ everything gets complied into single DLL hence deployment becomes easy.

With Stored Procedures, we need to provide an additional script for deployment

3 LINQ is type safe, so queries errors are type checked at compile time.It is really good to encounter an error when compiling rather than runtime exception!

Stored Procedures are not type safe i.e., error can be caught only during runtime.

4 LINQ supports multiple databases With Stored Procedures which need to be re-written for different databases.

5 LINQ supports abstraction which allows framework to add additional improvements like multi threading. It is much simpler and easier to add this support through LINQ than Stored Procedures.

As Stored Procedures does not support abstaction , so it is difficult to add additional impovements like multi threading

6 LINQ queries need to compile before execution.Therefore, LINQ is slower than Stored Procedures.

Stored Procedures are ster thn LINQ because they are precompiled i.e., Stored Procedures have a predictable execution plan.Therefore, if a stored procedure is being executed for the second time, the database gets the cached execution plan to execute the stored procedure.

4.Difference between LINQ to SQL and LINQ to Objects

S.No LINQ to SQL LINQ to Objects

1 LINQ to SQL needs a Data Context object. The Data Context object is the bridge between LINQ and the database.

LINQ to Objects does not need any intermediate LINQ provider or API.

2 LINQ to SQL returns data of type IQueryable<T>

LINQ to Objects returns data of type IEnumerable<T>.

Page 45: Dotnet difference questions & answers Compiled-1(updated)

3 LINQ to SQL is translated to SQL by way of Expression Trees, which allow them to be evaluated as a single unit and translated to the appropriate and optimal SQL statements.

LINQ to Objects does not need to be translated.

4 LINQ to SQL is translated to SQL calls and executed on the specified database

LINQ to Objects is executed in the local machine memory.

5.Difference between LINQ to SQL and LINQ to Entities

S.No LINQ to SQL LINQ to Entities

1 Does not support Conceptual Data Model

Supports Conceptual Data Model

2 Does not support Storage Schema Supports Storage Schema

3 Does not support Mapping Schema Supports Mapping Schema

4 Does not support New Data Access Provider

Supports New Data Access Provider

5 Does not support Non-SQL Server Database Support

Supports Non-SQL Server Database Support

6 Supports Direct Database Connection

Does not support Direct Database Connection

7 Does not support Multiple-table Inheritance

Supports Multiple-table Inheritance

8 Does not support Single Entity from Multiple Tables

Supports Single Entity from Multiple Tables

Page 46: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between LINQ to SQL and ADO.NET

S.No LINQ to SQL ADO.NET

1 Used for data handling with SQL Server databases only.

Used for data handling with any database: SQL Server/Access/Oracle/Excel etc.

2 Uses the extension methods of System.Linq.Queryable class.

Does not use the extension methods of System.Linq.Queryable class.

3 Introduced in .net Framework 3.0 It is there since the .net Framework 1.0

4 DataContext is used for Database connectivity.

SqlConnection/OleDbConnection are used for database connectivity

5 Syntax and coding is somewhat complex.

Easier syntax and coding.

Note: Both LINQ TO SQL and ADO.NET have connected / disconnected modes of datahandling

2.Difference between LINQ and nHibernate

S.No LINQ nHibernate

1 LINQ is not an open-source nHibernate is an open source.

2 LINQ is an incomplete ORM tool as it needs additional extensions.

nHibernate is an ORM tool

3 LINQ is primarily a querying language

nHibernate has a limited querying language.

4 LINQ is much more useful in small applications where there is no massive dependence on databases.

nHibernate is much more useful in largel applications where there is massive dependence on databases.

5 With LINQ, database already exists and the relationships and some programming will be dependent on how the database is defined.

With nHibernate, database does not already exist and it needs to be defined .

Page 47: Dotnet difference questions & answers Compiled-1(updated)

3.Difference between LINQ and Entity Framework

S.No LINQ Entity Framework

1 Used for Rapid Application Development

Used for Enterprise Development

2 Works with objects in database Works with Conceptual model of database

3 Mainly woks with SQL Server Works with all data sources

4 ".dbml" is created while using LINQ to SQL

".EDMX" is created while using Entity Framework

Page 48: Dotnet difference questions & answers Compiled-1(updated)

1) What are the differences between TypeOf() and GetType()?S.No TypeOf() GetType()1 Its an operator Its a method2 Can't be overloaded Has lot of overloads

2) What are the differences between const and readonly?S.No const readonly1 It cannot be static It can be instance level or static2 It is evaluated at design time It is evaluated at run time3 It is initialized at declaration It is initialized at declaration or in

constructor4 It must be of integral type or

enumerationIn addition, it can have complex types with new keyword and enumerations are not allowed

3) What are the Differences between Abstract Class and Interface?S.No Abstract Class Interface1 It can have implemented Methods It cannot have implemented Methods2 A class can inherit only one abstract

classA Class can implement any number of Interfaces

3 We go for Abstract classes on such situations where we need to give common functionality for group of related classes

We go for Interface on such situations where we need to give common functionality for group of un-related classes

4 If we add a new method, then we can provide a default implementation and so no need to make any change to existing work

If we add a new method, then we need to change all the existing work

5 Static and Instance constants are possible

Only Static constants are possible

4) What are the differences between Structure and Class?S.No Structure Class1 It is value type It is reference type2 It is stored on stack It is stored on heap3 It does not support inheritance It supports inheritance4 It is suitable for small data structure It is suitable for complex data structures

5) What are the differences between property and indexer?S.No Property Indexer1 A property can be static member An indexer is always an instant member2 The get accessor of a property

corresponds to a method with no parameters

The get accessor of an indexer corresponds to the same formal parameter lists as the indexer

6) What are the differences between overloading and overriding?S.No Overloading Overriding1 Same name in same / derived class

but with different / type of parameterWe need to provide different implementation than base class

2 Has different signature Has same signature3 Otherwise called Compile-time Otherwise called Run-time Polymorphism

Page 49: Dotnet difference questions & answers Compiled-1(updated)

Polymorphism

7) What are the differences between Value Types and Reference Types?S.No Value Types Reference Types1 It is stored on stack It is stored on heap2 It can be accessed directly It can be accessed through references3 Life time of value type is determined

by lifetime of variable that contain them

Lifetime of reference type is managed by .net framework

4 Examples: All numeric data type, Boolean, char, Date, Structure, enumerations

Examples: All arrays, String, Class types, Delegate

Note: Object is not any kind of type. You can create object of structure as well as Class

Are not type: Namespaces, Modules, Events, properties, procedures, variables, constants, & fields.

Page 50: Dotnet difference questions & answers Compiled-1(updated)

Difference between Events and Delegates

S.No Events Delegates

1 Event can be used in an interface definition

Delegate cannot be used in an interface definition

2 Event can only be invoked from the class that declares it

Delegates can be invoked from child classes and clients.

3 Event comes with its pair of accessors i.e Add and Remove. An event is always assigned and unassigned with a += and -= operator.

There is no pair of accessors concept in delegates.

4 Event has a restrictive signature and must always be of the form Event (object source, EventArgs args)

Delegates do not have restrictive

signature as like events

Difference between Class and Object

S.No Class Object

1 It is a datatype that contains the programming logic.

It is a chunk of memory that implements the class logic.

2 Class is visible in the source code and resides in hard disk.

Object is in the RAM and not visible in source code.

3 Class is like a template or blueprint of the object. It implements reusability,encapsulation, inheritance

It is the real world implementation of the class. Each object has its own copy of data.

4 Example:Button is a class with properties like Text,BackColor, events like click, methods like Focus

Example: Button1, Button2 are the objects of Button class.

5 We can create subclasses We cannot create sub-objects

Difference between Private and Static ConstructorS.No Static constructor Private constructor

1 A static constructor is called before the first instance is created. i.e. global initializer.

Private constructor is called after the instance of the class is created.

2 Static constructor will be called first time when the class is referenced.Static constructor is used to initialize static members of the class.

Static members will not be initialized either by private or public constructor.

3 The static constructor will only be executed once.

The private constructor will be executed each time it is called.

Page 51: Dotnet difference questions & answers Compiled-1(updated)

Difference between properties and methods

S.No Properties Methods

1 Properties are used to represent data

Methods are used to performs actions

2 Properties are created by using getter and setter i.e., get{} and set{}

Methods create like public void method1(parameter list here)

Difference between Singleton Pattern and a static class

S.No Singleton Pattern static class

Singleton pattern maintains single instance.

We cannot create instance for static class.

2 A singleton can extend classes and implement interfaces.

A static class cannot .Note: It can extend classes, but it does not inherit their instance members.

3 A singleton can be initialized lazily or asynchronously.

A static class is generally initialized when it is first loaded, leading to potential class loader issues.

4 Singletons can be handled polymorphically without forcing their users to assume that there is only one instance.

static class cannot be handled polymorphically.

5 Singleton Class can have value when Class object instantiated between server and client, such a way if three client want to have a shared data between them Singleton can be used.Thats why singleton class can be used for state mangement in stateless scenarios like shopping cart scenario.

Static are always just shared and have no instance but multiple references.

6 We can pass singleton object as parameter

We cannot pass parameter in static class

7 Singleton provides flexibility and also provides sort of a mechanism to control object creation based on various requirements. They can be extended as well if need arises. In other words we are not always tied to a particular implementation. With Singleton we have the flexibility to make changes as when situation demands.

Static classes once defined could not accomodate any future design changes as by design static classes are rigid and cannot be extended.

Page 52: Dotnet difference questions & answers Compiled-1(updated)
Page 53: Dotnet difference questions & answers Compiled-1(updated)

Difference between Abstraction and Encapsulation

Abstraction Encapsulation

Abstraction solves the problem in the design level.

Encapsulation solves the problem in the implementation level.

Abstraction is used for hiding the unwanted data and giving relevant data.

Encapsulation means hiding the code and data into a single unit to protect the data from outside world.

Abstraction allows us to focus on what the object does instead of how it does it

Encapsulation means hiding the internal details or mechanism of how an object does something.

Abstraction- Outer layout, used in terms of design.For Example:- Outer Look of a Mobile Phone, like it has a display screen and keypad buttons to dial a number.

Encapsulation- Inner layout, used in terms of implementation.For Example:- Inner Implementation detail of a Mobile Phone, how keypad button and Display Screen are connected with each other using circuits

Difference between Composition and Aggregation

Composition Aggregation

Defines a strong-coupled relationship between two entities, where the one entity is part of another, and both need each other for their existence.

Defines a weak-coupled relationship between two entities, where one entity could be part of another, but either can exist without the other, independantly.

e.g. Human body and the Heart. e.g.School and teacher.

Composition implies real ownership of its components

Aggregation does not necessarily own any of its aggregates.

Composition has a stronger bond of its components.

Aggregation has weaker or looser bonds with its aggregates.

Composition has components that exist at the inner level.

Aggregation has aggregates that live at the outer level.

Page 54: Dotnet difference questions & answers Compiled-1(updated)

Difference between Private Class and Sealed Class

Private Class Sealed Class

A Private class can only be accessed by the class it is defined and contain within - it is completely inaccessible to outside classes.

A Sealed class can be accessed by any class.Private Constructor of a Private Class = Sealed Class.

In private Class,we can create a constructor and therefore we can create an instance of that class.

In Sealed class we can not create a constructor of that class, so no instance of that class is possible.

public class A { private class B { } B b = new B(); }public class C { A.B b = new A.B(); // ERROR }

public sealed class A { }public class B : A //ERROR { }

The main use of Private class is to create a user-defined type, which we want to be accessible to that class only.

Private class(i.e private constructor) is also used to implement singleton classes(pattern). Singleton means "A single-instance object, and it simplify complex code. Singletons have a static property that we must access to get the object reference."

The sealed classes are mainly used to prevent inheritance features of object oriented programming.

Difference between Static Class and Sealed Class

Static Class Sealed Class

We can neither create their instances, nor inherit them

We can create their instances, but cannot inherit them

They can have static members only. They can contain static as well as nonstatic members.

ex: static class Program

ex:

Page 55: Dotnet difference questions & answers Compiled-1(updated)

{

}

sealed class demo {

}

class abc:demo { --Wrong }

Static classes are used when a class provides functionality that is not specific to any unique instance.

The sealed classes are mainly used to prevent inheritance features of object oriented programming.

Difference between Virtual method and Abstract method

Feature Virtual method Abstract method

Overriding Virtual method may or may not override by inherited class.

i.e.,Virtual method provide the derived class with the option of overriding it. Virtual = = Overridable

An abstract method should be overriden by inherited class.

i.e.,Abstract method forces the derived class to override it.

abstract == MustOverride

Implementation Virtual method has an implementation.

Abstract method does not provide an implementation.

Necessity to Implement

Virtual methods allow subclasses to provide their own implementation of that method using the override keyword

Abstract methods in a class contain no method body, and are implicitly virtual

Scope Virtual methods scope to members only.

Abstract method's scope to members and classes

Instancing Virtual methods - Not applicable, as we can't create instance for members, it is possible only with classes.

Abstract method - direcly NO, but other way, Yes. We can create an instance of a class that derives from an abstract class. And we can declare a type Abstract class and instantiate that as a derived class.

Page 56: Dotnet difference questions & answers Compiled-1(updated)

Example:

public abstract class Test{

public abstract void A(); // Abstract method

public virtual void B() { Console.WriteLine("Test.B"); } // Virtual Method }

public class InheritedTest : Test {

public override void A() { Console.WriteLine("InheritedTest.A"); }

//Method B implementation is optional

public override void B() { Console.WriteLine("InheritedTest.B"); } }

Difference between Class and Static Class

Class Static Class

Class has Instance Members Static class does not have Instance Members

In Class, Constructor has Access Specifier.

In Static Class, Constructor does not have Access Specifier.

In Class Constructor, initiation is done every time when an object is created for the class

In Static Class ,Constructor will be called only one time .

In Class, Class members can be accessed through class object.

In Static Class, members can be accessed through its Class name only

Page 57: Dotnet difference questions & answers Compiled-1(updated)

Difference between Method Overloading and Method overriding in C#

Method Overloading Method overriding

Method Overloading is passing same message for different functionality

Method Overriding is redifining parent class function to the child class

Method Overloading is between the same function name with the different signature

Method Overriding is between the same method.

Method Overloading does not check for the return type.

Method Overriding checks the return type.

Method Overloading takes place in the same class.

Method Overriding takes place between parent and child classes

Method Overloading is static binding Method Overriding is a dynamic binding.

Page 58: Dotnet difference questions & answers Compiled-1(updated)

1) What are the Differences between TRUNCATE and Delete?S.No Truncate Delete1 Truncate is faster Delete is comparatively slower2 Removes all rows from a table Can remove specific rows with Where

clause3 Is DDL Command Is DML Command4 Resets identity of the table Does not reset identity of the table5 Removes the data by deallocating

the data pages and logs the deallocation.

Removes one row at a time and records an entry in the transaction log for each deleted row.

6 Cannot be rolled back Can be rolled back

2) What are the differences between Primary key and Unique key?S.No Primary Key Unique Key1 Creates Clustered index Creates Non-Clustered index2 Null values are not allowed Allows only one null value

3) What are the Differences between Clustered Indexes and Non-Clustered Indexes?

S.No Clustered Indexes Non-Clustered Indexes1 It reorders the physical storage of

records in the tableIt sorts and maintain a separate storage

2 There can be only one Clustered index per table

More than one

3 The leaf nodes contain data The leaf node contains pointer to data

4) What are the differences between Stored Procedures and User Defined Functions?S.No Stored Procedures User Defined Functions1 Stored Procedure cannot be used

in a Select statementUser Defined Function can be used in a Select statement

2 Stored procedure supports Deferred Name Resolution

User Defined Function does not support Deferred Name Resolution

3 Stored Procedures are generally used for performing Business Logic

User Defined Functions are generally used for Computations

4 Stored Procedure need not return a value

User Defined Functions should return a value

5 Stored Procedures can return any datatype

User Defined Functions cannot return Image

6 Stored Procedures can accept more number of input parameters than User Defined Functions. Stored Procedures can have upto 21000 input parameters

User Defined Functions accept lesser number of input parameters than Stored Procedures. UDF can have upto 1023 input parameters

7 Stored Procedures can use Temporary Tables

Temporary Tables cannot be used in a User Defined Function

8 Stored Procedures can execute Dynamic SQL

User Defined Functions cannot execute Dynamic SQL

9 Stored Procedure supports error handling

User Defined Function does not support error handling. RAISEERROR or @@ERROR are

Page 59: Dotnet difference questions & answers Compiled-1(updated)

not allowed in UDFs10 Non-deterministic functions can

be used in Stored Procedures.Non-deterministic functions cannot be used in User Defined Functions (UDFs). For example, GETDATE() cannot be used in User Defined Functions(UDFs)

5) What are the differences between Where and Having clauses?S.No Where clause Having clause1 It applies to individual rows It applies to a group as a whole2 It selects rows before grouping It selects rows after grouping3 It cannot contain aggregate

functionsIt can contain aggregate functions

4 It can be used in select, delete ,insert etc.

It is used only in select clause

6) What are the differences between Union and UnionAll?S.No Union UnionAll1 This is used to eliminate duplicate

rowsIt will not eliminate duplicate rows

2 This selects only distinct rows It selects all the values3 It can be used to combine any

number of queriesIt can be used to combine maximum of 2 queries

4 It cannot contain aggregate functions

It can contain aggregate functions

7) What is the difference between normal Select statement and a Cursor?S.No Select statement Cursor1 Select statements are used for

table-level processingCursors are used for row-level processing

Page 60: Dotnet difference questions & answers Compiled-1(updated)

1) What are the differences between Instead of Triggers and After Triggers?S.No Instead of Triggers After Triggers1 Each table or view can have one

INSTEAD OF trigger for each triggering action (UPDATE, DELETE, and INSERT)

A table can have several AFTER triggers for each triggering action.

2 INSTEAD OF triggers fire in place of the triggering action and before constraints are processed.

AFTER triggers fire after the triggering action (INSERT, UPDATE, or DELETE) and after any constraints are processed.

2) What are the differences between Views and User-Defined Functions?S.No Views User-Defined Functions1 Views cannot accept parameters. User-Defined Functions can accept

parameters.2 Output of the Views cannot be

directly used in the SELECT clause.

Output of the User-Defined Functions can be directly used in the SELECT clause.

3) What are the differences between Triggers and Stored Procedures?S.No Triggers Stored Procedures1 Triggers cannot return a value Stored Procedures may return a value2 We cannot pass parameters in

TriggersWe can pass parameter in Stored Procedures

3 We can write a Stored procedure within a Trigger

We cannot write a Trigger within a Stored Procedure

4 Triggers are implicitly fired whenever insert, update or delete operations take place on table

Stored Procedures need to be explicitly called by the programmer

5 Triggers can only be implemented on Tables or Views

Stored procedures can be written for the Database

Page 61: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between Identity and Sequence in SQL Server 2012

S.No Identity Sequence

1 Dependant on table. Independent from table.

2 Identity is a property in a table.

Example :

CREATE TABLE Tabletest_Identity

(

[ID] int Identity (1,1),

[Product Name] varchar(50)

)

Sequence is an object.

Example :

CREATE SEQUENCE [dbo].[Sequence_ID]

AS [int]

START WITH 1

INCREMENT BY 1

MINVALUE 1

MAXVALUE 1000

NO CYCLE

NO CACHE

3 If we need a new ID from an identity column we need toinsert and then get new ID.

Example :

Insert into [test_Identity] Values (‘SQL Server’)

GO

SELECT @@IDENTITY AS ‘Identity’

–OR

Select SCOPE_IDENTITY() AS ‘Identity’

In the sequence, we do not need to insert new ID, we can view the new ID directly.

Example :

SELECT NEXT VALUEFOR dbo.[Sequence_ID]

4 We cannot perform a cycle in identity column. Meaning, we cannot restart the counter after aparticular interval.

In the sequence, we can simply add one property to make it a cycle.

Example :

ALTER SEQUENCE [dbo].[Sequence_ID]

Page 62: Dotnet difference questions & answers Compiled-1(updated)

CYCLE;

5 We cannot cache Identity column property.

Sequence can be easily cached by just setting cache property ofsequence. It also improves the performance.

Example :

ALTER SEQUENCE [dbo].[Sequence_ID]

CACHE 3;

6 We cannot remove the identity column from the table directly.

The sequence is not table dependent so we can easily remove it

Example :

Create table dbo.[test_Sequence]

(

[ID] int,

[Product Name] varchar(50)

)

GO

–First Insert With Sequence object

INSERT INTO dbo.test_Sequence ([ID],[Product Name]) VALUES (NEXT VALUE FOR [Ticket] , ‘MICROSOFT SQL SERVER 2008′)

GO

–Second Insert without Sequence

INSERT INTO dbo.test_Sequence ([ID],[Product Name]) VALUES (2 , ‘MICROSOFT SQL SERVER 2012′)

7 We cannot define the maximum value in identity column it isbased on the data type limit.

Here we can set up its maximum value.

Example :

Page 63: Dotnet difference questions & answers Compiled-1(updated)

ALTER SEQUENCE [dbo].[Sequence_ID]

MAXVALUE 2000;

8 We can reseed it but cannot change the step size.

Example :

DBCC CHECKIDENT (test_Identity, RESEED, 4)

We can reseed as well as change the step size.

Example :

ALTER SEQUENCE [dbo].[Sequence_ID]

RESTART WITH 7

INCREMENT BY 2;

9 We cannot generate range from identity.

We can generate a range of sequencevalues from a sequence object with the help of sp_sequence_get_range.

2.Difference between Temp table and Table variable

S.No Temp table Table variable

1 A Temp table is easy to create and back up data.

But the table variable involves the effort when we usually create the normal tables.

2 Temp table result can be used by multiple users.

But the table variable can be used by the current user only.

3 Temp table will be stored in the tempdb. It will make network traffic. When we have large data in the temp table then it has to work across the database. A Performance issue will exist.

But a table variable will store in the physical memory for some of the data, then later when the size increases it will be moved to the tempdb.

4 Temp table can do all the DDL operations. It allows creating the indexes, dropping, altering, etc..,

Whereas table variable won't allow doing the DDL operations. But the table variable allows us to create the clustered index only.

5 Temp table can be used for the current session or global. So that a multiple user session can utilize the results in the table.

But the table variable can be used up to that program. (Stored procedure)

6 Temp variable cannot use the But we cannot do it for table variable.

Page 64: Dotnet difference questions & answers Compiled-1(updated)

transactions. When we do the DML operations with the temp table then it can be rollback or commit the transactions.

7 Functions cannot use the temp variable. More over we cannot do the DML operation in the functions .

But the function allows us to use the table variable. But using the table variable we can do that.

8 The stored procedure will do the recompilation (can't use same execution plan) when we use the temp variable for every sub sequent calls.

Whereas the table variable won't do like that.

Another Good Reference:

http://sqljunkieshare.com/2011/11/05/difference-between-temporary-tables-and-table-variables/

3.Difference between RAISERROR and THROW statements

S.No RAISERROR Statement THROW Statement

1 If a msg_id is passed to RAISERROR, the ID must be defined in sys.messages.

The error_number parameter does not have to be defined in sys.messages.

2 The msg_str parameter can contain printf formatting styles.

The message parameter does not accept printf style formatting.

3 The severity parameter specifies the severity of the exception.

There is no severity parameter. The exception severity is always set to 16.

4.Difference between Local temporary table and Global temporary table

S.No Local temporary table Global temporary table

1 Denoted by # symbol. Denoted by ## symbol.

2 Valid for the current connection only. They are cleared as soon as the current connection closes.

Available to all the connections once created. They are deleted when all users referencing the table disconnect from SQL Server .

3 Cannot be shared between multiple users.

Can be shared between multiple users.

Page 65: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between Correlated subquery and Nested subquery

S.No Correlated subquery Nested subquery

1 Correlated subquery runs once for each row selected by the outer query. It contains a reference to a value from the row selected by the outer query.

Nested subquery runs only once for the entire nesting (outer) query. It does not contain any reference to the outer query row.

2 Correlated subquery follows down to top approach i.e., main query is executed first(even though parenthesis are present) and then child query.

We can also say: in a Correlated subquery,Inner query condition is used in the outer query

Nested subquery follows top-down approach i.e., child query is executed first and then parent .

We can also say:In a subqueryOuter query condition is used in the the inner query.

4 Example:

select e1.empname, e1.basicsal, e1.deptno from emp e1

where e1.basicsal = (select max(basicsal) from emp e2 where e2.deptno = e1.deptno)

Example:

select empname, basicsal, deptno from emp

where (deptno, basicsal) in (select deptno, max(basicsal) from emp group by deptno)

2.Difference between Weak Entity Set and Strong Entity Set

S.No Weak Entity Set Strong Entity Set

1 An entity set which does not possess sufficient attributes to form a primary key is known as a weak entity set.

An entity set which does have a primary key is called a strong entity set.

2 Member of a weak entity set is a subordinate entity.

Member of a strong entity set is a dominant entity.

3 Example:

Specific Person,Company,Event,Plant

Example:

Set of all Persons,Companies,Trees,Holidays

Page 66: Dotnet difference questions & answers Compiled-1(updated)

3.Difference between char and varchar data types in Sql Server

S.No Char Varchar

1 Fixed length memory storage Variable length memory storage(Changeable)

2 CHAR takes up 1 byte per character

VARCHAR takes up 1 byte per character, + 2 bytes to hold length information

3 Use Char when the data entries in a column are expected to be the same size like phone number

Use Varchar when the data entries in a column are expected to vary considerably in size like address

4 Ex: Declare test Char(100); test="Test" - Then "test" occupies 100 bytes first four bytes with values and rest with blank data

Ex: Declare test VarChar(100); test="Test" - Then "test" occupies only 4+2=6 bytes. first four bytes for value and other two bytes for variable length information.

4.Difference between Sql Server 2005 and Sql Server 2008

S.No Sql Server 2005 Sql Server 2008

1 XML datatype is introduced. XML datatype is used.

2 Cannot encrypt the entire database.

Can encrypt the entire database introduced in 2008.

3 Datetime is used for both date and time.

Date and time are seperately used for date and time

4 No table datatype is included. Table datatype introduced.

5 SSIS is started using. SSIS avails in this version.

6 CMS is not available. Central Management Server(CMS) is Introduced.

7 PBM is not available Policy based management(PBM) server is Introduced.

Page 67: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between Database Mail and SQL Mail

S.No Database Mail SQL Mail

1 Based on SMTP (Simple Mail Transfer Protocol).

Based on MAPI (Messaging Application Programming Interface).

2 Introduced in Sql Server 2005. Used prior versions of Sql Server 2005.

3 No need to install Outlook. Require Outlook to be installed.

4 More secure than Sql mail. Less secure than Database mail.

2.Difference between Azure Table storage and SQL Azure

S.No Azure Table storage SQL Azure

1 It is built on top of the Azure Storage platform.

It is an SQL Server that has been configured to be hosted on top of the Windows Azure in a high availability mode.

2 It comprises flexible or schema-less entities. No referential integrity between the tables, and no custom indexes.

It comprises standard SQL Tables with indexes and referential integrity.

3 It can scale massive amounts of data due to the partition key.

It may not scale as far as Azure Table storage.

4 Can be thought as single spreadsheet.

Look familiar to any .Net developer who has used Sql server 2008 prior.

3.Difference between DBMS and RDBMS

S.No DBMS RDBMS

1 Stands for DataBase Management System

Stands for Relational DataBase Management System

2 In dbms no relationship concept It is used to establish the relationship concept between two database objects, i.e, tables

3 It supports Single User only It supports multiple users

4 It treats Data as Files internally It treats data as Tables internally

5 It supports 3 rules of E.F.CODD out off 12 rules

It supports minimum 6 rules of E.F.CODD

6 It requires low Software and It requires High software and

Page 68: Dotnet difference questions & answers Compiled-1(updated)

Hardware Requirements. hardware requirements.

7 DBMS is used for simpler business applications

RDBMS is used for more complex applications.

8 DBMS does not impose any constraints or security with regard to data manipulation

RDBMS defines the integrity constraint for the purpose of holding ACID PROPERTY

9 In DBMS Normalization process will not be present

In RDBMS, normalization process will be present to check the database table consistency

10 There is no enforcement to use foreign key concept compulsorily in DBMS

Although the foreign key concept is supported by both DBMS and RDBMS but its only RDBMS that enforces the rules

11 FoxPro, IMS are Examples SQL Server, Oracle are examples

4.Difference between SQL Server 2000 and SQL Server 2005

S.No SQL Server 2000 SQL Server 2005

1 Query Analyser and Enterprise manager are separate.

Both are combined as SSMS(Sql Server management Studio).

2 No XML datatype is used. .XML datatype is introduced.

3 We can create maximum of 65,535 databases.

We can create 2(pow(20))-1 databases.

4 Exception Handling mechanism is not available

Exception Handling mechanism is available

5 There is no Varchar(Max) data type is not available

Varchar(Max) data type is introduced.

6 DDL Triggers is not available DDL Triggers is introduced

7 DataBase Mirroring facility is not available

DataBase Mirroring facility is introduced

8 RowNumber function for paging is not available

RowNumber function for paging is introduced

9 Table fragmentation facility is not available

Table fragmentation facility is introduced

10 Full Text Search facility is not available

Full Text Search facility is introduced

Page 69: Dotnet difference questions & answers Compiled-1(updated)

11 Bulk Copy Update facility is not available

Bulk Copy Update facility is introduced

12 Data Encryption concept is not introduced

.Cannot encrypt the entire database

13 Cannot compress the tables and indexes.

Can Compress tables and indexes.(Introduced in 2005 SP2)

14 No varchar(max) or varbinary(max) is available.

Varchar(max) and varbinary(max) is used.

15 Data Transformation Services(DTS) is used as ETL tool

SQL Server Integration Services(SSIS) is started using from this SQL Server version and which is used as ETL tool

Page 70: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between SQL Server and PostgreSQL

S.No SQL Server PostgreSQL

1 INSERT t VALUES (…) This syntax is not allowed. Allows: INSERT INTO t VALUES (…)

2 BULK INSERT and BCP uses COPY instead (which has the functionality of both BCP and BULK INSERT)

3 Management Studio pgAdmin

4 Bit type Boolean type (accepts values true and false)

5 IDENITTY Has sequencers (like Oracle)

6 default schema is dbo default schema is PostgreSQL

7 Default Listening on 1433 Default listening on 5432

8 datatype: varchar(max) datatype: text

9 Key is clustered by default key is not clustered by default (and it is enforced by a constraint and not an an index!)

10 User Defined Data Types Domains

11 user: sa user: postgres

12 No such thing NATURAL and USING joins

13 SELECT TOP 10 * FROM t SELECT * FROM t LIMIT 10

14 Query plans read from right to left Query plan read from left to right

15 Estimate Query Plan: CTRL+L Estimate Query Plan: F7

2.Difference between Cross Join and Full Outer Join

S.No Cross Join Full Outer Join

1 No join conditions are specified. A combination of both left and right outer joins.

2 Results in pairs of rows. Results in every row from both of the tables , at least once.

3 Results in Cartesian product of two tables.

Assigns NULL for unmatched fields.

Page 71: Dotnet difference questions & answers Compiled-1(updated)

3.Difference between SQL Server and Oracle

S.No SQL Server Oracle

1 SQL History:

IBM introduced structured Query Language (SQL) as the language to interface with its prototype relational database management system; System R. Oracle Corporation introduced the first commercially available SQL relational database management system in 1979. Today, SQL has become an industry standard, and Oracle Corporation clearly leads the world in RDBMS technology. SQL is used for all types of DB activities by all type of users. The basic SQL commands can be learned in a few hours and even the most advanced commands can be mastered in a few days.

Oracle History:

Oracle Corp is the leading supplier for S/w products, headquartered in Redwood shores, California, USA. It was founded by Larry Ellison, Bob Miner and Ed Oates in 1977. Now they have 43,000 Employees in 150 countries. Oracle first commercial RDBMS was built in 1979, and it is the first to support the SQL. Oracle is the first S/w company to develop and deploy 100 % Internet-enabled enterprise Software.

2 SQL (Structure Query Language):

When a user wants to get some information from any DB file, he can issue a query. Structured query language (SQL), pronounced “Sequel”, is the set of commands that all programs and users must use to access data within the Oracle. SQL is a high performance fault tolerant data base management system. The database is mostly maintained by SQL language, which is conceded as the heart of the RDBMS.

Oracle (RDBMS):

Oracle is fastest and easiest way to create applications in MS windows. It provides the ability to store and access data. Whether you are experienced or new to windows in programming, Oracle provides you with the complete set of tools to simplify rapid application development. The Oracle refers to the method used to create the graphical user inter face. There is no need to write numerous lines of code to describe the appearance and location of inter face elements.

3 SQL Technology:

SQL is divided into four parts:

DDL (Data Definition Language): Create, Alter, Drop, Rename, Truncate.

Oracle Technology:

Oracle DB structure is divided into two parts, one is called Physical structure (these files define the operating system that make up the DB, each Oracle DB is made by three types

Page 72: Dotnet difference questions & answers Compiled-1(updated)

DML (Data Manipulate Language): Select, Update and Delete, Insert, Into.

DCL (Data Control Language): Grant, Revoke

TCL (Transaction Control Language): Commit, Rollback.

of files, data-files, redo logs file-controls file) and the other is called Logical structure (these files define the logical areas of storage like schema, table spaces, segments and extents).

4 Advantages:

• Provides easy access to all data.

• Flexibility in data molding.

• Reduced data storage and redundancy.

• Provides a high-level manipulation language.

• SQL can save data in common PC file formats that can be imported into other application (like Ms-Excel).

• SQL is not case sensitive. • It can enter one or more

lines. • Tabs and indents can be

used to make code more readable.

• Can be used by a range of users.

• It is a nonprocedural language (English-like language).

Advantages:

• Data consistency • Integration of data • Easy file generation • Increased security • Easy updating of records • No wastage of time • Enforcement of standards • Controlled data redundancy • Reduce the total expenditures • Searching of particular data is

easy • Dispose of heavy files and

register work • The work of three persons is

reduced to one • Instant intimation of

modification of information

5 Differences:

• SQL is a tool for all DB like DBMS, RDBMS, T-SQL, and SQL Plus.

• SQL maintains different RDBMS.

• SQL is combination of different commands and functions that why, SQL is worked for Oracle DB as a

Differences:

• Oracle Corp is the world’s leading supplier of S/w products.

• Oracle is the platform, where we develop and implement different DB designs and software.

• Oracle is the combination of different S/w products, where

Page 73: Dotnet difference questions & answers Compiled-1(updated)

command prompt shell (SQL is the command prompt shell, where we can communicate with any DB).

they work together for designing DB.

• Oracle works with different front and back end products/tools (like SQL).

4.Difference between View and Stored Procedure

S.No View Stored Procedure

1 Does not accepts parameters Accept parameters

2 Can be used as a building block in large query.

Cannot be used as a building block in large query.

3 Can contain only one single Select query.

Can contain several statement like if, else, loop etc.

4 Cannot perform modification to any table.

Can perform modification to one or several tables.

5 Can be used (sometimes) as the target for Insert, update, delete queries.

Cannot be used as the target for Insert, update, delete queries.

5.Difference between IN and EXISTS

S.No IN EXISTS

1 Returns true if specified value matches any value in the sub query or a list.

Return true if sub query contain any rows.

2 The sub query will run first and then only outer query.

The Outer query will ran first and then only sub query.

3 IN is slower than EXISTS. The IN is used in the widely For Static variables for eg: select name from table where ID in (Select ID from table2).

Exists is faster than IN.The Outer query will run first and then only inner query.So it will reduce the over head. The Exists is useful mostly in IF conditional statements.

4 Example:

SELECT id,[Name]FROM dbo.tableaWHERE id IN (SELECT id

Example:

SELECT id,[Name]FROM dbo.tablea AS aWHERE EXISTS (SELECT id2

Page 74: Dotnet difference questions & answers Compiled-1(updated)

FROM dbo.tableb) FROM dbo.tablebWHERE id2 = a.id)

Please visit my blog @ http://onlydifferencefaqs.blogspot.in/

Page 75: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between Checkpoint and Lazy Writer

S.No CheckPoint Lazy Writer

1 Flush dirty pages to Disk Flush dirty pages to disk

2 Flush only Data pages to disk Check for available memory and removed Buffer pool (execution plan/compile plan/ Data pages /Memory objects)

3 Default, Occurs approximately every 1 minute

Occurs depending upon memory pressure and resource availability

4 Can be managed with sp_confige -recovery interval option

It is lazy, Sql server manages by its own.

5 Does not check the memory pressure

Monitor the memory pressure and try maintain the available free memory.

6 Crash recovery process will be fast to read log as data file is updated.

No role in recovery

7 Occurs for any DDL statement Occurs per requirement

8 Occurs before Backup/Detach command

Occurs per requirement

9 Depends upon the configuration setting, we can control.

Works on Least recent used pages and removed unused plans first, no user control.

10 For simple recovery it flush the tlog file after 70% full.

No effect on recovery model.

11 Can manually /Forcefully run command “Checkpoint”

No command for Lazy Writer

12 Very Less performance impact No performance impact

2.Difference between Mirroring and Log Shipping

S.No Mirroring Log Shipping

1 Principle can have single mirror Multiple stand by servers can be possible.

2 Generally good to have 10 DB’s for one server

No limit

3 No data loss and can be used as May be some data loss as per schedule.

Page 76: Dotnet difference questions & answers Compiled-1(updated)

high availability like Clustering And secondary server takes some manual work and time to be primary

4 Read log read and transfer the committed transaction through endpoints.

Transfer the log back up and restored at standby server.

5 Only committed transaction Committed as well as uncommitted and whole log backup restores.

6 PAGE repair is possible if principle database page gets corrupt

N/A

7 Mirrored DB can only be accessed using snapshot DB

Secondary server can be reporting server (read-only)

8 Principle and Mirror server should have same edition

Primary and secondary server should be compatible server for restore.

9 Require FULL recovery model Require FULL or Bulk-Logged recovery model

10 Requires Sql Server 2005 SP1 or higher – Enterprise or Developer Editions

Enterprise edition for Sql Server 2000 and even Standard edition for 2005 can works

11 Immediate data moved depending on SEND and WAIT queue

Can control the flow of data by scheduling jobs

12 As Immediate data moves, user error reflects at mirrored DB

As delay in data transfer can avoided user error.

3.Difference between Change Track and Change Data Capture – CDC in SQL Server 2008

S.No Change Track Change Data Capture

1 It is about fact: It captures only the fact as the tracking table has changed. It does NOT capture the data. Therefore, change tracking is more limited in the historical questions it can answer compared to change data capture. However, for those applications that do not require the historical information, there is far less storage overhead because of the changed data not being captured

It is about the Data: Change data capture provides historical change information for a user table by capturing both the fact that DML changes were made and the actual data that was changed.

Page 77: Dotnet difference questions & answers Compiled-1(updated)

2 Storage: Internal tables are placed on the same filegroup as the parent entity. You could use the sys.internal_tables catalog view to show all the internal tables and parent entities. For example: select name, object_name(parent_id) as parent_object from sys.internal_tables

Storage: When change data capture is enabled for a database, a few things are added to the database, including a new schema (called cdc), some metadata tables, and a trigger to capture Data Definition Language (DDL) events.

The two function names are, respectively, fn_cdc_get_all_changes_ and fn_cdc_get_net_changes_, with the capture instance name appended. Note that (like the change tracking feature) this functionality requires the table to have a primary key or other unique index.

3 Supported on “Simple” recovery model also. It is recommended that you use snapshot isolation when change tracking is enabled. Snapshot isolation itself can add significant workload overhead and requires much more careful management of tempdb.

Prevents Log truncation. Forces full logging of some bulk operations.

One major point to note here is that once change data capture is enabled, the transaction log behaves just as it does with transactional replication—the log cannot be truncated until the log reader has processed it. This means a checkpoint operation, even in SIMPLE recovery mode, will not truncate the log unless it has already been processed by the log reader.

4 It uses synchronous tracking mechanism. once a database is enabled for change tracking, a version number is instituted, which allows ordering of operations

Change Data Capture (CDC) uses the asynchronous process that reads the transaction log.

5 Change Tracking has minimal impact on the system.

It has almost nil impact as it asynchronous mechanism reads from the transaction log.

6 It uses TempDB heavily It uses transaction log.

7 DDL Restriction: There are restrictions on the DDL that can be performed on a table being tracked. The most notable restriction is that the primary key cannot be altered in any way. The

No such DDL restriction

Page 78: Dotnet difference questions & answers Compiled-1(updated)

other restriction worth calling out here is that an ALTER TABLE SWITCH will fail if either table involved has change tracking enabled.

8 SQL Agent not needed t requires SQL Agent to be running. SQL Agent Job & Transaction Replication: Two SQL Agent jobs may be created: the capture job and the cleanup job. I say "may be created" because the capture job is the same as the one used for harvesting transactions in transactional replication. If transactional replication is already configured, then only the cleanup job will be created and the existing log reader job will also be used as the capture job

9 Permission required to enable: SYSADMIN

Permission required to enable: DBOwner

4.Difference between Index Rebuild and Index Reorganize in SQL Server 2005

S.No Index Rebuild Index Reorganize

1 Index Rebuild drops the existing Index and Recreates the index from scratch.

Index Reorganize physically reorganizes the leaf nodes of the index.

2 Rebuild the Index when an index is over 30% fragmented.

Reorganize the Index when an index is between 10% and 30% fragmented.

3 Rebuilding takes more server resources and uses locks unless you use the ONLINE option available in 2005 Enterprise and Development editions.

Always prefer to do Reorganize the Index.

4 T-SQL for Rebuilding all Indexes of a particular table.

USE AdventureWorks; GO ALTER INDEX ALL ON HumanResources.Employee REBUILD GO

T-SQL for Reorganize all Indexes of a particular table.

USE AdventureWorks; GO ALTER INDEX ALL ON HumanResources.Employee REORGANIZE GO

Page 79: Dotnet difference questions & answers Compiled-1(updated)

Note: If fragmentation is below 10%, no action required.

5.Difference between User -defined SP and System-defined SP

S.No User-defined SP System-defined SP

1 Once we create User defined SP in one database i.e available to only that database directly.i.ewe cannot call it from some other DB’s directly

System defined sp are available in master DB.These sp’s can be directly called from any DB

2 UDSP will be used to fulfill the user requirements

SDSP will be used for managing sql server

Please visit my blog @ http://onlydifferencefaqs.blogspot.in/

Page 80: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between Constraints and Triggers

S.No Constraints Triggers

1 Once we define some constraint in a table they will be stored along with table definition

It will be stored as separate object

2 Constraints will do memory location to table comparison.

Triggers will do table to table comparison.For this triggers will use magic tables(inserted,deleted).

3 In the order of precedence first Constraints will be fired

In the order of precedence only after Constraints is fired,then only Triggers will be fired

4 Performance wise Constraints will not give best performance because memeory location to table comparison is slower than table to table comparison.

Performance wise triggers will give best performance because table to table comparison is faster than memeorylocation to table comparison.

5 Constraints cannot start a chain reaction as like triggers - for instance each delete, update action etc. can trigger off another function

Triggers are used to carry out tasks which cant be done using constraints.For eg:-A change in the "sal" column of a table should change the "tax" column in another table.This cant be done using constraints.It has to be done using triggers.Thats where the importance of triggers lie.

6 Constraint is used for column Trigger is used for table

7 Constraints are predefined business rules in which all theorganisations follow this constraints without anymodification.

Trigger is a user defined business rule for which user is responasible for logic for business rule

8 Constraints are used to maintain the integrity and atomicity of database .In other words it can be said they are used to prevent invalid data entry . the main 5 constraints areNOT NULL,PRIMARY KEY,FOREIGN KEY,UNIQUE KEY and CHECK

Triggers are bascically stored procedures which automaticallly fired when any insert,update or delete is issued on table

Page 81: Dotnet difference questions & answers Compiled-1(updated)

2.Difference between Cast and Convert in SQL Server

S.No Cast Convert

1 Cast is ANSII Standard Convert is Specific to SQL SERVER

2 Cast cannot be used for Formatting Purposes.

Convert can be used for Formatting Purposes.For example Select convert (varchar, datetime, 101)

3 Cast cannot convert a datetime to specific format

Convert can be used to convert a datetime to specific format

4 Usage of CAST:

USE SampleGOSELECT SUBSTRING(Name, 1, 30) AS ProductName, ListPriceFROM Production.ProductWHERE CAST(ListPrice AS int) LIKE '3%';GO

Usage of CONVERT:

USE SampleGOSELECT SUBSTRING(Name, 1, 30) AS ProductName, ListPriceFROM Production.ProductWHERE CAST(int, ListPrice) LIKE '3%';GO

3.Difference between CUBE and ROLLUP

S.No CUBE ROLLUP

1 It is an additional switch to GROUP BY clause. It can be applied to all aggregation functions to return cross tabular result sets.

It is an extension to GROUP BY clause. It’s used to extract statistical and summarized information from result sets. It creates groupings and then applies aggregation functions on them.

2 Produces all possible combinations of subtotals specified in GROUP BY clause and a Grand Total.

Produces only some possible subtotal combinations

Please visit my blog @ http://onlydifferencefaqs.blogspot.in/

Page 82: Dotnet difference questions & answers Compiled-1(updated)

Difference between basicHttpBinding and wsHttpBinding

Criteria BasicHttpBinding WsHttpBinding

Security support

This supports the old ASMXstyle, i.e. WS-BasicProfile 1.1.

This exposes web services using WS-*specifications.

Compatibility This is aimed for clients who donot have .NET 3.0 installed and itsupports wider ranges of clients.Many of the clients like Windows2000 still do not run .NET 3.0. Soolder version of .NET canconsume this service.

As its built using WS-* specifications, itdoes not support wider ranges of clientand it cannot be consumed by older.NET version less than 3 version.

Soap version SOAP 1.1 SOAP 1.2 and WS-Addressingspecification.

Reliablemessaging

Not supported. In other words, ifa client fires two or three callsyou really do not know if theywill return back in the sameorder.

Supported as it supports WS-*specifications.

Default securityoptions

By default, there is no securityprovided for messages when theclient calls happen. In otherwords, data is sent as plain text.

As WsHttBinding supports WS-*, it hasWS-Security enabled by default. So thedata is not sent in plain text.

Security options

NoneWindows – default authenticationBasicCertificate

NoneTransportMessageTransport with message credentials

Difference between Message and Transport level security in WCF

Criteria Transport Security Message Security

Scenarios when we should be using one of them

When there are no intermediate systems in between this is the best methodology.

If it’s an intranet type of solution this is most recommended methodology.

When there are intermediate systems like one more WCF service through which message is routed then message security is the way to go.

Advantages Does not need any extra coding as protocol inherent security is used.

Performance is better as we can use hardware accelerators to enhance performance.

There is lot of interoperability support and communicating

Provides end to end security as it’s not dependent on protocol. Any intermediate hop in network does not affect the application.

Supports wide set of security options as it is not dependent on protocol. We can also implement custom security.

Page 83: Dotnet difference questions & answers Compiled-1(updated)

clients do not need to understand WS security as it’s built in the protocol itself.

Disadvantages As it’s a protocol implemented security so it works only point to point.

As security is dependent on protocol it has limited security support and is bounded to the protocol security limitations.

Needs application refactoring to implement security.

As every message is encrypted and signed there are performance issues.

Does not support interoperability with old ASMX webservices

Difference between Buffered transfer and Streamed transfer in WCF

S.No Buffered Transfer Streamed Transfer1 Target can process the message once

it is completely received.Target can start processing the data when it is partially received.

2 Performance will be good when message size is small

Performance will be good when message size is larger(more than 64K)

3 Native channel shape is IDuplexSessionChannel

Native channels are IRequestChannel and IReplyChannel

Difference between WCF and Web Services

S.No Features WebService WCF1 Hosting It can be hosted in IIS t can be hosted in IIS,

windows activation service, Self-hosting, Windows service

2 Programming [WebService] attribute has to be added to the class

[ServiceContract] attribute has to be added to the class

3 Model [WebMethod] attribute represents the method exposed to client

[OperationContract] attribute represents the method exposed to client

4 Operation One-way, Request- Response are the different operations supported in web service

One-Way, Request-Response, Duplex are different type of operations supported in WCF

5 XML System.Xml.serialization name space is used for serialization

System.Runtime.Serialization namespace is used for serialization

6 Encoding XML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, Custom

XML 1.0, MTOM, Binary, Custom

Page 84: Dotnet difference questions & answers Compiled-1(updated)

7 Transports Can be accessed through HTTP, TCP, Custom

Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom

8 Protocols Security Security, Reliable messaging, Transactions

9 State Management

Web Services are stateless WCF Services can manage states

Page 85: Dotnet difference questions & answers Compiled-1(updated)

Difference between Self Hosting and IIS Hosting

Feature Self Hosting IIS Hosting

Coding Effort We need to add some extra code to host the process

No need to add extra code Automatic hosting

Deployment Easy to deploy More difficult to deploy than Self-Hosting

Recycling Automatic process recycling is not possible

Automatic process recycling is possible

Service Lifetime Can control the service lifetime using Open and Close methods

Lifetime cannot be controlled manually.

Host Process Host process should be running before client makes a call to the service.

IIS host runs automatically when a client makes a call to the service.

Difference between Behaviour and Contract (OR)

Difference between Service Behaviour and Service Contract

Feature ServiceContract ServiceBehavior

Behaviour Affects the behavior of both client and server

Only affects the behavior of the server

Applicability Can apply to both interface and class

Only applicable to a class implementation

Impact on WSDL Affects the WSDL emitted Does not affect the WSDL

Difference between proxy and channel factory

Proxy Channel Factory

Only requires URL where the service resides We must have direct access to the assembly that contains that service contract T for

Very simpler Not easier

Easy to understand Channels are complex, network-related

There is Visual Studio gives us add the reference When we share a common service contract dll between the client and the server, we will be using the ChannelFactory class

Proxies have several restrictions like:1. Properties need to have gets and sets 2. Contructors cannot be exposed 3. Methods other than the service contract

cannot be exposed

If we know that our entities will not change much and the client code is less, then a DLL would work better than a proxy

By using SVCutil.exe we will create Proxy When we are using DLL that refers Service contract interface then use the channel factory class

Page 86: Dotnet difference questions & answers Compiled-1(updated)

Difference between DataContractSerializer and XMLSerializer

DataContractSerializer XMLSerializer

A practical benefit of the design of the DataContractSerializer is better performance over Xmlserializer. This is because DataContratSerializer explicitly shows the which fields or properties are serialized into XML.

XMLSerializer does not provide better performance when compare with DataContratSerializer because XMLSerializer does not indicate which fields or properties of the type are serialized into XML

The DataContractSerializer can translate the HashTable into XML.

XMLSerializer cannot translate the HashTable into XML.

DataContractSerializer is basically for very small, simple subset of the XML infoset.

XMLSerializer is used for complex schemas.

DataContractSerializer serializes private members.

XmlSerializer cannot serialize private members

DataContractSerializer uses the opts-in approach i.e, selecting the members that needs to be serialized .This is called as opts-in approach.

XmlSerializer uses opts-out approach i.e., marking the members do not need to be serialized. This is called as opts-out approach.

DataContractSerializer can serialize both private and public types.

XmlSerializer can serialize only public types. If we are trying to serialize a class that is marked private by InvalidOperation Exception will be thrown by the serializer.

DataContractSerializer does not need any default constructor before serializing any type.

For any types that needs to be serialized by XmlSerializer must have a default constructor.

DataContractSerializer does not give more control over the generated xml structure compared to the XmlSerializer.

XmlSerializer gives more control over the generated xml structure compared to the DataContractSerializer. For ex, if a field should come as an attribute or element.

DataContractSerializer can able to serialize types that implements Idictionary.

XmlSerializer cannot able to serialize types that implements IDictionary, for ex. Dictionary type cannot be serialized.

We can serialize a type that marked with [Serializable] attribute with DataContractSerializer. It serializes all the members (private, public) even they are marked with [XmlIgnore].

Only the public members are serialized not the private members. Suppose we do not need any of the member to be serialized we can use [XmlIgnore] attribute

WCF uses DataContractSerializer attribute Webservice uses XMLSerializer attribute

Page 87: Dotnet difference questions & answers Compiled-1(updated)

1.Difference between ASP.NET and Silverlight

S.No ASP.NET Silverlight

1 ASP.NET is Microsoft's technology for developing dynamic web application using .NET languages like VB.NET or C#. The code is executed on the web server and the results are sent to the user’s browser. This is comparable to the way a web site would be done with the PHP language.

Silverlight is Microsoft technology for developing Rich Internet Applications. It is a browser plug-in that allows code from .NET languages to be run in the user’s browsers making it easier to develop graphically rich applications without having to constantly go back and forth between the browser and the server. This is comparable to Adobe's Flash technology.

2 ASP.NET uses AJAX to improve performance in the browser by making post backs and calls between the browser and server asynchronously. ASP.NET AJAX uses new built-in types and controls and JavaScript.

Unlike ASP.NET, the bulk of Silverlight processing occurs on the client machine thus decreasing server resource utilization and improving the Web experience on the client.

There is no concept of “Post back” in Silverlight.

3 Asp.net is not platform independent.

Silverlight is delivered as a cross-platform and cross-browser plug-in that exposes a programming framework and features that are a subset of the .NET Framework and Windows Presentation Foundation (WPF).

4 ASP.NET is a server framework for building dynamic web applications. In Asp.net most processing happens from the server side.

Silverlight is a client-side framework geared at providing a rich user experience and/or other capabilities such as video streaming. In Silverlight most processing happens from the client side.

5 Both ASP.NET and ASP.NET AJAX are heavily dependent upon the ASP.NET page event life cycle, are tightly coupled to the server.

Silverlight is a free plug-in that encompasses a subset of functionality from the .NET Framework and WPF.Silverlight runs in the browser as a "sandbox" - a secure zone installed into the browser that accommodates Silverlight functionality while completely protecting the host platform from any possibly adverse actions performed by Silverlight

6 Asp.net can be hosted in IIS. Silverlight can be hosted in IIS & Apache.

Page 88: Dotnet difference questions & answers Compiled-1(updated)

7 ASP.NET is Microsoft's competitor to JSP/JSF and the successor to classic ASP

Silverlight is Microsoft's competitor to Adobe Flash and Flex. Basically, a standalone runtime running inside a browser allowing animation, real-time 2D and vector rendering, etc

2.Difference between WPF and Silverlight

S.No WPF Silverlight

1 WPF is mainly used for creating desktop applications.

Silverlight is prominent for creating web based applications.

2 WPF extends support for advanced features of Windows OS. Few among those features are: 3D, complete documentation support and hardware acceleration.

The advanced features of Windows OS namely 3D, complete documentation support and hardware acceleration are not supported in Silverlight.

3 WPF includes extensive collection of data binding properties.

Silverlight does not support many data binding properties that are supported by WPF. Few properties that are not supported by Silverlight are ElementName, RelativeSource, UpdateSourceTrigger

4 In WPF, the custom markup extensions are supported through the markup extension support x:type.

The x:type is not available in Silverlight.

5 In WPF, the items that are added to the control named TabControl will be wrapped automatically within the TabItem.

In Silverlight, the items that are added to the control named TabControl will not be wrapped automatically within the TabItem.

6 WPF provides routed commands and all its controls are linked to commands using the property called Command.

Silverlight does not provide routed commands or Command property. Silverlight provides only an interface called ICommand. The developers have to create classes that implement this interface and the custom behavior has to be defined within the class.

7 WPF offers input binding support. Silverlight does not offer input binding support.

Page 89: Dotnet difference questions & answers Compiled-1(updated)

3.Difference between HTML 5 and Silverlight

S.No HTML 5 Silverlight

1 HTML5 needs to integrate CSS3 and JavaScript to add its effects to web pages.

On the other hand, Silverlight can be programmed without getting error prone due to usage of a statically typed .Net language. It is easier to program in Silver light.

2 While HTML5 is more resource friendly. This is the primary reason which Apple has given for not including support for technologies other than HTML5.

Silverlight has a disadvantage in that it consumes a lot of hardware resources of our device

3 When HTML5 will be fully standardized it is likely to get better support from all the newer versions of different browsers.

On the other hand, newer browsers would have to be compatible with older versions of Silverlight in order to get the proper functioning.

4 HTML5 uses multiple codecs to run videos on the browsers that are not considered in the Apple’s bloc.

Silver light always needs a plug-in for any case and would not even run on iPhone and iPad.

5 HTML5 video quality is not that crisp as other competitors and its lack of ability to provide video content of various quality levels on various bandwidths to the user is also a hindrance in getting the message across to low data rate users.

Silverlight offers good video quality and also provide video content of various quality levels on various bandwidths to the user.

6 HTML5 pages, when designed, should be compatible with all the browsers.

Silver light works just like a plug-in. We can simply add the functionality to for any browser.

7 While HTML5 being more tilted towards open source is a relatively easy target of stealing code. The divisions of JavaScript and HTML are clearly marked so it is easy to view and understand the code.

Silverlight application is not easy to decode

8 At present HTML5 doesn’t provide direct support for these devices. However there are some difficult ways to get around this in HTML5.

Silverlight supports microphone and web cam and thus renders a number of rich interactive applications.

Page 90: Dotnet difference questions & answers Compiled-1(updated)

9 HTML5, like its predecessors facilitates search engines to crawl through its content and get maximum exposure for the website.Therefore,HTML5 is suitable for online business websites or those sites which require traffic through search engines.

Silverlight is not popular in the SEO community. At present the content of Silverlight is not indexed by search engines.Therefore,Silverlight is not suitable for online business websites or those sites which require traffic through search engines.

4.Difference between Flash and Silverlight

S.No Flash Silverlight

1 The animation model is frame based.

Animation - Silverlight supports the WPF animation model, which is not only time based instead of frame based, but lets you define the start and end conditions and it will figure out how to get there for you. No need to deal with matrixes like in flash. Also no need to calculate positions on various frames. It just works.

2 Flash stores its shapes using binary shape records.In order to write shape definitions, you will need to either license a 3rd party Flash file format SDK, or build your own. It is not too difficult, but it does require a bit of a learning curve.

Silverlight uses XAML. XAML is text based and can be output using a simple XML object.

3 The debugging with flash is harder than Silverlight.

The debugging with Silverlight is simpler than with flash.

4 Dealing with fonts is fairly complex with flash.

Silverlight lets you embed true type font information directly into your projects, and download that information with the downloader object.

5 Only Action Script can be used as programming tool in Flash.

Rich set of development languages are available for Silverlight. Developer can use JavaScript as well as managed code VB.Net, C# for Silverlight development

6 ActionScript is an imperative language, which brings itself the

XAML is declarative while ActionScript is imperative.

Page 91: Dotnet difference questions & answers Compiled-1(updated)

pitfalls of imperative languageswhen compared with declarative languages.

Using imperative languages to build UIs goes back to the early days of DOS and Windows, when developershad to manage all of the API nuances when interacting with graphical panes.

7 There is not any such service provided by Flash

Web Services support for Silverlight Streaming

8 Flash is not spread as across the vast majority of both desktops and mobiles platforms, as compared to Silverlight. Flash requires Flash Lite preinstalled on mobile devices.

Additional Support for mobile devices with desktop and desktop browsers:Silverlight is supported byWindows mobile device as part of a new service that the NBL have built. Silverlight applications and mediastreaming can be run on a mobile phone – so Silverlight even at this stage is about more than just the desktop browser and desktop market. Silverlight may be seen soon on the Symbian OS too.

9 Flash requires video codec to run .WMV videos.

Silverlight does not require video codec to run industry standard videos like .WMV

10 Flash does not support scalable video formats from HD to mobile

Silverlight supports scalable video formats from HD to mobile.

11 Flash does not support Hardware-assisted editing and encoding solutions.

Silverlight supports Hardware-assisted editing and encoding solutions.

12 Flash does not have XAML based presentation layer for SEO.

Silverlight has XAML based presentation layer for SEO.

13 Flash does not provide End-to-end server and application platform.

Silverlight provides End-to-end server and application platform.

14 Media server licensing is costlier than Silverlight.

Media server licensing is cheaper than flash.

15 Flash does not support Scalable full screen video.

Silverlight supports Scalable full screen video.

16 This limitation doesn’t exist with Flash.

Silverlight is missing Linux support, so people using Linux machine cannot run it on their machines and will have to stick to Windows and MAC OS

17 Flash Video turned Flash into a mechanism for delivering media with far more potential than any

Silverlight will add to the use of the WMV file format.Using the WMV video format essentially makes

Page 92: Dotnet difference questions & answers Compiled-1(updated)

other solution that is .flv, no doubt Flash has also limitation to play other video file. For that Flashrequired codex for that player installed on Client machine.

Silverlight useless for the vast majority of video websites such as YouTube. It cannot play .avi and .mov file.

18 Even flash is also lacking this area. Flash can read data source in terms of XML or text from some URL and can use it. Same thing silverlight also can read.

Silverlight has no support for binding to models,binding to data, or even connecting to network resources to obtain data.

19 Flash has rich set of control library.

Silverlight doesn't even have support for things that should be considered a stock part of any library such as buttons, checkboxes, list boxes, list views, grids,etc. Probably in future release may Microsoft support it.

20 Flash test tools are already in place.

Once the accessibility features are provided with Silverlight versions, any existing test tools that support driving UI through Accessibility will be fullyenabled to automate Silverlight applications

21 With some media file sound processing can possible.

Cannot do sound processing.

22 Flash allows creating XML Socket object.

Socket programming is not possible.

23 Can do that. Per pixel bitmap editing, bitmap filters (convolution, color matrix, etc),bitmap effects (drop shadow, blur,glow) cannot be done.

24 Flash supports it. Webcam and Microphone support are not provided by Silverlight

25 Inbuilt Upload/download support is there.

Built in file upload/download support is not available.

26 Flash has a long history that spans more than ten years, and already got acceptance in market and being the most successful browser plug- in ,it is installed on over 90 percent of the world’s web browsers

Silverlight is new in market and required time to get acceptance in market.

27 Size of flash component is smaller.

Size of Silverlight component is larger.

Page 93: Dotnet difference questions & answers Compiled-1(updated)

28 Flash ships in single component that is .swf.Images/video/sounds also incorporated in single.swf package.

It has found in practical implementation of image animation, at some extent flickering occurs on image.