Advanced ASP.net Interview Questions Sharepointloversdotcom

download Advanced ASP.net Interview Questions Sharepointloversdotcom

of 45

Transcript of Advanced ASP.net Interview Questions Sharepointloversdotcom

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    1/45

    http://www.sharepointlovers.com

    Diversities1. Diversities between Classic ASP and ASP.Net?

    Answer:

    ASP is Interpreted language based on scripting languages like Jscript orVBScript.

    ASP has Mixed HTML and coding logic.

    Limited development and debugging tools available. Limited OOPS support.

    Limited session and application state management.

    Poor Error handling system.

    No in-built support for XML.

    No fully distributed data source support.

    while

    ASP.Net is supported by compiler and has compiled language support.

    Separate code and design logic possible.

    Variety of compilers and tools available including the Visual studio.Net.

    Completely Object Oriented.

    Complete session and application state management.

    Full proof error handling possible. Full XML Support for easy data exchange.

    Fully distributed data source support.2. Whats the Diversities between Response.Write () and Response.Output.Write ()?

    Answer: Response.Outout.Write allows us to write the formatted out put.3. Can you explain the diversity between an ADO.NET Dataset and an ADO

    Recordset?

    Answer:

    A DataSet can represent an entire relational database in memory, completewith tables, relations, and views, A Recordset can not.

    A DataSet is designed to work without any continues connection to theoriginal data source; Recordset maintains continues connection with the original

    data source. There's no concept of cursor types in a DataSet, They are bulk loaded, whileRecordset work with cursors and they are loaded on demand.

    DataSets have no current record pointer, you can use For Each loops tomove through the data. Recordsets have pointers to move through them.

    You can store many edits in a DataSet, and write them to the original datasource in a single operation. Recordset can have a single edit at a time.

    Dataset can fetch source data from many tables at a time, for Recordset you

    can achieve the same only using the SQL joins.4. What is the Diversities between an abstract method & virtual method?

    Answer: An Abstract method does not provide an implementation and forces overriding to the derivingclass (unless the deriving class also an abstract class), where as the virtual method has an implementationand leaves an option to override it in the deriving class. Thus Virtual method has an implementation &

    provides the derived class with the option of overriding it. Abstract method does not provide animplementation & forces the derived class to override the method.

    5. What is the Diversities between static or dynamic assemblies?Answer: Assemblies can be static or dynamic. Static assemblies can include .NET Framework types(interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource files, and soon). Static assemblies are stored on disk in portable executable (PE) files. You can also use the .NETFramework to create dynamic assemblies, which are run directly from memory and are not saved to diskbefore execution. You can save dynamic assemblies to disk after they have executed.

    Page 1 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    2/45

    http://www.sharepointlovers.com

    6. What are the Diversities between Structure and Class?Answer:

    Structures are value type and Classes are reference type.

    Structures can not have contractors or destructors. Classes can have bothcontractors and destructors.

    Structures do not support Inheritance, while Classes support Inheritance.

    7. What are the Diversities between const and readonly?Answer:

    A const can not be static, while readonly can be static.

    A const need to be declared and initialized at declaration only, while areadonly can be initialized at declaration or by the code in the constructor.

    A consts value is evaluated at design time, while a readonlys value isevaluated at runtime.

    8. Diversitiess between dataset.clone and dataset.copyAnswer:dataset.clone copies just the structure of dataset (including all the datatables, schemas, relations andconstraints.); however it doesnt copy the data. On the other hand dataset.copy, copies both the datasetstructure and the data.

    9. Describe the Diversities between inline and code behind.

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

    10. What is Diversities between Namespace and Assembly?Answer: Namespace is a logical design-time naming convenience, whereas an assembly establishes thename scope for types at run time.

    11. What is the Diversities between early binding and late binding?Answer: Calling a non-virtual method, decided at a compile time is known as early binding. Calling avirtual method (Pure Polymorphism), decided at a runtime is known as late binding.

    12. What is the Diversities between Custom Control and User Control?Answer:Custom Controls are compiled code (Dlls), easier to use, difficult to create, and can be placed in toolbox.Drag and Drop controls. Attributes can be set visually at design time. Can be used by Multiple Applications(If Shared Dlls), Even if Private can copy to bin directory of web application add reference and use.

    Normally designed to provide common functionality independent of consuming Application. User Controlsare similar to those of ASP include files, easy to create, can not be placed in the toolbox and dragged -dropped from it. A User Control is shared among the single application files.

    13. What is the Diversities between ASP Session State and ASP.Net Session State?Answer: ASP session state relies on cookies, Serialize all requests from a client, does not survive processshutdown, Can not maintained across machines in a Web farm.

    14. Diversities between ASP Session and ASP.NET Session?Answer: Asp.net session supports cookie less session & it can span across multiple servers.

    15. Can you explain the Diversities between an ADO.NET Dataset and an ADORecordset? (Repeated but more explanatory)Answer:In ADO, the in-memory representation of data is the recordset. In ADO.NET, it is the dataset.There are important Diversitiess between them.

    o A recordset looks like a single table. If a recordset is to contain data from

    multiple database tables, it must use a JOIN query, which assembles the datafrom the various database tables into a single result table. In contrast, a dataset isa collection of one or more tables. The tables within a dataset are called datatables; specifically, they are DataTable objects. If a dataset contains data frommultiple database tables, it will typically contain multiple DataTable objects.That is, each DataTable object typically corresponds to a single database table orview. In this way, a dataset can mimic the structure of the underlying database.A dataset usually also contains relationships. A relationship within a dataset isanalogous to a foreign-key relationship in a database that is, it associates rowsof the tables with each other. For example, if a dataset contains a table about

    Page 2 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    3/45

    http://www.sharepointlovers.com

    investors and another table about each investors stock purchases, it could alsocontain a relationship connecting each row of the investor table with thecorresponding rows of the purchase table. Because the dataset can hold multiple,separate tables and maintain information about relationships between them, itcan hold much richer data structures than a recordset, including self-relatingtables and tables with many-to-many relationships.

    o In ADO you scan sequentially through the rows of the recordset using the ADO

    MoveNext method. In ADO.NET, rows are represented as collections, so youcan loop through a table as you would through any collection, or accessparticular rows via ordinal or primary key index. DataRelation objects maintaininformation about master and detail records and provide a method that allowsyou to get records related to the one you are working with. For example, startingfrom the row of the Investor table for "Nate Sun," you can navigate to the set ofrows of the Purchase table describing his purchases. A cursor is a databaseelement that controls record navigation, the ability to update data, and thevisibility of changes made to the database by other users. ADO.NET does nothave an inherent cursor object, but instead includes data classes that provide thefunctionality of a traditional cursor. For example, the functionality of a forward-only, read-only cursor is available in the ADO.NET DataReader object.

    o Minimized Open Connections : In ADO.NET you open connections only long

    enough to perform a database operation, such as a Select or Update. You canread rows into a dataset and then work with them without staying connected tothe data source. In ADO the recordset can provide disconnected access, butADO is designed primarily for connected access. There is one significantDiversities between disconnected processing in ADO and ADO.NET. In ADOyou communicate with the database by making calls to an OLE DB provider. InADO.NET you communicate with the database through a data adapter (anOleDbDataAdapter, SqlDataAdapter, OdbcDataAdapter, or OracleDataAdapterobject), which makes calls to an OLE DB provider or the APIs provided by theunderlying data source. The important Diversities is that in ADO.NET the dataadapter allows you to control how the changes to the dataset are transmitted tothe database by optimizing for performance, performing data validationchecks, or adding any other extra processing. Data adapters, data connections,

    data commands, and data readers are the components that make up a .NETFramework data provider. Microsoft and third-party providers can makeavailable other .NET Framework data providers that can be integrated intoVisual Studio.

    o Sharing Data between Applications. Transmitting an ADO.NET dataset between

    applications is much easier than transmitting an ADO disconnected recordset.To transmit an ADO disconnected recordset from one component to another,you use COM marshalling. To transmit data in ADO.NET, you use a dataset,which can transmit an XML stream.

    o Richer data types.COM marshalling provides a limited set of data types those

    defined by the COM standard. Because the transmission of datasets inADO.NET is based on an XML format, there is no restriction on data types.Thus, the components sharing the dataset can use whatever rich set of data types

    they would ordinarily use.o Performance. Transmitting a large ADO recordset or a large ADO.NET dataset

    can consume network resources; as the amount of data grows, the stress placedon the network also rises. Both ADO and ADO.NET let you minimize whichdata is transmitted. But ADO.NET offers another performance advantage, in thatADO.NET does not require data-type conversions. ADO, which requires COMmarshalling to transmit records sets among components, does require that ADOdata types be converted to COM data types.

    Page 3 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    4/45

    http://www.sharepointlovers.com

    o Penetrating Firewalls.A firewall can interfere with two components trying to

    transmit disconnected ADO recordsets. Remember, firewalls are typicallyconfigured to allow HTML text to pass, but to prevent system-level requests(such as COM marshalling) from passing.

    Abbreviations1. CLR= Common Language Runtime

    2. CLS = Common Language Specifications3. CTS = Common Type Specifications4. GC = Garbage Collector.5. WSDL = Web Services Description Language.6. MSIL = Microsoft Intermediate Language.7. CIL = Common Intermediate Language - MSIL.8. JIT = Just In Time.9. PE = Portable Executable A file format.10. COFF = Common Object File Format A file format.11. GAC = Global Assembly Cache.12. DDL = Data Definition Language.13. DML = Data Manipulation Language.14. CAS = Code Access Security.

    15. RCW = Runtime Callable Wrapper.16. CCW = COM Callable Wrapper.17. COM = Component Object Model.18. DOM = Document Object Model.19. DNA = Distributed interNet Applications Architecture.20. GUID = Globally Unique Identifier.21. MS-DTC = Microsoft Distributed Transaction Coordinator.22. OLTP = OnLine Transaction Processing.23. OLAP = OnLine Analytical Processing.24. RAD = Rapid Application Development.25. SMTP = Simple Mail Transfer Protocol.26. SOAP = Simple Object Access Protocol.27. TCP = Transfer Control Protocol.

    28. TLB = Type Library.29. UDF = Uniform Data Format.30. UDDI = Universal Description, Discovery and Integration.

    True/False1. A Web service can only be written in .NET?

    Answer: False2. To test a Web service you must create a windows application or Web application to

    consume this service?Answer: False, the web service comes with a test page and it provides HTTP-GETmethod to test it.

    3. A wbe service is only available through http://www.uddi.org?Answer: False

    Simple Questions1. What is IL? (What is MSIL or CIL, What is JIT?)

    MSIL is the CPU independent instruction set into which .Net framework programsare compiled. It contains instructions for loading, storing initializing, and callingmethods on objects.

    2. What is CLR?Answer: CLR also known as Common Language Run time provides a environment

    Page 4 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    5/45

    http://www.sharepointlovers.com

    in which program are executed, it activate object, perform security check on them,lay them out in the memory, execute them and garbage collect them.

    3. What is CTS?Answer: The common type system is a rich type system, built into the commonlanguage runtime, which supports the types and operations found in mostprogramming languages.

    4. What is CLS?Answer: CLS also known as Common Language Specification defines the ruleswhich all language must support, in order to be a part of .Net framework.TheCommon Language Specification is a set of constructs and constraints that serves asa guide for library writers and compiler writers. It allows libraries to be fully usablefrom any language supporting the CLS, and for those languages to integrate witheach other. The Common Language Specification is a subset of the common typesystem. The Common Language Specification is also important to applicationdevelopers who are writing code that will be used by other developers.

    5. Which class does the web page belong to in ASP.Net?Answer: System.Web.UI.Page

    6. Which class deals wit the users locale information?Answer: System.Web.UI.Page.Culture

    7. What data type does the RangeValidator control support?

    Answer: Integer, Date and String.8. What is the Diversities between Server.Transfer and Response.Redirect?

    Answer: Server.Transfer, transfers the control of a web page, posting a form data,while Response.Redirect simply redirects a page to another page, it can not post aform data to another page. Server.Transfer is more efficient over theResponse.Redirect, because Response.Redirect causes a round trip to server as thepage is processed once again on the client and a request is made to server there after.

    9. Can you give an example of what might be best suited to place in theApplication_Start and Session_Start subroutines?Answer: All the global declarations or the variables used commonly across theapplication can be deployed under Application_Start. All the user specific tasks ordeclarations can be dealt in the Session_Start subroutine.

    10. What is ViewState?

    Answer: ViewState is a .Net mechanism to store the posted data among post backs.ViewState allows the state of objects to be stored in a hidden field on the page, savedon client side and transported back to server whenever required.

    11. What is the lifespan for items stored in ViewState?Answer: Items stored in a ViewState exist for the life of the current page, includingthe post backs on the same page.

    12. Can we disable ViewState, If, yes how?Answer: ViewState can be disabled by using "EnableViewState" property set tofalse.

    13. Whats a bubbled event?Answer: When a complex control like datalist or datagrid, which contains a childcontrol, using an itemcommand can listen to the events raised by the child control inthe main control. The process of listening to the child control in the main or parent

    control is called as event bubbling.14. What is an assembly?

    Answer: Assemblies are the building blocks of the .NET framework. They are thelogical grouping of the functionality in a physical file.

    15. What are different types of Assemblies?Answer: Single file and multi file assembly. Assemblies can be static or dynamic.Private assemblies and shared assemblies

    16. Which method do you invoke on the DataAdapter control to load your generateddataset with data?Answer: DataAdapters fill () method is used to fill load the data in dataset.

    Page 5 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    6/45

    http://www.sharepointlovers.com

    17. Can you edit data in the Repeater control?Answer: No, it just reads the information from its data source.

    18. Which template is to be provided in the Repeater control in order to display a data?Which template will display every other row in another color?Answer:ItemTemplate, AlternatingItemTemplate

    19. What are the most important property and most important method of a Repeatercontrol?Answer: The DataSource property and DataBind () method.

    20. How many classes can a single .NET DLL contain?Answer: It can contain many classes.

    21. What are the advantages of an assembly?Answer: Increased performance. Better code management and encapsulation. It alsointroduces the n-tier concepts and business logic.

    22. What is the purpose of an Assembly?Answer: An assembly controls many aspects of an application. The assemblyhandles versioning, type and class scope, security permissions, as well as othermetadata including references to other assemblies and resources. The rules describedin an assembly are enforced at runtime.

    23. What a static assembly consist of in general?Answer: In general, a static assembly consist of the following four elements:

    Assembly Manifest, which contains the assembly metadata.

    Type Metadata.

    MSIL code that implements the types.

    A set of resources.From above all only the manifest is required, however the other types andresources add the additional functionality to the assembly.

    24. What is GAC or Global Assembly Cache?Answer: Global Assembly Cache (GAC) is a common place to share the .NETassemblies across many applications. GAC caches all strong named assemblyreferences within it. All System assemblies that come with the .NET frameworkreside in the GAC.

    25. How to view an assembly?Answer: We can use the tool "ildasm.exe" known as "Assembly Disassembler" toview the assembly.

    26. What is Authentication and Authorization?Answer: Authentication is the process of identifying users. Authentication isidentifying/validating the user against the credentials (username and password) andAuthorization performs after authentication. Authorization is the process of grantingaccess to those users based on identity. Authorization allowing access of specificresource to user.

    27. What are the types of Authentication? Describe.Answer: There are 3 types of Authentication. Windows, Forms and PassportAuthentication.

    Windows authentication uses the security features integrated into the

    Windows NT and Windows XP operating systems to authenticate andauthorize Web application users.

    Forms authentication allows you to create your own list/database of users

    and validate the identity of those users when they visit your Web site.

    Passport authentication uses the Microsoft centralized authenticationprovider to identify users. Passport provides a way to for users to use asingle identity across multiple Web applications. To use Passportauthentication in your Web application, you must install the Passport SDK.

    Page 6 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    7/45

    http://www.sharepointlovers.com

    28. What are the types of comment in C#?Answer: There are 3 types of comments in C#.Single line (//), Multi line (/* */) and Page/XML Comments (///).

    29. What is an ArrayList?Answer: The ArrayList object is a collection of items containing a single data typevalues.

    30. What is a HashTable?Answer: The Hashtable object contains items in key/value pairs. The keys are usedas indexes, and very quick searches can be made for values by searching throughtheir keys.

    31. What is SortedList?Answer: The SortedList object contains items in key/value pairs. A SortedList objectautomatically sorts items in alphabetic or numeric order.

    32. What is a Literal Control?Answer: The Literal control is used to display text on a page. The text isprogrammable. This control does not let you apply styles to its content!

    33. What is CAS or Code Access Security?Answer: CAS is the part of the .NET security model that determines whether or not apiece of code is allowed to run, and what resources it can use when it is running. Forexample, it is CAS that will prevent a .NET web applet from formatting a hard disk.

    34. What is Side-by-Side Execution?Answer: The CLR allows any versions of the same-shared DLL (shared assembly) toexecute at the same time, on the same system, and even in the same process. Thisconcept is known as side-by-side execution.

    35. What are the different types of Caching?Answer: There are three types of Caching:

    Output Caching: stores the responses from an asp.net page.

    Fragment Caching: Only caches/stores the portion of page (User Control)

    Data Caching: is Programmatic way to Cache objects for performance.36. What are the different types of Validation Controls?

    Answer: There are six types of validation controls available:

    RequiredFieldValidator

    RangeValidator

    RegularExpressionValidator

    CompareValidator

    CustomValidator

    ValidationSummary37. How to Manage State in ASP.Net?

    There are several ways to manage a state.

    ViewState

    QueryString

    Cookies

    Session

    Application38. What base class all Web Forms inherit from?

    Answer: System.Web.UI.Page.39. What method do you use to explicitly kill a users Session?

    Answer: HttpContext.Current.Session.Abandon().40. What are the layouts of ASP.NET Pages?

    Answer: GridLayout and FlowLayout. GridLayout positions the form object onabsolute x and y co-ordinates of the screen. FlowLayout positions the form objectsrelative to each other.

    41. What is the Web User Control?Answer: Combines existing Server and/or HTML controls by using VS.Net to create

    Page 7 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    8/45

    http://www.sharepointlovers.com

    functional units that encapsulate some aspects of UI. Resides in Content Files, whichmust be included in project in which the controls are used.

    42. What is the Composite Custom Control?Answer: combination of existing HTML and Server Controls.

    43. What are the satellite assemblies?Answer: in a multilingual or multi-cultural application, the localized assemblies,which contain language specific instructions that modify the core application, arekept separately and they are called satellite assemblies.

    44. What namespaces are necessary to create a localized application?Answer: System.Globalization, System.Resources

    Tricky Questions1. If Im developing an application that must accommodate multiple security levels

    though secure login and my ASP.NET web application is spanned across three web-servers (using round-robin load balancing) what would be the best approach tomaintain login-in state for the users?Answer: You can use the security state maintained using a database. (UseAuthentication mode as database)

    2. Whats the Diversities between Codebehind="MyCode.aspx.cs" and

    Src="MyCode.aspx.cs"?Answer: Visual Studio uses the Codebehind attribute to distinguish the page sourceor programming logic from the design. Also the src attribute will make the pagecompile on every request. That is the page will not be compiled in advance andstored in the bin as a dll instead it will be compiled at run time.

    3. Suppose you want a certain ASP.NET function executed on MouseOver over acertain button or textbox. Where do you add an event handler?Answer: Every web control has an ability to add the attributes on client side whichwill execute on client side and run a client side script like a javascript function.

    btnSubmit.Attributes.Add(onMouseOver,someClientCode();) //For on mouseover of a buttonTextBox1.Attributes.Add(onFocus,ClearText();) //For on focus of a text box

    4. Explain what a diffgram is and a good use for one?Answer: The DiffGram is one of the two XML formats that you can use to renderDataSet object contents to XML. For reading database data to an XML file to be sentto a Web Service.

    5. Name two properties common in every validation control?Answer: ControlToValidate and Text property.

    6. What tags do you need to add within the Datagrid tags to bind columns manually?Answer: Set AutoGenerateColumns Property to false on the Datagrid tag.

    7. What tag do you use to add a hyperlink column to the DataGrid?Answer:

    8. What is the transport protocol you use to call a Web service?Answer: SOAP (Simple Object Access Protocol) is the preferred protocol.

    9. Where on the Internet would you look for Web services?

    Answer: http://www.uddi.org10. Which control would you use if you needed to make sure the values in two differentcontrols matched?Answer: CompareValidator Control

    11. What are the assembly entry points? An Assembly can have how many entry pointsat a time?Answer: An assembly can have only one entry point from DllMain, WinMain orMain.

    12. What does an assembly contain?Answer:

    Page 8 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    9/45

    http://www.sharepointlovers.com

    Manifest - The metadata describing the information below. Assembly name - Aids in versioning and visibility scope. Version information - The version number is integrated into the assembly'sidentity. Types - Boundaries and scopes of methods, classes, properties, events andattributes. Locale - Information describing language/culture. Cryptographic Hash - Public key encoded hash acting as version/security check. Security Permissions - The permissions within the assembly determine thepermissions that can be granted for all aspects of the assembly contents.

    13. What does an assembly manifest contains?Answer: It contains assembly name, version number (major.minor.build.revision)and culture Information. It also specifies the strong name information, which isuseful for shared assemblies, and list of files, an assembly contains. It also providesinformation for type references in an assembly and other referenced assemblies.

    14. Which tool is used to deploy an assembly, so as the assembly is available to all theapplication?Answer: The GacUtil.exe is the tool, which allows us to add any assembly to thewindows GAC (Global Assembly Catche).

    15. How many catch statements can be associated with single try statement?

    Answer: There can be a zero or more catch statement for each try statement. So it hasnot limit to the number of catch statement per try statement.

    16. What is Console and System a Class/a Data Member/a routine/a namespace or atype?Answer: Console is a class and System is namespace.

    17. How many values can be returned from a method in C#?Answer: Only one value can be returned from method, however you can use ref orout parameters to change more than one value in called method.

    18. How to declare a variable named this in C#, with data type string?Answer: string @this;

    19. Can we change the dimension of Array at run time like Array [3, 4]?Answer: Yes, We can change only the first position of array dimension.

    20. What keyword is used to accept a variable number of parameter in a method?

    Answer: params keyword is used as to accept variable number of parameters.21. What is a Namespace? What is the use of a namespace?

    Answer: Namespaces are logical grouping of classes and other types in hierarchicalstructure. Namespaces are useful to avoid collision or ambiguity among the classesand type names. Another use of the namespace is to arrange a group of classes for aspecific purpose.

    22. What does a keyword using works for?Answer: Using is just a convention or a short-cut method which allows us to accessthe classes in a namespace by referencing it once. So when ever we want use theclasses or methods in them, we can avoid typing the entire namespace hierarchy.However it is not a good practice when there are likely chances to have nameambiguity or collision of class names.

    23. What is Enums in C#?

    Answer: Enums or Enumerators are used to declare a set of related constants (defaultstart with 0); they are only available with primitive data types like int and short etc.

    24. What is Delegates?Answer: Delegates are a type-safe, object-oriented implementation of functionpointers and are used in many situations where a component needs to call back to thecomponent that is using it. Delegates are generally used as basis of events, whichallow any delegate to easily be registered for as event.

    25. Which are the namespaces that are imported automatically by Visual Studio inASP.Net?Answer: There are 7 namespaces which are imported automatically.

    Page 9 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    10/45

    http://www.sharepointlovers.com

    System

    System.Collections

    System.IO

    System.web

    System.web.UI

    System.web.UI.HTMLControls

    System.web.UI.WebControls26. Which namespaces are used for data access?

    System.Data

    System.Data.OleDB

    System.Data.SQLClient27. What do you mean by boxing and un-boxing?

    Answer: C# provides us with Value types and Reference Types. Value Types arestored on the stack and Reference types are stored on the heap. The conversion ofvalue type to reference type is known as boxing and converting reference type backto the value type is known as un-boxing.e.g.int x = 10;

    object o = x ; // Implicit boxingobject o = (object) x; // Explicit Boxing

    x = o; // Implicit Un-Boxingx = (int)o; // Explicit Un-Boxing

    28. What are the different methods available under sqlcommand class to access the data?

    ExecuteReader Used where one or more records are returned SELECT

    Query.

    ExecuteNonQuery Used where it affects a state of the table and no data isbeing queried - INSERT, UPDATE, DELETE, CREATE and SET queries.

    ExecuteScalar Used where it returns a single record(a single valuenormally) SQL Functions like MIN(), NAX()

    29. What are the different types of Session state management options available withASP.NET?Answer: ASP.NET provides In-Process & Out-of-Process state management,Also known as "In-Proc" and "Out-Proc". In-Proc stores the session in memory ofthe web server, that is on the same server the ASP.Net page is.On the other hand Out-Proc session state management stores the session data onexternal data source, which can be a SQL Server or Server State Service. Out-of-Process state management requires the objects stored in session, must be serializable.

    30. What is Remoting? Give Example.Answer: Remoting is a means by which one operating system process, or program,can communicate with another process. The two processes can exist on the samecomputer or on two computers connected by a LAN or the Internet. Web services areprobably the best known type of remoting, but they are not the only option.

    31. When would you use .NET Remoting and when Web services?

    Answer: Use remoting for more efficient exchange of information when you controlboth ends of the application. Use Web services for open-protocol-based informationexchange when you are just a client or a server with the other end belonging tosomeone else.

    32. Whats a proxy of the server object in .NET Remoting?Answer: Its a fake copy of the server object that resides on the client side andbehaves as if it was the server. It handles the communication between real serverobject and the client object. This process is also known as marshaling.

    Page 10 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    11/45

    http://www.sharepointlovers.com

    33. What are remotable objects in .NET Remoting?Answer: Remotable objects are the objects that can be marshaled across theapplication domains. You can marshal by value, where a deep copy of the object iscreated and then passed to the receiver. You can also marshal by reference, wherejust a reference to an existing object is passed.

    34. What is Marshalling?Answer: Marshaling is a process of making an object in one process (the server)available to another process (the client). There are two ways to achieve themarshalling.

    i. Marshal by value: the server creates a copy of the object passes the copy to theclient. When a client makes a call to an object marshaled by value (MBV), theserver creates an exact copy and sends that copy to the client. The client canthen use the object's data and executable functionality directly within its ownprocess or application domain without making additional calls to the server.Objects that the application accesses frequently are best remoted using MBV.

    ii. Marshal by reference: the client creates a proxy for the object and then uses theproxy to access the object. When a client makes a call to an object marshaled byreference (MBR), the .NET framework creates a proxy in the client's applicationdomain and the client uses that proxy to access the original object on the server.

    Large objects that the application accesses relatively infrequently are goodcandidates for MBR.35. What is a Static class? What are its features?

    Answer: Static class is a class which can be used or accessed without creating aninstance of the class.Important Features:

    i. Static class only contains static members and a private constructor.ii. Static class cannot be instantiated.

    iii. Static classes are sealed by default and therefore cannot be inherited.36. What is sealed class? What are its features?

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

    In C# structs are implicitly sealed; therefore, they cannot be inherited.37. Can we declare a method as sealed?

    Answer: In C# a method can't be declared as sealed. However when we override amethod in a derived class, we can declare the overridden method as sealed. Bydeclaring it as sealed, we can avoid further overriding of this method.E.g.using System;class MyClass1{

    public int x;public int y;public virtual void Method() {

    Console.WriteLine("virtual method"); }

    }class MyClass : MyClass1{

    public override sealed void Method() {Console.WriteLine("sealed method"); }

    }class MainClass{ public static void Main() {

    MyClass1 mC = new MyClass();mC.x = 110;

    Page 11 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    12/45

    http://www.sharepointlovers.com

    mC.y = 150;Console.WriteLine("x = {0}, y = {1}", mC.x, mC.y);mC.Method(); }

    }38. What is a DataSet ?

    Answer: A DataSet is an in memory representation of data loaded from any datasource.

    39. What is a DataTable?Answer: A DataTable is a class in .NET Framework and in simple words aDataTable object represents a table from a database.

    40. If you want to view an Assembly how to you go about it? What is ILDASM?Answer: You can use the MSIL Disassembler (Ildasm.exe) to view Microsoftintermediate language (MSIL) information in a file. If the file being examined is anassembly, this information can include the assembly's attributes, as well asreferences to other modules and assemblies. This information can be helpful indetermining whether a file is an assembly or part of an assembly, and whether thefile has references to other modules or assemblies.

    41. Where is version information stored of an assembly?Answer: The version number is stored in the assembly manifest along with otheridentity information, including the assembly name and public key, as well as

    information on relationships and identities of other assemblies connected with theapplication.

    42. Is versioning applicable to private assemblies?Answer: No

    43. How to create a shared assembly or add an assembly to GAC?Answer: There are several ways an assembly can be added to GAC.i. Use .msi installer designed to work with the global assembly cache.

    ii. Use GACUtil.exeprovided by the .NET Framework SDK.iii. Use Windows Explorer to drag assemblies into the cache.

    44. What is strong Name?Answer:

    45. What is reflection?Answer: All .NET compilers produce metadata about the types defined in the

    modules they produce. This metadata is packaged along with the module (modules inturn are packaged together in assemblies), and can be accessed by a mechanismcalled reflection. The System.Reflection namespace contains classes that can be usedto interrogate the types for a module/assembly.

    46. How can I produce an assembly?Answer: Simply compile your class/module with the following command.C#.Net - CSC /t:library yourclassname.csVB.Net - VBC /t:library yourmodulename.vb

    47. What is an Application Domain? How they get created?Answer: An Application Domain can be thought of as a lightweight processescontrolled by the .Net runtime. Application Domains are usually created by hosts likeWindows Shell, ASP.NET and IE. When you run a .NET application from thecommand-line, the host is the Shell. The Shell creates a new Application Domain for

    every application.48. Do I have any control over the garbage collection algorithm?

    Answer: Yes, we have a limited control over the GC algorithm, For example, theSystem.GC class exposes a Collect method - this forces the garbage collector tocollect all unreferenced objects immediately.

    49. What is a life span of a static variable?Answer: A static variables life span is till the class is in memory.

    50. What is a Page Life Cycle of an ASP.Net page?Answer: There are various stages described as under.

    Page 12 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    13/45

    http://www.sharepointlovers.com

    Init

    LoadViewState

    LoadPostBackData

    Load

    RaisePostBackDataChangedEvent

    RaisePostBackEvents

    Pre-Render SaveViewState

    Render

    Unload51. Can the action attribute of a server-side tag be set to a value and if not how

    can you possibly pass data from a form to a subsequent Page?Answer: No, Assigning value will not work because will be overwritten at the timeof rendering. We can assign value to it by register a startup script which will set theaction value of form on client-side. On other hand we can use Server.Transfer orResponse.Redirect.

    52. How do you turn off cookies in one page of your asp.net application?Answer: We may not use them at the max, However to allow the cookies or not, isclient side functionality.

    53. Which method do you use to redirect to user to another page without performing around trip to Client?Answer: Server.Transfer(AnotherPage.aspx).

    54. How many namespaces are in .NET version 1.1?Answer: 124.

    55. Should Validation occur on Client/Server Side for Date Input?Answer: Both. Client-side reduces extra round-trip. Server-Side ensures preventionagainst hacking and failure against automated requests.

    56. What are the web form events?Answer:

    i. The first event that occurs in the life of a Web Form is the Init event. This israised so that we can have initialization code for the page. The controls on thepage are not yet created at this point. This event is raised once for each user of

    the page.ii. The Load event follows the Init event. Subsequently, it is raised each time the

    page is requested. When this event is raised, all child controls of the Web Formare loaded and accessible. You should be able to retrieve data and populate thecontrols so that they can render themselves on the page when sent back to theclient.

    iii. The PreRender event happens just before the page is rendered and sent back tothe client. We don't often handle this event; however, it depends on the situation.

    iv. The last event in the life of a Web Form is the Unload event. This happens whenthe page is unloaded from memory. Final cleanup should be done here.

    57. Why main function is static?Answer: To ensure there is only one entry point to the application.

    58. How CCW (COM Callable Wrapper) and RCW (Runtime Callable Wrapper) work?

    Answer:CCW: The .NET Framework includes support for COM clients to use .NETcomponents. When a COM client needs to create a .NET object, the CLR creates themanaged object and a COM callable wrapper (CCW) that wraps the object. TheCOM client interacts with the managed object through the CCW. The runtimecreates only one CCW for a managed object, regardless of how many COM clientsare using it.

    RCW: The .NET Framework includes extensive support for COM interoperability.

    Page 13 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    14/45

    http://www.sharepointlovers.com

    To allow .NET clients to interact with a COM component, .NET uses an RCWaspecial .NET proxy class that sits between your .NET code and the COMcomponent. The RCW handles all the details, including marshaling data types, usingthe traditional COM interfaces, and handling COM events.

    59. Can we copy a COM dll to GAC folder?Answer: No.

    60. How can you write a class to restrict that only one object of this class can be created?Answer: We can create a singleton class. Singleton class is a class which will returnnull if there is no prior instance of the same class is prevailing and will allow tocreate the new instance else it will return without creating a new instance of thatclass.

    61. What is concurrency? How will you avoid concurrency when dealing with dataset?(One user deleted one row after that another user through his dataset was trying toupdate same row. What will happen? How will you avoid this problem?)Answer:If the row we want to update has already been updated by another user, theDataAdapter throws a DBConcurrencyException. We can use the Row property ofthis exception to identify the row that caused the problem. Finally, to ensure that youalways have a set of fresh records inside your DataSet object, you can select theRefresh the DataSet advanced option in order to retrieve the records each time a newdatabase operation is performed:

    Use optimistic concurrency adds a WHERE condition to the INSERT, UPDATE,and DELETE statements generated automatically by the wizard in order to guaranteeto users that they are not going to change records that have been modified by otherusers, otherwise the command will fail.

    62. How do you merge two datasets into the third dataset in a simple manner?Answer: Use DataSet1.Merge (DataSet2) method to merge two datasets and copyDataSet1 to DataSet3.

    63. If you are executing these statements in commandObject. Select * from Table1;Select * from Table2 How you will deal result set?Answer:

    64. If a dataset contains 100 rows, how to fetch rows between 5 and 15 only?Answer:

    65. How to generate XML from a dataset and vice versa?

    Answer: We can use WriteXml() and ReadXml() methods of DataSet Object.66. Can the action attribute of a server-side Form tag be set to a value and if not how can

    you possibly pass data from a form page to a subsequent page?67. What is the Diversities between Server.Transfer and response.Redirect? Answer: The

    Server.Transfer() method stops the current page from executing, and runs the contenton the specified page, when the execution is complete the control is passed back tothe calling page. While the response.Redirect() method transfers the control on thespecified page and the control is never passed back to calling page after execution.

    68. What are the Advantages and DisAdvantages of viewstate?Answer: Maintaining viewstate across post backs is a good user experience and alsohelps minimizing the validation errors to some extent, however maintaining viewstate makes the page heavier as it stores the encoded view state details in the hiddenfield.

    69. Which template must you provide, in order to display data in a Repeater control?Answer:

    70. What is Session State Management? Describe.Answer: you can apply state management to your applications in a number of ways.Session State Management determines how the sessions are stored by the ASP.NETapplication. The default option is InProc. Other options include Off, StateServer, andSQLServer. Running sessions in-process (InProc) means that the sessions are storedin the same process as the ASP.NET worker process. Therefore, if IIS is shut downand then brought up again, all the sessions are destroyed and unavailable to endusers. StateServer means that sessions are stored out-of-process by a Windows

    Page 14 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    15/45

    http://www.sharepointlovers.com

    service called ASPState. SQLServer is by far the most secure way to deal with yoursessions. It stores them directly in SQL Server itself. Although it is the most securemethod, it is also the least performance-efficient method.

    71. Which template must you provide, in order to display data in a Repeater control?Answer: The Diversities between a DataList control and a Repeater control is thatthe DataList control has a set of default templates, and the Repeater control is ablank space in which you must build all of the templates manually.

    72. What base class do all web forms inherit from?Answer: System.Web.UI.Page

    73. Which two properties are on every validation control?Answer: ControlToValidate and ErrorMessage.

    74. How do you create a permanent cookie?Answer: Set the expiry date as datetime.maxvalue.

    75. What does WSDL stand for?Answer: Web Services Description Language.

    76. How is a property designated as read-only?Answer: Use only the get accessor.

    77. Which control would you use if you needed to make sure the values in two differentcontrols matched?Answer: CompareValidator.

    78. To test a Web Service you must create a windows application or web application toconsume this service? It is True/False?Answer: Every web service by default generates a test page, we need not create orconsume the Web service in order to test it.

    79. What is the maximum length of a varchar in SQL Server? Answer: 25580. Is string a value type or a reference type?

    Answer: String is the reference type.81. Whats the C# equivalent of C++ try catch blocks, which was a catch-all statement

    for any possible exception?Answer: a simple catch block shown as under will catch all the exceptions which fallunder System.Exception class.try{

    ---Some code to execute----

    }catch {----some exception handling---}

    82. Can multiple catch blocks be executed?Answer: No, once an exception fall under a catch block the control will never bepassed to next catch block instead it will be passed to the finally block (if any or/and)the code next to the finally block.

    83. How do you generate documentation from the C# file commented properly with acommand-line compiler?Answer: Compile it with a /doc switch.

    84. What debugging tools come with the .NET SDK?Answer: CorDBG command-line debugger, and DbgCLR graphic debugger.

    Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile theoriginal C# file using the /debug switch.

    85. What does assert () do?Answer: In debug compilation, assert takes in a Boolean condition as a parameter,and shows the error dialog if the condition is false. The program proceeds withoutany interruption if the condition is true.

    86. Whats the Diversities between the Debug class and Trace class?Answer: Documentation looks the same. Use Debug class for debug builds, useTrace class for both debug and release builds.

    Page 15 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    16/45

    http://www.sharepointlovers.com

    87. How do you debug an ASP.NET Web application?Answer: Attach the aspnet_wp.exe process to the DbgClr debugger.

    88. Name the 4 .NET authentification methods.Answer: ASP.NET, in conjunction with Microsoft Internet Information Services(IIS), can authenticate user credentials such as names and passwords using any of thefollowing authentication methods:a. Windows: Basic, digest, or Integrated Windows Authentication (NTLM orKerberos).b. Microsoft Passport authenticationc. Forms authenticationd. Client Certificate authentication

    89. Explain what a diffgram is and a good use for one?Answer: A DiffGram is an XML format that is used to identify current and originalversions of data elements. The DataSet uses the DiffGram format to load and persistsits contents, and to serialize its contents for transport across a network connection.When a DataSet is written as a DiffGram, it populates the DiffGram with all thenecessary information to accurately recreate the contents, though not the schema, ofthe DataSet, including column values from both the Original and Current rowversions, row error information, and row order.

    90. Where would you use an iHTTPModule, and what are the limitations of anyapproach

    you might take in implementing one?Answer: One of ASP.NETs most useful features is the extensibility of the HTTPpipeline, the path that data takes between client and server. You can use them toextend your ASP.NET applications by adding pre- and post-processing to eachHTTP request coming into your application. For example, if you wanted customauthentication facilities for your application, the best technique would be to interceptthe request when it comes in and process the request in a custom HTTP module.

    91. What method do you use to explicitly kill a users session?Answer: The Abandon method destroys all the objects stored in a Session object andreleases their resources.If you do not call the Abandon method explicitly, the server destroys these objectswhen the session times out.Syntax: Session.Abandon

    92. How do you turn off cookies for one page in your site?Answer: Use the Cookie.Discard Property which Gets or sets the discard flag set bythe server. When true, thisproperty instructs the client application not to save the Cookie on the users hard diskwhen a session ends.

    93. Which method do you use to redirect the user to another page without performing around trip to the client?Answer: Server.transfer()

    94. Where do you store the information about the users locale?Answer: System.Web.UI.Page.Culture

    95. Whats the Diversities between Codebehind="MyCode.aspx.cs"andSrc="MyCode.aspx.cs"?Answer: CodeBehind is relevant to Visual Studio.NET only.

    96. What data type does the RangeValidator control support?Answer: Integer, String and Date.

    97. What is cookie less session? How it works?Answer: By default, ASP.NET will store the session state in the same process thatprocesses the request, just as ASP does. If cookies are not available, a session can betracked by adding a session identifier to the URL. This can be enabled by setting thefollowing:

    98. What is State Management in .Net and how many ways are there to maintain a statein .Net? What is view state?

    Page 16 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    17/45

    http://www.sharepointlovers.com

    Answer: Web pages are recreated each time the page is posted to the server. Intraditional Web programming, this would ordinarily mean that all informationassociated with the page and the controls on the page would be lost with each roundtrip.To overcome this inherent limitation of traditional Web programming, the ASP.NETpage framework includes various options to help you preserve changes that is, formanaging state. The page framework includes a facility called view state thatautomatically preserves property values of the page and all the controls on it betweenround trips.However, you will probably also have application-specific values that you want topreserve. To do so, you can use one of the state management options.Client-Based State Management Options:- View State- Hidden Form Fields- Cookies- Query StringsServer-Based State Management Options-Application State-Session State-Database Support

    99. What are the different modes for the sessionstates in the web.config file?Answer:Off Indicates that session state is not enabled.Inproc Indicates that session state is stored locally.StateServer Indicates that session state is stored on a remote server.SQLServer Indicates that session state is stored on the SQL Server.

    100. In a Webservice, need to display 10 rows from a table. So DataReader or DataSet isbest choice?Answer: WebService will support only DataSet.

    101. What is singleton and what is singlecall?Answer: Singleton types never have more than one instance at any one time. If aninstance exists, all client requests are serviced by that instance.Single Call types always have one instance per client request. The next method

    invocation will be serviced by a different server instance, even if the previousinstance has not yet been recycled by the system.

    102. What is the Diversities between Compiler and Interpreter?Answer:Compiler:A compiler is a program that translates program (called source code) written in somehigh level language into object code. The compiler derives its name from the way itworks, looking at the entire piece of source code and collecting and reorganizing theinstructions. A compiler translates high-level instructions directly into machinelanguage and this process is called compiling.Interpreter:An interpreter translates high-level instructions into an intermediate form, which itthen executes. Interpreter analyzes and executes each line of source code in

    succession, without looking at the entire program; the advantage of interpreters isthat they can execute a program immediately. Compilers require some time before anexecutable program emerges. However, programs produced by compilers run muchfaster than the same programs executed by an interpreter.Compiled programs generally run faster than interpreted programs. The advantage ofan interpreter, however, is that it does not need to get through the compilation stageduring which machine instructions are generated. This process can be time-consuming if the program is long. The interpreter, on the other hand, canimmediately execute high-level programs. For this reason, interpreters are sometimesused during the development of a program, when a programmer wants to add small

    Page 17 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    18/45

    http://www.sharepointlovers.com

    sections at a time and test them quickly.Because compilers translate source code intoobject code, which is unique for each type of computer, many compilers areavailable for the same language. For example, there is a C compiler for PCs andanother for UNIX computers.

    OOPS1. What are the OOPS concepts?

    Answer:1) Encapsulation: It is the mechanism that binds together code and data inmanipulates, and keeps both safe from outside interference and misuse. In short itisolates a particular code and data from all other codes and data. A well-definedinterface controls the access to that particular code and data.2) Inheritance: It is the process by which one object acquires the properties ofanother object. This supports the hierarchical classification. Without the use ofhierarchies, each object would need to define all its characteristics explicitly.However, by use of inheritance, an object need only define those qualities that makeit unique within its class. It can inherit its general attributes from its parent. A newsub-class inherits all of the attributes of all of its ancestors.

    3) Polymorphism: It is a feature that allows one interface to be used for general classof actions. The specific action is determined by the exact nature of the situation. Ingeneral polymorphism means "one interface, multiple methods"; this means that it ispossible to design a generic interface to a group of related activities. This helpsreduce complexity by allowing the same interface to be used to specify a generalclass of action. It is the compiler's job to select the specific action (that is, method) asit applies to each situation.

    2. What is a class?Answer: Class is concrete representation of an entity. It represents a group of objects,which hold similar attributes and behavior.It provides Abstraction andEncapsulations.

    3. What is an Object? What is Object Oriented Programming?Answer: Object represents/resembles a Physical/real entity. An object is simply

    something you can give a name. Object Oriented Programming is a Style ofprogramming that represents a program as a system of objects and enables code-reuse.

    4. What is Encapsulation?Encapsulation is binding of attributes and behaviors. Hiding the actualimplementation and exposing the functionality of any object. Encapsulation is thefirst step towards OOPS, is the procedure of covering up of dataand functions into asingle unit (called class). Its main aim is to protect the data from out side world.

    5. What is Abstraction?Answer: Hiding the complexity. It is a process of defining communication interfacefor the functionality and hiding rest of the things.

    6. What is Overloading?Answer: Adding a new method with the same name in same/derived class but with

    different number/types of parameters. It implements Polymorphism.7. What is Overloading?Answer: A process of creating different implementation of a method having a samename as base class, in a derived class. It implements Inheritance.

    8. What is Shadowing?Answer: When the method is defined as Final/sealed in base class and not overrideable and we need to provide different implementation for the same. This process isknown as shadowing, uses shadows/new keyword.

    Page 18 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    19/45

    http://www.sharepointlovers.com

    9. What is Inheritance?Answer: It is a process of acquiring attributes and behaviors from another object(normally a class or interface).

    10. What is an Abstract class?Answer: An abstract class is a special kind of class that cannot be instantiated. Itnormally contains one or more abstract methods or abstract properties. It providesbody to a class.

    11. What is an Interface?Answer: An interface has no implementation; it only has the signature or in otherwords, just the definition of the methods without the body.

    12. What is Polymorphism?Answer: Mean by more than one form. Ability to provide different implementationbased on different number/type of parameters.

    13. What is Pure-Polymorphism?Answer: When a method is declared as abstract/virtual method in a base class andwhich is overridden in a base class. If we create a variable of a type of a base classand assign an object of a derived class to it, it will be decided at a run time, whichimplementation of a method is to be called.This is known as Pure-Polymorphism or Late-Binding.

    14. What is a Constructor?

    Answer: A special Method Always called whenever an instance of the class iscreated.

    15. What is a Destructor?Answer: A special method called by GC. Just before object is being reclaimed byGC.

    16. How a base class method is hidden?Answer: Hiding a base class method by declaring a method in derived class withkeyword new. This will override the base class method and old method will besuppressed.

    17. What Command is used to implement properties in C#?Answer: get & set access modifiers are used to implement properties in c#.

    18. What is method overloading?Answer: Method overloading is having methods with same name but carrying

    different signature, this is useful when you want a method to behave differentlydepending upon a data passed to it.

    19. Can constructors have parameters?20. What are Static Assembly and Dynamic Assembly?

    Answer: Static assemblies can include .NET Framework types (interfaces andclasses) as well as resources for the assembly (bitmaps, JPEG files, resource files,and so forth). Static assemblies are stored on disk. Dynamic assemblies run directlyfrom memory and are not saved to disk before execution.

    21. Describe the functionality of an assembly.Answer: It is the smallest unit that has version control. All types and resources in thesame assembly are versioned as a unit and support side by side execution.Assemblies contain the metadata and other identities which allow the commonlanguage runtime to execute. They are the boundaries providing the type check. They

    the unit where security permissions are requested and granted.22. What is serialization?

    Answer: Serialization is the process of converting an object into a stream of bytes.De-serialization is the opposite process of creating an object from a stream of bytes.Serialization/De-serialization is mostly used to transport objects (e.g. duringremoting), or to persist objects (e.g. to a file or database). There are two separatemechanisms provided by the .NET class library for serialization - XmlSerializer andSoapFormatter and BinaryFormatter. Microsoft uses XmlSerializer for WebServices, and uses SoapFormatter/BinaryFormatter for remoting.

    Page 19 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    20/45

    http://www.sharepointlovers.com

    23. What is a static class?Answer: When a class has been defined as static, it is not creatable using the newkeyword, and it can contain only static members or fields.

    24. What is static member?Answer: The member defined as static which can be invoked directly from the classlevel, rather than from its instance.

    25. What is static function/method?Answer:Static methods need not need to create an instance of the class containing itand can be accessed directly from class level.

    26. What is static constructor? (This is introduced in VS 2005)Answer: When constructors are used to set the value of a types data at the time ofconstruction, if we want the value of such static data is to be preserved regardless ofhow many objects of the type are created, we have to define the constructor withstatic keyword.

    27. Why Main () method is static?Answer:To ensure there is only one entry point to the application.

    28. What is Reflection?Answer: Reflection is the process of runtime type discovery.

    29. What do you mean by Serialize?Answer: The term serialization describes the process of persisting (and possibly

    transferring) the state of an object to a stream.30. What is an Asynchronous delegate? (VS 2005)

    Answer: When you invoke a delegate asynchronously, no new thread is created.Instead, the CLR automatically assigns a free thread from a small thread pool that itmaintains. Typically, this thread pool starts with one thread and increases to amaximum of about 25 free threads on a single-CPU computer. As a result, if youstart 50 asynchronous operations, one after the other, the first 25 will complete first.As soon as one ends, the freed thread is used to execute the next asynchronousoperation.

    31. How to create events for a control? What are custom events?Answer:Declare a public delegate and set of events to listen from.public delegate void CarEventHandler(string msg);

    public event CarEventHandler AboutToBlow;public event CarEventHandler BlewUp;

    32. Whats the advantage of using System.Text.StringBuilder over System.String?Answer: StringBuilder is more efficient in the cases, where a lot of manipulation isdone to the text. Strings are immutable, so each time its being operated on, a newinstance is created.

    33. Can you store multiple data types in System.Array?Answer: No.

    34. Whats the Diversities between the System.Array.CopyTo() andSystem.Array.Clone()?Answer: System.Array.CopyTo() performs a deep copy while System.Array.Clone()performs a shallow copy.

    35. How can you sort the elements of the array in descending order?

    Answer: First use Sort () method to sort the array and then call Reverse () method toarrange array elements in descending order.

    36. Whats the .NET datatype that allows the retrieval of data by a unique key?Answer: A HashTable.

    37. Whats class SortedList underneath?Answer: A sorted HashTable.

    38. Will finally block get executed if the exception had not occurred?Answer: Yes.

    39. When you inherit a protected class-level variable, who is it available to?Answer: Classes in the same namespace.

    Page 20 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    21/45

    http://www.sharepointlovers.com

    40. Are private class-level variables inherited?Answer: Yes, but they are not accessible, so looking at it you can honestly say thatthey are not inherited. But they are.

    41. Describe the accessibility modifier protected internal.Answer: Its available to derived classes and classes within the same Assembly (andnaturally from the base class its declared in).

    42. Hows method overriding different from overloading?Answer: When overriding, you change the method behavior for a derived class.Overloading simply involves having a method with the same name within the class.

    43. What does the keyword virtual mean in the method definition?Answer: The method can be over-ridden.

    44. Can you declare the override method static while the original method is non-static?Answer: No, you cant, the signature of the virtual method must remain the same,only the keyword virtual is changed to keyword override.

    45. Can you override private virtual methods?Answer: No, moreover, you cannot access private methods in inherited classes, haveto be protected in the base class to allow any sort of access.

    46. Can you prevent your class from being inherited and becoming a base class for someother classes?Answer: Yes, thats what keyword sealed in the class definition is for. The developer

    trying to derive from your class will get a message: cannot inherit from Sealed classWhateverBaseClassName. Its the same concept as final class in Java.

    47. Can you allow class to be inherited, but prevent the method from being over-ridden?Answer: Yes, just leave the class public and make the method sealed.

    48. When do you absolutely have to declare a class as abstract?Answer: When at least one of the methods in the class is abstract. When the classitself is inherited from an abstract class, but not all base abstract methods have beenover-ridden.

    49. Can we declare private methods inside an Interface? Why cant you specify theaccessibility modifier for methods inside the interface?No, they all must be public. Therefore, to prevent you from getting the falseimpression that you have any freedom of choice, you are not allowed to specify anyaccessibility, its public by default.

    50. Whats the Diversities between an interface and abstract class?Answer: In the interface all methods must be abstract; in the abstract class somemethods can be concrete. In the interface no accessibility modifiers are allowed,which is ok in abstract classes.

    51. If a base class has a bunch of overloaded constructors, and an inherited class hasanother bunch of overloaded constructors, can you enforce a call from an inheritedconstructor to an arbitrary base constructor?Answer: Yes, just place a colon, and then keyword base (parameter list to invoke theappropriate constructor) in the overloaded constructor definition inside the inheritedclass.

    52. Whats the Diversities between System.String and System.StringBuilder classes?Answer: System.String is immutable; System.StringBuilder was designed with thepurpose of having a mutable string where a variety of operations can be performed.

    53. How do you initiate a string without escaping each backslash?Answer: Put @ sign in front of the double-quoted string.e.g. @C:\Documents and Settings\Administrator\My Documents; is equivalent toC:\\Documents and Settings\\Administrator\\My Documents.

    54. What are valid signatures for the Main function?Answer:public static void Main()public static int Main()public static void Main( string[] args )public static int Main(string[] args )

    Page 21 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    22/45

    http://www.sharepointlovers.com

    55. Explain encapsulation.Answer: The implementation is hidden, the interface is exposed.

    56. Where all the value-type variables allocated in the computer RAM?Answer: Stack

    57. Where do the reference-type variables go in the RAM?Answer: The references go on the stack, while the objects themselves go on the heap.

    58. What is the Diversities between the value-type variables and reference-type variablesin terms of garbage collection?Answer: The value-type variables are not garbage-collected, they just fall off thestack when they fall out of scope, the reference-type objects are picked up by GCwhen their references go null.

    59. How do you convert a string into an integer in .NET?Answer: Int32.Parse(string), Convert.ToInt32()

    60. How do you enforce garbage collection in .NET?Answer: System.GC.Collect();

    61. Can you declare a C++ type destructor in C# like ~MyClass()?Answer: Yes, but whats the point, since it will call Finalize (), and Finalize () has noguarantees when the memory will be cleaned up, plus, it introduces additional loadon the garbage collector. The only time the finalizer should be implemented, is whenyoure dealing with unmanaged code.

    62. Whats the Diversities between const and readonly?Answer: You can initialize readonly variables to some runtime values. Lets say yourprogram uses current date and time as one of the values that wont change. This wayyou declarepublic readonly string DateT = new DateTime().ToString();This is not possible with a constant.

    63. What happens when you encounter a continue statement inside the for loop?Answer: The code for the rest of the loop is ignored; the control is transferred backto the beginning of the loop.

    64. Describe the compilation process for .NET code?Answer: Source code is compiled and run in the .NET Framework using a two-stageprocess. First, source code is compiled to Microsoft intermediate language (MSIL)code using a .NET Framework-compatible compiler, such as that for Visual Basic

    .NET or Visual C#. Second, MSIL code is compiled to native code.65. In which cases you use override and new base?

    Answer: Use the new modifier to explicitly hide a member inherited from a baseclass. To hide an inherited member, declare it in the derived class using the samename, and modify it with the new modifier.

    66. In which Scenario you will go for Interface or Abstract Class?Answer: Interfaces, like classes, define a set of properties, methods, and events. Butunlike classes, interfaces do not provide implementation. They are implemented byclasses, and defined as separate entities from classes. Even though class inheritanceallows your classes to inherit implementation from a base class, it also forces you tomake most of your design decisions when the class is first published.Abstract classes are useful when creating components because they allow youspecify an invariant level of functionality in some methods, but leave the

    implementation of other methods until a specific implementation of that class isneeded. They also version well, because if additional functionality is needed inderived classes, it can be added to the base class without breaking code.

    67. What are the access-specifiers available in c#?Answer: Private, Protected, Public, Internal, Protected Internal.

    68. Explain about Protected and protected internal, internal access-specifier?Answer: protected - Access is limited to the containing class or types derived fromthe containing class.internal - Access is limited to the current assembly.

    Page 22 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    23/45

    http://www.sharepointlovers.com

    protected internal - Access is limited to the current assembly or types derived fromthe containing class.

    69. Diversities between type constructor and instance constructor? What is staticconstructor, when it will be fired? And what is its use?Answer: (Class constructor method is also known as type constructor or typeinitializer)Instance constructor is executed when a new instance of type is created and the classconstructor is executed after the type is loaded and before any one of the typemembers is accessed. (It will get executed only 1st time, when we call any staticmethods/fields in the same class.) Class constructors are used for static fieldinitialization. Only one class constructor per type is permitted, and it cannot use thevararg (variable argument) calling convention.A static constructor is used to initialize a class. It is called automatically to initializethe class before the first instance is created or any static members are referenced.

    70. What is Private Constructor? Whats its use? Can you create instance of a classwhich has Private Constructor?Answer: When a class declares only private instance constructors, it is not possiblefor classes outside the program to derive from the class or to directly create instancesof it. (Except Nested classes)Make a constructor private if:

    - You want it to be available only to the class itself. For example, you might have aspecial constructor used only in the implementation of your class' Clone method.- You do not want instances of your component to be created. For example, you mayhave a class containing nothing but Shared utility functions, and no instance data.Creating instances of the class would waste memory.

    71. I have 3 overloaded constructors in my class. In order to avoid making instance ofthe class do I need to make all constructors to private?Answer: Yes

    72. Overloaded constructor will call default constructor internally?Answer: No

    SQL: Queries

    1. Write a query to select the second highest salary from a table.Answer: SELECT max(salary) AS salary2 FROM orders WHERE salary 1.

    4. Using query analyzer, name 3 ways you can get an accurate count of the number ofrecords in a table.Answer:a. select count (coumnName(s)) from tableName.

    b. select count_big(coumnName(s)) from tableNamec. select columnName from ableNameselect @@ROWCOUNT as rowCount

    SQL: Questions1. What is the Diversities between Delete and Truncate command in SQL?

    Answer: Delete command and truncate command both will delete the data, howeverthe truncate command can not be rolled back as delete can be. The delete command

    Page 23 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    24/45

    http://www.sharepointlovers.com

    can be used for selected records using the where clause but with the truncatecommand we have to loose data.DELETE statement is a logged operation and hencetakes more time then truncate.

    2. What is Magic Table in SQL?Answer: The insert and Delete commands are known as magic tables in SQL.

    3. Can Primary key is a Foreign Key on the same table?Answer: Yes, Consider a category table in a e-commerce web site.Category_Id, Category_Name, Parent_Category_ID. In this table all the parentcategories are also categories. When we create a self join category id will be treatedas foreign key to the same table.

    4. What is Normalization?5. What are the advantages and disadvantages of Normalization?

    Answer: There are several advantages of normalization as under:

    Faster sorting and index creation.

    A larger number of clustered indexes.

    Narrower and more compact indexes.

    Fewer indexes per table, which improves the performance of INSERT,UPDATE, and DELETE statements

    Fewer null values and less opportunity for inconsistency, which increase

    database compactness.

    Beside the above benefits there are few disadvantages as well:

    Increased amount of Normalization increases the amount of complexityof joins between tables and that hinders the performance.

    6. What are the conditions to achieve the normalization?Answer: There are few conditions to achieve the normalization:

    There should be a unique row identifier.

    A table should store only data for a single type of entity. For e.g.details for books publisher and books author should be saved underdifferent table.

    A table should avoid columns which can be null-able.

    A table should avoid duplication of data and columns.

    7. What is a Stored Procedure? State its advantage.Answer: A stored procedure is a set of pre-compiled SQL commands (querystatements), which are stored in the server. It is faster then the loose SQL statementsprocessed on client, as it is pre-compiled. It can execute more then one SQLcommands once as they are bundled in a single entity. We can use control statementswithin the stored procedure, which will allow us to repeat some SQL command. Itcan send return values depending upon the result. Stored procedures are used toreduce network traffic.

    8. What is a Trigger?Answer: Triggers are a special type of stored procedure, which gets invoked upon acertain event. They can be performed upon an INSERT, UPDATE and DELETE.

    9. What is a Clustered Index?Answer: The data rows are stored in order based on the clustered index key. Data

    stored is in a sequence of the index.In a clustered index, the physical order of therows in the table is the same as the logical (indexed) order of the key values. A tablecan contain only one clustered index.A clustered index usually provides fasteraccess to data than does a non-clustered index

    10. What is a Non-Clustered Index?Answer: The data rows are not stored in any particular order, and there is noparticular order to the sequence of the data pages. In a clustered index, the physicalorder of the rows in the table is not same as the logical (indexed) order of the keyvalues.

    Page 24 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    25/45

    http://www.sharepointlovers.com

    11. Describe the three levels of data abstraction?The are three levels of abstraction:

    Physical level: The lowest level of abstraction describes how dataare stored.

    Logical level: The next higher level of abstraction, describes whatdata are stored in database and what relationship among those data.

    View level: The highest level of abstraction describes only part ofentire database

    12. What is DDL (Data Definition Language)?Answer: A data base schema which is specified by a set of definitions expressed by aspecial language is called DDL.Data Definition Language (DDL) is used to defineand manage all the objects in an SQL database.

    13. What is DML?Answer: It is a special language used to manipulate the Data. Data ManipulationLanguage (DML), which is used to select, insert, update, and delete data in theobjects defined using DDL.

    14. What is a PRIMARY KEY?Answer: The PRIMARY KEY is the column(s) used to uniquely identify each row ofa table.

    15. What is a FOREIGN KEY?Answer: A FOREIGN KEY is one or more columns whose values are based on thePRIMARY or CANDITATE KEY values from the database.

    16. What is a UNIQUE KEY?Answer: A UNIQUE KEY is one or more columns that must be unique for each rowof the table.

    17. What is the Diversities between UNIQUE and PRIMARY KEY?Answer: The UNIQUE KEY column restricts entry of duplicate values but entry ofNULL value is allowed. In case of PRIMARY KEY columns entry of duplicate aswell as value is also restricted.

    18. What is a VIEW?Answer: A View is a database object that is a logical representation of a table. It isderived from a table but has no storage space of its own and often may be used in thesame manner as a table.

    19. What is a ROWID?Answer: ROWID is the logical address of a row, and it is unique within the database.

    20. What is INDEX?Answer: INDEX is a general term for an SQL feature used primarily to speed upexecution and impose UNIQUENESS upon data.You can use an index to gain fastaccess to specific information in a database table. An index is a structure that ordersthe values of one or more columns in a database table.The index provides pointersto the data values stored in specified columns of the table, and then orders thosepointers according to the sort order you specify.

    21. What is a cursor?Answer: An entity that maps over a result set and establishes a position on a singlerow within the result set. After the cursor is positioned on a row, operations can beperformed on that row, or on a block of rows starting at that position. The most

    common operation is to fetch (retrieve) the current row or block of rows.22. The Diversities between 'Count' and 'Count (*)'?

    Answer: 'Count': Counts the number of non-null values. 'Count (*)': Counts thenumber of rows in the table, including null values and duplicates.

    23. Which are the default databases get installed with the MSSQL installation?Answer: Master, Model, msdb, Northwind, Pubs, tempdb.

    24. What is the purpose of using COLLATE in a query?25. What is the STUFF function and how does it differ from the REPLACE function?

    Answer: STUFF deletes a specified length of characters and inserts another set of

    Page 25 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    26/45

    http://www.sharepointlovers.com

    characters at a specified starting point. REPLACE removes the specified string andinserts supplied string in place.

    26. What does the parameter Initial Catalog define inside Connection String?Answer: The database name to connect to.

    27. Whats the data provider name to connect to Access database?Answer: Microsoft.Access.

    28. What does Dispose () method do with the connection object?Answer: Deletes it from the memory.

    29. What is a pre-requisite for connection pooling?Answer: Multiple processes must agree that they will share the same connection,where every parameter is the same, including the security settings.

    Glossary & Terms

    1. abstract method: A method that has no implementation; if a class has an abstractmethod, then the class is abstract as well.

    2. Abstraction: A process of retrieving information about an object.3. abstract class :A class that cant be instantiated and can only be derived from.4. Array: A collection of same-type variables or elements identified with an index.

    5. ArrayList: A dynamic array class:a. It has a default capacity of 16 objects.b. It automatically increases in size.c. It holds any type of object reference.When accessing the objects, they need to be cast to the appropriate type.

    6. Assembly: A repository (e.g., .dll or .exe) to store multiple and related codeconstructs or functionality.

    7. const: A static modifier used on local variables or member fields; once its value isassigned, it cant be changed at runtime.

    8. constructor: A special method that instantiates a class into an object.9. destructor: Method declaration to terminate an objecte.g., ~aClass(): used with

    Finalize().10. delegate: A class that is a reference to a method that has a given signature (parameter

    list and return type). This is also known as functional pointer.11. deserialize: A process to reconstruct from a binary stream back to a C# object.12. dictionary:Collection with a key and value association.13. Early Binding: Methodology whereby binding is determined as design time.14. enum: A value type that contains an enumerator list (a set of named numeric

    constants). Enumeration list of named constants: enum keyword or value type thatholds a quantity of named numeric constants (byte, sbyte, short, ushort, long, ulong,int, unit).

    15. extern: Modifies a method, indicating that unmanaged code is used to implement it.16. HashTable: Same as Dictionary that is tweaked for speedy retrieval.17. Generics: Methodologies that enable class, delegate, interface, struct types, and

    methods to be created with type parameters, which are placeholder types that canbe substituted when the type is known (C# 2.0 feature).

    18. Generic method: A method that accepts type parameters (C# 2.0 feature).19. immutable: Unchangeable: a string may appear to change, but a method merelyreturns a modified string object. (Strings are immutable, stringbuilder class ismutable.)

    20. inheritance: a methodology in which functionality is inherited (class and interfacetype).

    21. jagged array: A multidimensional array where the rows are of varying sizes: an arrayis comprised of elements that are themselves arrays. It is also known as Array ofArrays.

    22. linked list: A data structure that has a series of connected nodes.

    Page 26 of 45 http://www.techmachi.com

  • 7/31/2019 Advanced ASP.net Interview Questions Sharepointloversdotcom

    27/45

    http://www.sharepointlovers.com

    23. late binding: A methodology in which binding is determined at runtime.24. manifest: An assemblys contents; it is also referred to as assembly metadata.25. multidimensional array: An array with multiple dimensions (rows and columns). C#

    has two: jagged ([][])and rectangular([,]).26. new: A keyword that calls a classs constructor.27. operator overloading: A technique whereby an operator is overloaded to give a class

    the functionality of the operator.28. overloading: The ability to include more than one method in the same class with the

    same name.29. overriding: When a virtual method in a base class has its functionality superimposed

    or overridden by a method in a subclass, which has the same name and signature.30. polymorphism: Object-oriented concept whereby a specialized class may be passed

    as an instance of a generalized class (class polymorphism): also refers to methods ofa class (method polymorphism).

    31. passing by reference: Reference types are passed to a calling method by referenceareference to a memory location (the heap) is passed rather than a copy of the type(contrast passing by value).

    32. passing by value: Value types are passed to a calling method by way of a copy of theunderlying value typealtering the copy does not alter the underlying (original)value type. Passing by value occurs on the stack (contrast with passing by reference).

    33. readonly: Keyword used to declare that a class member variable is read-only andcant be edited at runtime.

    34. Rectangular array: A form of multidimensional array with two or more dimensionsthat has rows of the same length (contrast with jagged array).

    35. se