Tuesday, 30 August 2011

.Net Interview Question

1)     What is .Net Framework?
a)        A programming infrastructure provided by Microsoft for building, deploying and running application and the service that use .Net technologies such as desktop application, Web Application and Web services.
The .Net Framework contains three major parts
                           I.                  Common Language Runtime(CLR)
                         II.                  Framework Class Libraries
                        III.                  Asp.net
2)     Difference between .Net Framework 1.1, 2.0, and 3.5?
CLR, Asp.net
Ado .Net Mars, Generics, Partial Classes, DPAPI

3)     What is CLR?
a)     Full form of CLR is Common language runtime. Basically it is an execution engine of .net framework. Its responsibility to care of code execution of program. Following are the responsibility of CLR.
1.      Garbage Collection:  CLR automatic manages the memory thus eliminating the memory leakage problem. When object are not referred GC automatically call and release the memories. Thus providing efficient memory management.
2.      Code Access Security: CAS grants rights to program depending on the security of the machine. Example program has rights to create or edit new file but the security configuration of machine does not allow to program to delete a file.
3.      Code Verification: It prevents the source code to perform illegal operation such as accessing invalid memory location etc.
4.      IL To Native Translator and Optimizer: CLR uses jIT and compiles the IL code to machine code and then executes.
4)     What is CTS?
a)      In order that two language communicate smoothly CLR has CTS (Common Type System).Example in VB you have “Integer” and in C++ you have “long” these data types are not compatible so the interfacing between them is very complicated. In order to able that two different languages can communicate Microsoft introduced Common Type System. So “Integer” data type in VB6 and “int” data type in C++ will convert it to System.int32 which is data type of CTS. CLS which is covered in the coming question is subset of CTS.

5)     What is CLS?
a)      This is a subset of the CTS which all .NET languages are expected to support. It was always a dream of Microsoft to unite all different languages in to one umbrella and CLS is one step towards that. Microsoft has defined CLS which are nothing but guidelines that language to follow so that it can communicate with other .NET languages in a seamless manner.

6)     What is Assembly?
a)     An assembly is the primary unit of deployment, Security, and version control in the .Net framework. Assembly is the .dll file which contains metadata information which is used by CLR for everything.
There are two types of assemblies.
1.      Private Assembly: A private assembly is normally used by single application and stored in application directory.
2.      Shared Assembly: A shared a assembly is used by multiple applications. A shared assembly is normally stored in GAC which is repository of assemblies maintained by .Net runtime. Shared assemblies are usually library of code which many applications will find useful. For e.g. Crystal Report classes which will used by application for reports.
7)     What is Namespace?
a)     There are 13000 classes in the .Net framework. This is an overwhelming number. If Microsoft simply jumbled all the classes together then you would never find anything. Fortunately Microsoft divides the classes in the framework into separate Namespaces. A namespace is a simply a category. For e.g. All the file related to working with file system are located in the system.IO namespace
8)     What is Manifest?
a)      Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the following things (See Figure Manifest View for more details):
1.       Version of assembly
2.       Security identity
3.       Scope of the assembly
4.       Resolve references to resources and classes.
5.      The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a stand-alone PE file that contains only assembly manifest information.
9)     What is GAC?
a)     GAC (Global Assembly Cache) is used where shared .NET assembly reside. GAC is used in the following situations :-
1.       If the application has to be shared among several application.
2.       If the assembly has some special security requirements like only administrators can remove the assembly. If the assembly is private then a simple delete of assembly the assembly file will remove the assembly.

10)  What is Garbage Collection?
a)      Garbage collection is a CLR feature which automatically manages memory. Programmers forget to release the objects while coding (Laziness). CLR automatically releases objects when they are no longer in use and referenced. CLR runs on non-deterministic to see the unused objects and cleans them. One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when it goes out of the scope of a function. Therefore, we should not put code into a class destructor to release resources.
11)  What is Reflection in .net?
a)     All .NET assemblies have metadata information stored about the types defined in modules. This metadata information can be accessed by mechanism called as “Reflection”. System. Reflection can be used to browse through the metadata information. Using reflection you can also dynamically invoke methods using System.Type.Invokemember.
12)  What are different types of JIT?
a)     JIT is a part of runtime execution environment.
In Microsoft there are three types of complier:
1.      Pre-JIT: - Pre-JIT compiles complete source code into native code in a single compilation cycle. This is done at the time of deployment of the application.
2.       Econo-JIT: - Econo-JIT compiles only those methods that are called at runtime. However, these compiled methods are removed when they are not required.
3.      Normal-JIT: - Normal-JIT compiles only those methods that are called at runtime. These methods are compiled the first time they are called, and then they are stored in cache. When the same methods are called again, the compiled code from cache is used for execution.
13)  What are Value types and Reference types?
Value types
Reference types
Value types directly contain the data
Reference types stores reference
Value types are allocated on the stack
Reference types are allocated on the heap
Int, string etc.
Class, pointer, interface

14)  What is Boxing and UnBoxing?
a)      The process of converting implicitly value types to reference type called Boxing where as Unboxing is a process of converting reference types to value types.
15)  What is Difference between VB.Net and C#.net?
Has support for optional parameter which makes COM interoperability
Not supported
Has With the Construct
Not supported
Not Supported
Supports Operator Overloading

16)  What is the difference between Convert.ToString () and ToString() method?
a)     The basic difference between them is “Convert” function handles NULLS while “i.ToString()” does not it will throw a NULL reference exception error. So as good coding practice using “convert” is always safe.
17)  What is Multi-tasking?
a)      It’s a feature of modern operating systems with which we can run multiple programs at same time example Word, Excel etc.
18)  What is Multi-threading?
a)     Multi-threading forms subset of Multi-tasking. Instead of having to switch between programs this feature switches between different parts of the same program. Example you are writing in word and at the same time word is doing a spell check in background.
19)  What is a Thread?
a)     A thread is the basic unit to which the operating system allocates processor time.
20)  What's Thread.Sleep() in threading ?
a)     Thread's execution can be paused by calling the Thread.Sleep method. This method takes an integer value that determines how long the thread should sleep. Example Thread.CurrentThread.Sleep(2000).
21)  What is an application domain?
a)     Previously “PROCESS” where used as security boundaries. One process has its own virtual memory and does not overlap the other process virtual memory; due to this one process cannot crash the other process. So any problem or error in one process does not affect the other process. In .NET they went one step ahead introducing application domains. In application domains multiple applications can run in same process without influencing each other. If one of the application domains throws error it does not affect the other application domains. To invoke method in a object running in different application domain .NET remoting is used.
22)  What is .NET Remoting?
a)     .NET remoting is replacement of DCOM. Using .NET remoting you can make remote object calls which lie in different Application Domains. As the remote objects run in different process client calling the remote object cannot call it directly. So the client uses a proxy which looks like a real object. When client wants to make method call on the remote object it uses proxy for it. These method calls are called as “Messages”. Messages are serialized using “formatter” class and sent to client “channel”. Client Channel communicates with Server Channel. Server Channel uses as formatter to deserialize the message and sends to the remote object.
23)  What is a Web Service?
a)     Web Services are business logic components which provide functionality via the Internet using standard protocols such as HTTP. Web Services uses Simple Object Access Protocol (SOAP) in order to expose the business functionality. SOAP defines a standardized format in XML which can be exchanged between two entities over standard protocols such as HTTP. SOAP is platform independent so the consumer of a Web Service is therefore completely shielded from any implementation details about the platform exposing the Web Service. For the consumer it is simply a black box of send and receives XML over HTTP. So any web service hosted on windows can also be consumed by UNIX and LINUX platform.
24)  Define State Management in .Net?
a)     State Management is a process by which you maintain state and page information over multiple requests for same or different pages
Types of state management system
1.      Client Side State Management
2.      Server Side State Management
1.        Client Side State Management: - In this we store the information on the clients computer and technique to store the state information is
a)     View State: - View state retaining the value between multiple requests for the same page. When the asp.net page is processed the current state of page is stored as hidden field.
b)     Control State: - When we create Custom control that requires view state so that we can use control state property to store state information for control.
c)      Hidden fields: - View state stores information in the web page using hidden fields.
d)      Cookies: - Web application can store small piece of data in the client’s web browser by using cookies. A cookie is a small amount of data that is a text file on the client file system.
e)     Query String: - Query String store values in the URL that are visible to the user.
2.      Server Side State Management:- In this we store the information on server and the technique to store the state information is.
a)     Session State: - Session state information is available to all pages opened by user during a single visit.
b)     Application State:- Application  state is available to all pages of which user request a page
25)  What’s a Class?
a)     A class describes all the attributes of objects, as well as the methods that implement the behavior of member objects. It’s a comprehensive data type which represents a blue print of objects. It’s a template of object.
26)   What’s an Object?
a)     It is a basic unit of a system. An object is an entity that has attributes, behavior, and identity. Objects are members of a class. Attributes and behavior of an object are defined by the class definition
27)  What is a difference between abstract class and interface?
Abstract Class
Have concrete method as well as abstract methods
Have only abstract methods
Access modifiers can be used
No access modifiers can be used
Class can be inherited only abstract class
Multiple Interfaces can be implemented in single class

28)  What is a delegate?
a)     Delegate is a class that can hold a reference to a method or a function. Delegate class has a signature and it can only reference those methods whose signature is compliant with the class. Delegates are type-safe functions pointers or callbacks.
29)  What are events?
a)     As compared to delegates events works with source and listener methodology. So listeners who are interested in receiving some events they subscribe to the source. Once this subscription is done the source raises events to its entire listener when needed. One source can have multiple listeners.
30)  What is the difference between delegate and events?
a)      Actually events use delegates in bottom. But they add an extra layer on the delegates, thus forming the publisher and subscriber model.
b)      As delegates are function to pointers they can move across any clients. So any of the clients can add or remove events, which can be pretty confusing. But events give the extra protection by adding the layer and making it a publisher and subscriber model.
31)  What is shadowing?
a)     When two elements in a program have same name, one of them can hide and shadow the other one. So in such cases the element which shadowed the main element is referenced. Below is a sample code, there are two classes “ClsParent” and “ClsShadowedParent”. In “ClsParent” there is a variable “x” which is a integer. “ClsShadowedParent” overrides “ClsParent” and shadows the “x” variable to a string.
32)  What is the difference between Class and structure’s?
 Following are the key differences between them:-
a)      Structure is value types and classes are reference types. So structures use stack and classes use heap.
b)      Structures members cannot be declared as protected, but class members can be. You cannot do inheritance in structures.
c)       Structures do not require constructors while classes require.
d)     Objects created from classes are terminated using Garbage collector. Structures are not destroyed using GC.
33)  What is Array List?
a)     Array is whose size can increase and decrease dynamically. Array list can hold item of different types. As Array list can increase and decrease size dynamically you do not have to use the REDIM keyword. You can access any item in array using the INDEX value of the array position.
34)   What’s a Hash Table? Twist: - What’s difference between Hash Table and Array List?
a)      You can access array using INDEX value of array, but how many times you know the real value of index. Hash table provides way of accessing the index using a user identified KEY value, thus removing the INDEX problem.

35)  What is the difference between System.String and System.StringBuilder classes?
a)     System.String is immutable; System.StringBuilder can have mutable string where a variety of operations can be performed.
36)  What’ is the sequence in which ASP.NET events are processed ?
Following is the sequence in which the events occur :-
a)      Page_Init.
b)     Page_Prerender
c)       Page_Load.
d)     Control events
e)     Page_Unload event.
Page_init event only occurs when first time the page is started, but Page_Load occurs in subsequent request of the page.
37)  What is event bubbling (Bubble Event)?
a)     Server controls like Datagrid, DataList, and Repeater can have other child controls inside them. Example DataGrid can have combo box inside datagrid. These child control do not raise their events by themselves, rather they pass the event to the container parent (which can be a datagrid, datalist, repeater), which passed to the page as “ItemCommand” event. As the child control send their events to parent this is termed as event bubbling.
38)  What is the difference between Authentication and authorization?
a)     This can be a tricky question. These two concepts seem altogether similar but there is wide range of difference. Authentication is verifying the identity of a user and authorization is process where we check does this identity have access rights to the system. In short we can say the following authentication is the process of obtaining some sort of credentials from the users and using those credentials to verify the user’s identity. Authorization is the process of allowing an authenticated user access to resources. Authentication always proceeds to Authorization; even if your application lets anonymous users connect and use the application, it still authenticates them as being anonymous.
39)  What is the difference between Server.Transfer and response.Redirect ? Following are the major differences between them:-
a)      Response.Redirect sends message to the browser saying it to move to some different page, while server.transfer does not send any message to the browser but rather redirects the user directly from the server itself. So in server.transfer there is no round trip while response.redirect has a round trip and hence puts a load on server.
b)      Using Server.Transfer you cannot redirect to a different from the server itself. Example if your server is www.yahoo.com you can use server.transfer to move to www.microsoft.com but yes you can move to www.yahoo.com/travels, i.e. within websites. This cross server redirect is possible only using Response.redirect.
c)       With server.transfer you can preserve your information. It has a parameter called as “preserveForm”. So the existing query string etc. will be able in the calling page. In response.redirect you can maintain the state, but has lot of drawbacks.

40)  How can we kill a user session?
a)     Session.abandon
41)  What is difference between dataset and datareader ?
 Following are some major differences between dataset and datareader :-
a)      DataReader provides forward-only and read-only access to data, while the DataSet object can hold more than one table (in other words more than one rowset) from the same data source as well as the relationships between them.
b)      Dataset is a disconnected architecture while datareader is connected architecture.
c)      Dataset can persist contents while datareader cannot persist contents, they are forward only.
42)  What is normalization? What are different types of normalization? It is set of rules that have been established to aid in the design of tables that are meant to be connected through relationships. This set of rules is known as Normalization. Benefits of normalizing your database will include:
a)     Avoiding repetitive entries
b)     Reducing required storage space
c)      Preventing the need to restructure existing tables to accommodate new data. √ Increased speed and flexibility of queries, sorts, and summaries.
 Following are the three normal forms:
1.      First Normal Form: - For a table to be in first normal form, data must be broken up into the smallest unit’s possible. In addition to breaking data up into the smallest meaningful values, tables in first normal form should not contain repetitions groups of fields.
2.      Second Normal Form: - The second normal form states that each field in a multiple field primary key table must be directly related to the entire primary key. Or in other words, each non-key field should be a fact about all the fields in the primary key.
3.      Third Normal Form: - A non-key field should not depend on other Non-key field. The field "Total" is dependent on "Unit price" and "qty".
43)  What are the different types of joins? What is the difference between them?
a)     Inner join: - Inner join shows matches only when they exist in both tables.Example, in the below SQL there are two tables Customers and Orders and the inner join in made on Customers Customerid and Orders Customerid.So this SQL will only give you result with customers who have orders.If the customer does not have order it will not display that record.
For e.g. SELECT Customers.*, Orders.* FROM Customers INNER JOIN Orders ON Customers.CustomerID =Orders.CustomerID
b)     LEFT OUTER JOIN :- Left join will display all records in left table of the SQL statement.In SQL below customers with or without orders will be displayed. Order data for customers without orders appears as NULL values. For example, you want to determine the amount ordered by each customer and you need to see who has not ordered anything as well. You can also see the LEFT OUTER JOIN as a mirror image of the RIGHT OUTER JOIN (Is covered in the next section) if you switch the side of each table.
For e.g. SELECT Customers.*, Orders.* FROM Customers LEFT OUTER JOIN Orders ON Customers.CustomerID =Orders.CustomerID
c)      RIGHT OUTER JOIN: - Right join will display all records in right table of the SQL statement. In SQL below all orders with or without matching customer records will be displayed. Customer data for orders without customers appears as NULL values. For example, you want to determine if there are any orders in the data with undefined CustomerID values (say, after a conversion or something like it). You can also see the RIGHT OUTER JOIN as a mirror image of the LEFT OUTER JOIN if you switch the side of each table.
For e.g. SELECT Customers.*, Orders.* FROM Customers RIGHT OUTER JOIN Orders ON Customers.CustomerID =Orders.CustomerID
44)  What are indexes? What is the difference between clustered and nonclustered indexes?
Indexes in SQL Server are similar to the indexes in books. They help SQL Server retrieve the data quickly.
There are clustered and nonclustered indexes.
a)     Cluster Index: - A clustered index is a special type of index that reorders the way in which records in the table are physically stored. Therefore table can have only one clustered index. The leaf nodes of a clustered index contain the data pages.
b)     Non Cluster Index: - A nonclustered index is a special type of index in which the logical order of the index does not match the physical stored order of the rows on disk. The leaf node of a nonclustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.
45)  What is the difference between DELETE TABLE and TRUNCATE TABLE commands?
1.      Delete is dml command and can be rollback
Truncate is ddl command and can’t be rollback
2.      Slower than truncate
Faster than delete
3.      Delete command is used with criteria like Where.
               Cannot be used with citeria.  

46)  What is the difference between a HAVING CLAUSE and a WHERE CLAUSE?
a)      You can use Having Clause with the GROUP BY function in a query and WHERE Clause is applied to each row before they are part of the GROUP BY function in a query.
47)  What is the difference between UNION and UNION ALL SQL syntax?
a)     UNION SQL syntax is used to select information from two tables. But it selects only distinct records from both the table, while UNION ALL selects all records from both the tables.
48)  What are transactions in SQL SERVER?
a)      A transaction is a sequence of operations performed as a single logical unit of work. A logical unit of work must exhibit four properties, called the ACID (Atomicity, Consistency, Isolation, and Durability) properties, to qualify as a transaction:
49)  Difference between Array and Array List?
a)     The capacity of an Array is fixed. Whereas, ArrayList can increase and decrease size dynamically.
b)      An Array is a collection of similar items. Whereas, ArrayList can hold item of different types.
c)       Array is in the System namespace. Whereas, ArrayList is in the System.Collections namespace.
d)      An Array can have multiple dimensions. Whereas, ArrayList always has exactly one dimension.
e)      We can set the lower bound of an Array. Whereas, the lower bound of an ArrayList is always zero.

50)    What is Serialization?
a)      Serialization is the process of saving the state of an object by converting it to a stream of bytes. The object can then be persisted to file, database, or even memory. The reverse process of serialization is known as deserialization.
Use of Serialization:-
a)  Serialization is used in many scenarios, but the main purpose is to save the state of an object in order to have the ability to recreate the same object when required. It is an important to let the user save work and then be able to continue from that point at a later time
b)   Serialization is also used in creating a clone of an object.
c)   Another important need for serialization arises when the object is required to travel electronically over wire. In such cases the objects are serialized and deserialized. In fact, serialization is one of the fundamental requirements for techniques such as .NET Remoting.
Types of Serialization: -
The XmlSerializer can be used when you need the data in the object to be stored in an XML Format. However, this serialize has the limitation that it can serialize only the public fields of an object.             

The SoapFormatter is ideal in scenarios where you need interoperability. This is ideal in applications spanning heterogeneous environments.

The BinaryFormatter generates a very compact stream when an object is serialized as compared to the other two techniques and hence is useful when data needs to travel electronically across the wire. This is appropriate when the applications do not involve heterogeneous environments.
51)  Describe difference between thread and process?
A process is an instance of running application
Thread is a execution steam of the process
 A process can have multiple thread

When process starts a specific area of memory is allocated to it
When there is a multiple thread in a process. Each thread gets a memory for storing the variable

52)  What is a difference between an Exe and a DLL?
Cannot Create Exe object
Can create DLL object
Exe is an Output process component
DLL is an IN Process Component
Exe is for single use
We can use DLL for multiple use
Exe can be started as stand alone
DLL cannot be

53)  What is the difference between Metadata and manifest?
a)      Metadata and Manifest forms an integral part of an assembly ( dll / exe ) in .net framework. Out of which Metadata is a mandatory component, which as the name suggests gives the details about various components of IL code viz : Methods , properties , fields , class etc. Essentially Metadata maintains details in form of tables like Methods Metadata tables , Properties Metadata tables , which maintains the list of Given type and other details like access specifier , return type etc.
b)      Now Manifest is a part of metadata only , fully called as “manifest metadata tables” , it contains the details of the references needed by the assembly of any other external assembly / type , it could be a custom assembly or standard System namespace .
54)  What is a satellite assembly?
a)      When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.
55)  What are user controls and custom controls?
a)     Custom controls: A control authored by a user or a third-party software vendor that does not belong to the .NET Framework class library. This is a generic term that includes user controls. A custom server control is used in Web Forms (ASP.NET pages). A custom client control is used in Windows Forms applications.
b)     User Controls: In ASP.NET: A user-authored server control that enables an ASP.NET page to be re-used as a server control. An ASP.NET user control is authored declaratively and persisted as a text file with an .ascx extension. The ASP.NET page framework compiles a user control on the fly to a class that derives from the System.Web.UI.UserControl class.
56)  What are the different types of caching?
a)      Caching is a technique widely used in computing to increase performance by keeping frequently accessed or expensive data in memory. In context of web application, caching is used to retain the pages or data across HTTP requests and reuse them without the expense of recreating them.
ASP.NET has 3 kinds of caching
1.      CachingOutput Caching: Caches the dynamic output generated by a request. Sometimes it is useful to cache the output of a website even for a minute, which will result in a better performance. For caching the whole page the page should have OutputCache directive.<%@ OutputCache Duration="60" VaryByParam="state" %>
2.      Fragment Caching: Caches the portion of the page generated by the request. Sometimes it is not practical to cache the entire page, in such cases we can cache a portion of page<%@ OutputCache Duration="120" VaryByParam="CategoryID;SelectedID"%>
3.      Data Caching: Caches the objects programmatically. For data caching asp.net provides a cache object for eg: cache["States"] = dsStates;

57)  What is the difference between a Thread and Process?
A process is a collection of virtual memory space, code, data, and system resources. A thread is code that is to be serially executed within a process. A processor executes threads, not processes, so each application has at least one process, and a process always has at least one thread of execution, known as the primary thread. A process can have multiple threads in addition to the primary thread. Prior to the introduction of multiple threads of execution, applications were all designed to run on a single thread of execution.

When a thread begins to execute, it continues until it is killed or until it is interrupted by a thread with higher priority (by a user action or the kernel’s thread scheduler). Each thread can run separate sections of code, or multiple threads can execute the same section of code. Threads executing the same block of code maintain separate stacks. Each thread in a process shares that process’s global variables and resources.
58)   What is the difference between ADO and ADO.NET?
The old ADO (ActiveX Data Object) has evolved to ADO.NET in the .NET Framework. The ADO.NET object is a lightweight object. The ADO Recordset was a huge object in ADO. It provided the ability to support multiple types of cursors. It provided fast lightweight "firehose" cursor and also supported a disconnected client-side cursor that supported tracking, optimistic locking, and automatic batch updates of a central database. However, all of this functionality was difficult to customize.
ADO.NET breaks the functionality of the ADO object to multiple classes, thereby allowing a focused approach to developing code. The ADO.NET DataReader is equivalent to the "firehose" cursor. The DataSet is a disconnected cache with tracking and control binding functionality. The
DataAdapter provides the ability to completely customize how the central data store is updated with the changes to a DataSet.
59)   Difference between Abstract Class and Interface

1) A class may inherit only one abstract class, but may implement multiple number of Interfaces. Say a class named Car needs to inherit some basic features of a vehicle, it may inherit from an Aabstract class named Vehicle. A car may be of any kind, it may be a vintage car, a sedan, a coupe, or a racing car. For these kind of requirements, say a car needs to have only two seats (means it is a coupe), then the class Car needs to implement a member field from an interface, that we make, say ICoupe.
2) Members of an abstract class may have any access modifier, but members of an interface are public by default, and cant have any other access modifier.
3) Abstract class methods may OR may not have an implementation, while methods in an Interface only have a definition, no implementation.

60)  What is the difference between Web Services and Remoting?
Both Remoting and Web Services are ways of communication between applications.

Remoting - In remoting, the applications involved in the communication process may be located on the same computer, different computers in a same or different network. In remoting, both applications know about each other. A proxy of an application object is created on the other application.

Web Services - Communication between applications using
web services is platform independent and programming independent. The application that consumes the web service, simply accesses it, without needing to know how this web service has actually been implemented & created.

Here are some of the major differences:
  * ASP.
NET Web Services may be accessed using HTTP only. Remoting objects may be accessed over any protocol like TCP, SMTP, HTTP
  * Web Service are Stateless, whereas Remoting has support for both stateless and with-state environment, which is achieved using Singleton and Singlecall activation
ASP.NET provides good support to create Web Services. They are easy to deploy. In comparison, Remoting is little complex.
  * Web services may be considered very reliable, due to the fact that they are hosted on
IIS. In remoting, if IIS is'nt used, then methods like plumbing have to be used to ensure the application reliability.
  * In .NET, when we create an application that consumes a web service, the web service may or may not be built using .NET. But while implementing Remoting in .NET, both the applications must be built in .NET.
  * Using web services, only a limited number of types may be serialized (XML). Using Remoting, objects like SOAP objects, Binary objects & XML Objects may be serialized.
61)  What is the difference between Authorization and Authentication?
Both Authentication and Authorization are concepts of providing permission to users to maintain different levels of security, as per the application requirement.

Authentication is the mechanism whereby systems may securely identify their users.
Authentication systems depend on some unique bit of information known only to the individual being authenticated and the authentication system.

Authorization is the mechanism by which a system determines what level of access a particular authenticated user should have to secured resources controlled by the system.

When a user logs on to an application/system, the user is first Authenticated, and then Authorized.

ASP.NET has 3 ways to Authenticate a user:
1) Forms Authentication
2) Windows Authentication
3) Passport Authentication (This is obsolete in .NET 2.0)
The 4th way is "None" (means no authentication)

The Authentication Provider performs the task of verifying the credentials of the user ans decides whether a user is authenticated or not. The authentication may be set using the web.config file.

Windows Authentication provider is the default authentication provider for ASP.NET applications. When a user using this authentication logs in to an application, the credentials are matched with the Windows domain through IIS.

There are 4 types of Windows Authentication methods:
1) Anonymous Authentication - IIS allows any user
2) Basic Authentication - A windows username and password has to be sent across the network (in plain text format, hence not very secure). 3)
Digest Authentication - Same as Basic Authentication, but the credentials are encrypted. Works only on IE 5 or above
4) Integrated Windows Authentication - Relies on
Kerberos technology, with strong credential encryption

Forms Authentication - This authentication relies on code written by a developer, where credentials are matched against a database. Credentials are entered on web forms, and are matched with the database table that contains the user information.

Authorization in .NET - There are two types:

FileAuthorization - this depends on the NTFS system for granting permission
UrlAuthorization - Authorization rules may be explicitly specified in web.config for different web URLs.
62)  What is the difference between System.Array.CopyTo and System.Array.Clone in .NET?
The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy.
63)  What is the difference between ExecuteScalar and ExecuteNonQuery? What is ExecuteReader?
ExecuteScalar - Returns only one value after execution of the query. It returns the first field in the first row. This is very light-weight and is perfect when all your query asks for is one item. This would be excellent for receiving a count of records (Select Count(*)) in an sql statement, or for any query where only one specific field in one column is required.

ExecuteNonQuery - This method returns no data at all. It is used majorly with Inserts and Updates of tables. It is used for execution of
DML commands.
SqlCommand cmd = new SqlCommand("Insert Into t_SomeTable Values('1','2')",con);
//note that con is the connection object
cmd.ExecuteNonQuery(); //The SQL Insert Statement gets executed
ExecuteReader - This method returns a DataReader which is filled with the data that is retrieved using the command object. This is known as a forward-only retrieval of records. It uses our SQL statement to read through the table from the first to the last record.

No comments:

Post a Comment