Dotnet Interview Questions.doc

Embed Size (px)

Citation preview

  • 8/13/2019 Dotnet Interview Questions.doc

    1/32

    .Net Interview Questions

    Diversities1. Whats the Diversities between Response.Write () and Response.Output.Write

    ()?

    Answer: Response.Outout.Write allows us to write the formatted out put.2. What is the Diversities between an abstract method & virtual method?

    Answer: An Abstract method does not provide an implementation and forces

    overriding to the deriving class (unless the deriving class also an abstract class!where as the virtual method has an implementation and leaves an option to overrideit in the deriving class. "hus #irtual method has an implementation $ provides thederived class with the option of overriding it. Abstract method does not provide animplementation $ forces the derived class to override the method.

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

    &tructures are value t'pe and lasses are reference t'pe.

    &tructures can not have contractors or destructors. lasses can have bothcontractors and destructors.

    &tructures do not support )nheritance! while lasses support )nheritance.*. What are the Diversities between const and readonl?

    Answer:

    A const can not be static! while readonl' can be static.

    A const need to be declared and initiali+ed at declaration onl'! while a readonl'can be initiali+ed at declaration or b' the code in the constructor.

    A const,s value is evaluated at design time! while a readonl',s value is evaluatedat runtime.

    -. Diversitiess between dataset.clone and dataset.copAnswer:dataset.clone copies ust the structure of dataset (including all the datatables!schemas! relations and constraints./ however it doesn,t cop' the data. On the otherhand dataset.cop'! copies both the dataset structure and the data.

    0. What is Diversities between !amespace and "ssembl?Answer: amespace is a logical designtime naming convenience! whereas anassembl' establishes the name scope for t'pes at run time.

    3. What is the Diversities between earl bindin# and late bindin#?Answer: alling a nonvirtual method! decided at a compile time is 4nown as earl'binding. alling a virtual method (5ure 5ol'morphism! decided at a runtime is4nown as late binding.

    &imple 6uestions1. What is 7R8

    Answer: 7R also 4nown as ommon 7anguage Run time provides a environmentin which program are e9ecuted! it activate obect! perform securit' chec4 on them!la' them out in the memor'! e9ecute them and garbage collect them.

    2. What is 7&8

    Answer: 7& also 4nown as ommon 7anguage &pecification defines the ruleswhich all language must support! in order to be a part of .et framewor4."heommon 7anguage &pecification is a set of constructs and constraints that serves asa guide for librar' writers and compiler writers. )t allows libraries to be full' usablefrom an' language supporting the 7&! and for those languages to integrate witheach other. "he ommon 7anguage &pecification is a subset of the common t'pes'stem. "he ommon 7anguage &pecification is also important to applicationdevelopers who are writing code that will be used b' other developers.

    %. Which class does the web page belong to in A&5.et8Answer: &'stem.Web.).5age

    Ratnabhumi Page 1 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    2/32

    .Net Interview Questions

    *. Which class deals wit the user,s locale information8Answer: &'stem.Web.).5age.ulture

    -. What is #iew&tate8Answer: #iew&tate is a .et mechanism to store the posted data among post bac4s.#iew&tate allows the state of obects to be stored in a hidden field on the page! savedon client side and transported bac4 to server whenever re;uired. )tems stored in a#iew&tate e9ist for the life of the current page! including the post bac4s on the samepage.

    0. What are the t'pes of comment in anage &tate in A&5.et8

    "here are several wa's to manage a state.

    #iew&tate

    6uer'&tring

    oo4ies

    &ession

    Application "ric4' 6uestions

    1. What,s the Diversities between odebehindGH>'ode.asp9.csH and&rcGH>'ode.asp9.csH8Answer: #isual &tudio uses the odebehind attribute to distinguish the page sourceor programming logic from the design. Also the src attribute will ma4e the pagecompile on ever' re;uest. "hat is the page will not be compiled in advance andstored in the bin as a dll instead it will be compiled at run time.

    2. &uppose 'ou want a certain A&5.I" function e9ecuted on >ouseOver over acertain button or te9tbo9. Where do 'ou add an event handler8Answer: Iver' web control has an abilit' to add the attributes on client side whichwill e9ecute on client side and run a client side script li4e a avascript function.

    btn&ubmit.Attributes.Add(Jon>ouseOverK!Ksomelientode(/K ==For on mouseover of a button"e9tLo91.Attributes.Add(JonFocusK!Jlear"e9t(/K ==For on focus of a te9t bo9

    %. I9plain what a diffgram is and a good use for one8Answer: "he DiffMram is one of the two @>7 formats that 'ou can use to renderData&et obect contents to @>7. For reading database data to an @>7 file to be sentto a Web &ervice.

    *. ame two properties common in ever' validation control8Answer: ontrol"o#alidate and "e9t propert'.

    Ratnabhumi Page 2 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    3/32

    .Net Interview Questions

    -. sing which validator 'ou can chec4 if 5assword and onfirm 5assword arematching8Answer: ompare#alidator ontrol

    0. What are the assembl' entr' points8 An Assembl' can have how man' entr' pointsat a time8Answer: An assembl' can have onl' one entr' point from Dll>ain! Win>ain or>ain.

    3. What does an assembl' contain8Answer:N >anifest "he metadata describing the information below.N Assembl' name Aids in versioning and visibilit' scope.N #ersion information "he version number is integrated into the assembl'sidentit'.N "'pes Loundaries and scopes of methods! classes! properties! events andattributes.N 7ocale )nformation describing language=culture.N r'ptographic ash 5ublic 4e' encoded hash acting as version=securit' chec4.N &ecurit' 5ermissions "he permissions within the assembl' determine thepermissions that can be granted for all aspects of the assembl' contents.

    B. ow man' catch statements can be associated with single tr' statement8

    Answer: "here can be a +ero or more catch statement for each tr' statement. &o it hasnot limit to the number of catch statement per tr' statement.

    C. Which namespaces are used for data access8

    &'stem.Data

    &'stem.Data.OleDL

    &'stem.Data.&67lient1E. What do 'ou mean b' bo9ing and unbo9ing8

    Answer: < provides us with #alue t'pes and Reference "'pes. #alue "'pes arestored on the stac4 and Reference t'pes are stored on the heap. "he conversion ofvalue t'pe to reference t'pe is 4nown as bo9ing and converting reference t'pe bac4to the value t'pe is 4nown as unbo9ing.e.g.int 9 G 1E/

    obect o G 9 / == )mplicit bo9ingobect o G (obect 9/ == I9plicit Lo9ing

    9 G o/ == )mplicit nLo9ing9 G (into/ == I9plicit nLo9ing

    11. What are the different methods available under s;lcommand class to access the data8

    I9ecuteReader P sed where one or more records are returned P &I7I"6uer'.

    I9ecuteon6uer' P sed where it affects a state of the table and no data isbeing ;ueried )&IR"! 5DA"I! DI7I"I! RIA"I and &I" ;ueries.

    I9ecute&calar P sed where it returns a single record(a single valuenormall' P &67 Functions li4e >)(! A@(

    12. What is sealed class8 What are its features8Answer: &ealed classes are those classes which can not be inherited and thus an'sealed class member can not be derived in an' other class. A sealed class cannot alsobe an abstract class.)n < structs are implicitl' sealed/ therefore! the' cannot be inherited.

    1%. Wh' main function is static8Answer: "o ensure there is onl' one entr' point to the application.

    1*. What is concurrenc'8 ow will 'ou avoid concurrenc' when dealing with dataset8(One user deleted one row after that another user through his dataset was tr'ing to

    Ratnabhumi Page 3 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    4/32

    .Net Interview Questions

    update same row. What will happen8 ow will 'ou avoid this problem8Answer:)f the row we want to update has alread' been updated b' another user! theDataAdapter throws a DLoncurrenc'I9ception. We can use the Row propert' ofthis e9ception to identif' the row that caused the problem. Finall'! to ensure that 'oualwa's have a set of fresh records inside 'our Data&et obect! 'ou can select theRefresh the Data&et advanced option in order to retrieve the records each time a newdatabase operation is performed:se optimistic concurrenc' P adds a WIRI condition to the )&IR"! 5DA"I!and DI7I"I statements generated automaticall' b' the wi+ard in order to guaranteeto users that the' are not going to change records that have been modified b' otherusers! otherwise the command will fail.

    1-. an multiple catch bloc4s be e9ecuted8Answer: o! once an e9ception fall under a catch bloc4 the control will never bepassed to ne9t catch bloc4 instead it will be passed to the finall' bloc4 (if an' or=andthe code ne9t to the finall' bloc4.

    10. ow do 'ou turn off coo4ies for one page in 'our site8Answer: se the oo4ie.Discard 5ropert' which Mets or sets the discard flag set b'the server. When true! thispropert' instructs the client application not to save the oo4ie on the user,s hard dis4when a session ends.

    13. What are the different modes for the sessionstates in the web.config file8Answer:Off )ndicates that session state is not enabled.)nproc )ndicates that session state is stored locall'.&tate&erver )ndicates that session state is stored on a remote server.&67&erver )ndicates that session state is stored on the &67 &erver.

    OO5&1. What are the OO5& concepts8

    Answer:1 Incapsulation: )t is the mechanism that binds together code and data inmanipulates! and 4eeps both safe from outside interference and misuse. )n short it

    isolates a particular code and data from all other codes and data. A welldefinedinterface controls the access to that particular code and data.2 )nheritance: )t is the process b' which one obect ac;uires the properties ofanother obect. "his supports the hierarchical classification. Without the use ofhierarchies! each obect would need to define all its characteristics e9plicitl'.owever! b' use of inheritance! an obect need onl' define those ;ualities that ma4eit uni;ue within its class. )t can inherit its general attributes from its parent. A newsubclass inherits all of the attributes of all of its ancestors.% 5ol'morphism: )t is a feature that allows one interface to be used for general classof actions. "he specific action is determined b' the e9act nature of the situation. )ngeneral pol'morphism means Hone interface! multiple methodsH/ this means that it ispossible to design a generic interface to a group of related activities. "his helpsreduce comple9it' b' allowing the same interface to be used to specif' a generalclass of action. )t is the compilers ob to select the specific action (that is! method asit applies to each situation.

    2. What is a class8Answer: lass is concrete representation of an entit'. )t represents a group of obects!which hold similar attributes and behavior.)t provides Abstraction andIncapsulations.

    %. What is an Obect8 What is Obect Oriented 5rogramming8Answer: Obect represents=resembles a 5h'sical=real entit'. An obect is simpl'something 'ou can give a name. Obect Oriented 5rogramming is a &t'le of

    Ratnabhumi Page 4 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    5/32

    .Net Interview Questions

    programming that represents a program as a s'stem of obects and enables codereuse.

    *. What is Incapsulation8Incapsulation is binding of attributes and behaviors. iding the actualimplementation and e9posing the functionalit' of an' obect. Incapsulation is thefirst step towards OO5&! is the procedure of covering up of dataand functions into asingle unit (called class. )ts main aim is to protect the data from out side world.

    -. What is Abstraction8Answer: iding the comple9it'. )t is a process of defining communication interfacefor the functionalit' and hiding rest of the things.

    0. What is Overloading8Answer: Adding a new method with the same name in same=derived class but withdifferent number=t'pes of parameters. )t implements 5ol'morphism.

    3. What is Overloading8Answer: A process of creating different implementation of a method having a samename as base class! in a derived class. )t implements )nheritance.

    B. What is &hadowing8Answer: When the method is defined as Final=sealed in base class and not overrideable and we need to provide different implementation for the same. "his process is4nown as shadowing! uses shadows=new 4e'word.

    C. What is )nheritance8Answer: )t is a process of ac;uiring attributes and behaviors from another obect(normall' a class or interface.

    1E. What is an Abstract class8Answer: An abstract class is a special 4ind of class that cannot be instantiated. )tnormall' contains one or more abstract methods or abstract properties. )t providesbod' to a class.

    11. What is an )nterface8Answer: An interface has no implementation/ it onl' has the signature or in otherwords! ust the definition of the methods without the bod'.

    12. What is 5ol'morphism8Answer: >ean b' more than one form. Abilit' to provide different implementationbased on different number=t'pe of parameters.

    1%. What is 5ure5ol'morphism8Answer: When a method is declared as abstract=virtual method in a base class andwhich is overridden in a base class. )f we create a variable of a t'pe of a base classand assign an obect of a derived class to it! it will be decided at a run time! whichimplementation of a method is to be called."his is 4nown as 5ure5ol'morphism or 7ateLinding.

    1*. What is a onstructor8Answer: A special >ethod Alwa's called whenever an instance of the class iscreated.

    1-. What is a Destructor8Answer: A special method called b' M. Qust before obect is being reclaimed b'M.

    10. ow a base class method is hidden8

    Answer: iding a base class method b' declaring a method in derived class with4e'word new. "his will override the base class method and old method will besuppressed.

    13. What ommand is used to implement properties in

  • 8/13/2019 Dotnet Interview Questions.doc

    6/32

    .Net Interview Questions

    2E. What are &tatic Assembl' and D'namic Assembl'8Answer: &tatic assemblies can include .I" Framewor4 t'pes (interfaces andclasses as well as resources for the assembl' (bitmaps! Q5IM files! resource files!and so forth. &tatic assemblies are stored on dis4. D'namic assemblies run directl'from memor' and are not saved to dis4 before e9ecution.

    21. Describe the functionalit' of an assembl'.Answer: )t is the smallest unit that has version control. All t'pes and resources in thesame assembl' are versioned as a unit and support side b' side e9ecution.Assemblies contain the metadata and other identities which allow the commonlanguage runtime to e9ecute. "he' are the boundaries providing the t'pe chec4. "he'the unit where securit' permissions are re;uested and granted.

    22. What is seriali+ation8Answer: &eriali+ation is the process of converting an obect into a stream of b'tes.Deseriali+ation is the opposite process of creating an obect from a stream of b'tes.&eriali+ation=Deseriali+ation is mostl' used to transport obects (e.g. duringremoting! or to persist obects (e.g. to a file or database. "here are two separatemechanisms provided b' the .I" class librar' for seriali+ation @ml&eriali+er and&oapFormatter and Linar'Formatter. >icrosoft uses @ml&eriali+er for Web&ervices! and uses &oapFormatter=Linar'Formatter for remoting.

    2%. What is a static class8

    Answer: When a class has been defined as static! it is not creatable using the new4e'word! and it can contain onl' static members or fields.

    2*. What is static member8Answer: "he member defined as static which can be invo4ed directl' from the classlevel! rather than from its instance.

    2-. What is static function=method8Answer:&tatic methods need not need to create an instance of the class containing itand can be accessed directl' from class level.

    20. What is static constructor8 ("his is introduced in #& 2EE-Answer: When constructors are used to set the value of a t'pe,s data at the time ofconstruction! if we want the value of such static data is to be preserved regardless ofhow man' obects of the t'pe are created! we have to define the constructor withstatic 4e'word.

    23. Wh' >ain ( method is static8Answer:"o ensure there is onl' one entr' point to the application.

    2B. What is Reflection8Answer: Reflection is the process of runtime t'pe discover'.

    2C. What do 'ou mean b' &eriali+e8Answer: "he term seriali+ation describes the process of persisting (and possibl'transferring the state of an obect to a stream.

    %E. What is an As'nchronous delegate8 (#& 2EE-Answer: When 'ou invo4e a delegate as'nchronousl'! no new thread is created.)nstead! the 7R automaticall' assigns a free thread from a small thread pool that itmaintains. "'picall'! this thread pool starts with one thread and increases to ama9imum of about 2- free threads on a single5 computer. As a result! if 'oustart -E as'nchronous operations! one after the other! the first 2- will complete first.

    As soon as one ends! the freed thread is used to e9ecute the ne9t as'nchronousoperation.

    %1. ow to create events for a control8 What are custom events8Answer:Declare a public delegate and set of events to listen from.public delegate void arIventandler(string msg/public event arIventandler About"oLlow/public event arIventandler Llewp/

    %2. What,s the advantage of using &'stem."e9t.&tringLuilder over &'stem.&tring8Answer: &tringLuilder is more efficient in the cases! where a lot of manipulation is

    Ratnabhumi Page of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    7/32

    .Net Interview Questions

    done to the te9t. &trings are immutable! so each time it,s being operated on! a newinstance is created.

    %%. an 'ou store multiple data t'pes in &'stem.Arra'8Answer: o.

    %*. What,s the Diversities between the &'stem.Arra'.op'"o( and&'stem.Arra'.lone(8Answer: &'stem.Arra'.op'"o( performs a deep cop' while &'stem.Arra'.lone(performs a shallow cop'.

    %-. ow can 'ou sort the elements of the arra' in descending order8Answer: First use &ort ( method to sort the arra' and then call Reverse ( method toarrange arra' elements in descending order.

    %0. What,s the .I" datat'pe that allows the retrieval of data b' a uni;ue 4e'8Answer: A ash"able.

    %3. What,s class &orted7ist underneath8Answer: A sorted ash"able.

    %B. Will finall' bloc4 get e9ecuted if the e9ception had not occurred8Answer: es.

    %C. When 'ou inherit a protected classlevel variable! who is it available to8Answer: lasses in the same namespace.

    *E. Are private classlevel variables inherited8

    Answer: es! but the' are not accessible! so loo4ing at it 'ou can honestl' sa' thatthe' are not inherited. Lut the' are.

    *1. Describe the accessibilit' modifier protected internal.Answer: )t,s available to derived classes and classes within the same Assembl' (andnaturall' from the base class it,s declared in.

    *2. ow,s method overriding different from overloading8Answer: When overriding! 'ou change the method behavior for a derived class.Overloading simpl' involves having a method with the same name within the class.

    *%. What does the 4e'word virtual mean in the method definition8Answer: "he method can be overridden.

    **. an 'ou declare the override method static while the original method is nonstatic8Answer: o! 'ou can,t! the signature of the virtual method must remain the same!onl' the 4e'word virtual is changed to 4e'word override.

    *-. an 'ou override private virtual methods8Answer: o! moreover! 'ou cannot access private methods in inherited classes! haveto be protected in the base class to allow an' sort of access.

    *0. an 'ou prevent 'our class from being inherited and becoming a base class for someother classes8Answer: es! that,s what 4e'word sealed in the class definition is for. "he developertr'ing to derive from 'our class will get a message: cannot inherit from &ealed classWhateverLaselassame. )t,s the same concept as final class in Qava.

    *3. an 'ou allow class to be inherited! but prevent the method from being overridden8Answer: es! ust leave the class public and ma4e the method sealed.

    *B. When do 'ou absolutel' have to declare a class as abstract8Answer: 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 been

    overridden.*C. an we declare private methods inside an )nterface8 Wh' can,t 'ou specif' the

    accessibilit' modifier for methods inside the interface8o! the' all must be public. "herefore! to prevent 'ou from getting the falseimpression that 'ou have an' freedom of choice! 'ou are not allowed to specif' an'accessibilit'! its public b' default.

    -E. What,s the Diversities between an interface and abstract class8Answer: )n the interface all methods must be abstract/ in the abstract class somemethods can be concrete. )n the interface no accessibilit' modifiers are allowed!which is o4 in abstract classes.

    Ratnabhumi Page ! of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    8/32

    .Net Interview Questions

    -1. )f a base class has a bunch of overloaded constructors! and an inherited class hasanother bunch of overloaded constructors! can 'ou enforce a call from an inheritedconstructor to an arbitrar' base constructor8Answer: es! ust place a colon! and then 4e'word base (parameter list to invo4e theappropriate constructor in the overloaded constructor definition inside the inheritedclass.

    -2. What,s the Diversities between &'stem.&tring and &'stem.&tringLuilder classes8Answer: &'stem.&tring is immutable/ &'stem.&tringLuilder was designed with thepurpose of having a mutable string where a variet' of operations can be performed.

    -%. ow do 'ou initiate a string without escaping each bac4slash8Answer: 5ut S sign in front of the double;uoted string.e.g. SJ:TDocuments and &ettingsTAdministratorT>' DocumentsK/ is e;uivalent toJ:TTDocuments and &ettingsTTAdministratorTT>' DocumentsK.

    -*. What are valid signatures for the >ain function8Answer:public static void >ain(public static int >ain(public static void >ain( stringUV args public static int >ain(stringUV args

    --. I9plain encapsulation.

    Answer: "he implementation is hidden! the interface is e9posed.-0. Where all the valuet'pe variables allocated in the computer RA>8

    Answer: &tac4-3. Where do the referencet'pe variables go in the RA>8

    Answer: "he references go on the stac4! while the obects themselves go on the heap.-B. What is the Diversities between the valuet'pe variables and referencet'pe variables

    in terms of garbage collection8Answer: "he valuet'pe variables are not garbagecollected! the' ust fall off thestac4 when the' fall out of scope! the referencet'pe obects are pic4ed up b' Mwhen their references go null.

    -C. ow do 'ou convert a string into an integer in .I"8Answer: )nt%2.5arse(string! onvert."o)nt%2(

    0E. ow do 'ou enforce garbage collection in .I"8

    Answer: &'stem.M.ollect(/01. an 'ou declare a t'pe destructor in < li4e X>'lass(8

    Answer: es! but what,s the point! since it will call Finali+e (! and Finali+e ( has noguarantees when the memor' will be cleaned up! plus! it introduces additional loadon the garbage collector. "he onl' time the finali+er should be implemented! is when'ou,re dealing with unmanaged code.

    02. What,s the Diversities between const and readonl'8Answer: ou can initiali+e readonl' variables to some runtime values. 7et,s sa' 'ourprogram uses current date and time as one of the values that won,t change. "his wa''ou declarepublic readonl' string Date" G new Date"ime(."o&tring(/"his is not possible with a constant.

    0%. What happens when 'ou encounter a continue statement inside the Yfor loop,8

    Answer: "he code for the rest of the loop is ignored/ the control is transferred bac4to the beginning of the loop.

    0*. Describe the compilation process for .I" code8Answer: &ource code is compiled and run in the .I" Framewor4 using a twostageprocess. First! source code is compiled to >icrosoft intermediate language (>&)7code using a .I" Framewor4compatible compiler! such as that for #isual Lasic.I" or #isual &)7 code is compiled to native code.

    0-. )n which cases 'ou use override and new base8Answer: se the new modifier to e9plicitl' hide a member inherited from a base

    Ratnabhumi Page " of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    9/32

    .Net Interview Questions

    class. "o hide an inherited member! declare it in the derived class using the samename! and modif' it with the new modifier.

    00. )n which &cenario 'ou will go for )nterface or Abstract lass8Answer: )nterfaces! li4e classes! define a set of properties! methods! and events. Lutunli4e classes! interfaces do not provide implementation. "he' are implemented b'classes! and defined as separate entities from classes. Iven though class inheritanceallows 'our classes to inherit implementation from a base class! it also forces 'ou toma4e most of 'our design decisions when the class is first published.Abstract classes are useful when creating components because the' allow 'ouspecif' an invariant level of functionalit' in some methods! but leave theimplementation of other methods until a specific implementation of that class isneeded. "he' also version well! because if additional functionalit' is needed inderived classes! it can be added to the base class without brea4ing code.

    03. What are the accessspecifiers available in ca4e a constructor private if: ou want it to be available onl' to the class itself. For e9ample! 'ou might have aspecial constructor used onl' in the implementation of 'our class lone method. ou do not want instances of 'our component to be created. For e9ample! 'ou ma'have a class containing nothing but &hared utilit' functions! and no instance data.reating instances of the class would waste memor'.

    31. ) have % overloaded constructors in m' class. )n order to avoid ma4ing instance ofthe class do ) need to ma4e all constructors to private8

    Answer: es32. Overloaded constructor will call default constructor internall'8

    Answer: o

    &67: 6ueries1. Write a ;uer' to select the second highest salar' from a table.

    Answer: &I7I" ma9(salar' A& salar'2 FRO> orders WIRI salar' Z(&I7I" ma9(salar' A& salar'1 FRO> orders

    Ratnabhumi Page # of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    10/32

    .Net Interview Questions

    2. Write a ;uer' to select the -thhighest salar' from a table.Answer:&I7I" min(salar' A& high- FRO> emplo'ee WIRI salar')(&I7I" D)&")" "O5 - salar' FRO> orders ORDIR L salar' DI&

    %. ow to find duplicate records with the number the' are duplicated8Answer: &I7I" )d! count (? as number[records from table group b' id havingcount (? \ 1.

    *. sing ;uer' anal'+er! name % wa's 'ou can get an accurate count of the number ofrecords in a table.Answer:a. select count (coumname(s from tableame.b. select count[big(coumname(s from tableamec. select columname from ableame select SSROWO" as rowount

    &67: 6uestions1. What is the Diversities between Delete and "runcate command in &678

    Answer: Delete command and truncate command both will delete the data! howeverthe truncate command can not be rolled bac4 as delete can be. "he delete command

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

    2. What is >agic "able in &678Answer: "he insert and Delete commands are 4nown as magic tables in &67.

    %. an 5rimar' 4e' is a Foreign ]e' on the same table8Answer: es! onsider a categor' table in a ecommerce web site.ategor'[)d! ategor'[ame! 5arent[ategor'[)D. )n this table all the parentcategories are also categories. When we create a self oin categor' id will be treatedas foreign 4e' to the same table.

    *. What is ormali+ation8-. What are the advantages and disadvantages of ormali+ation8

    Answer: "here are several advantages of normali+ation as under:

    Faster sorting and inde9 creation. A larger number of clustered inde9es.

    arrower and more compact inde9es.

    Fewer inde9es per table! which improves the performance of )&IR"!5DA"I! and DI7I"I statements

    Fewer null values and less opportunit' for inconsistenc'! which increasedatabase compactness.

    Leside the above benefits there are few disadvantages as well:

    )ncreased amount of ormali+ation increases the amount of comple9it'of oins between tables and that hinders the performance.

    0. What are the conditions to achieve the normali+ation8Answer: "here are few conditions to achieve the normali+ation:

    "here should be a uni;ue row identifier. A table should store onl' data for a single t'pe of entit'. For e.g. details

    for boo4,s publisher and boo4,s author should be saved under differenttable.

    A table should avoid columns which can be nullable.

    A table should avoid duplication of data and columns.3. What is a &tored 5rocedure8 &tate its advantage.

    Answer: A stored procedure is a set of precompiled &67 commands (;uer'statements! which are stored in the server. )t is faster then the loose &67 statements

    Ratnabhumi Page 1$ of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    11/32

    .Net Interview Questions

    processed on client! as it is precompiled. )t can e9ecute more then one &67commands once as the' are bundled in a single entit'. We can use control statementswithin the stored procedure! which will allow us to repeat some &67 command. )tcan send return values depending upon the result. &tored procedures are used toreduce networ4 traffic.

    B. What is a "rigger8Answer: "riggers are a special t'pe of stored procedure! which gets invo4ed upon acertain event. "he' can be performed upon an )&IR"! 5DA"I and DI7I"I.

    C. What is a lustered )nde98Answer: "he data rows are stored in order based on the clustered inde9 4e'. Datastored is in a se;uence of the inde9.)n a clustered inde9! the ph'sical order of therows in the table is the same as the logical (inde9ed order of the 4e' values. A tablecan contain onl' one clustered inde9.A clustered inde9 usuall' provides fasteraccess to data than does a nonclustered inde9

    1E. What is a onlustered )nde98Answer: "he data rows are not stored in an' particular order! and there is noparticular order to the se;uence of the data pages. )n a clustered inde9! the ph'sicalorder of the rows in the table is not same as the logical (inde9ed order of the 4e'values.

    11. Describe the three levels of data abstraction8

    "he are three levels of abstraction:

    5h'sical level: "he lowest level of abstraction describes how dataare stored.

    7ogical level: "he ne9t higher level of abstraction! describes whatdata are stored in database and what relationship among those data.

    #iew level: "he highest level of abstraction describes onl' part ofentire database

    12. What is DD7 (Data Definition 7anguage8Answer: A data base schema which is specified b' a set of definitions e9pressed b' aspecial language is called DD7.Data Definition 7anguage (DD7 is used to defineand manage all the obects in an &67 database.

    1%. What is D>78Answer: )t is a special language used to manipulate the Data. Data >anipulation

    7anguage (D>7! which is used to select! insert! update! and delete data in theobects defined using DD7.

    1*. What is a 5R)>AR ]I8Answer: "he 5R)>AR ]I is the column(s used to uni;uel' identif' each row ofa table.

    1-. What is a FORI)M ]I8Answer: A FORI)M ]I is one or more columns whose values are based on the5R)>AR or AD)"A"I ]I values from the database.

    10. What is a )6I ]I8Answer: A )6I ]I is one or more columns that must be uni;ue for each rowof the table.

    13. What is the Diversities between )6I and 5R)>AR ]I8Answer: "he )6I ]I column restricts entr' of duplicate values but entr' of

    77 value is allowed. )n case of 5R)>AR ]I columns entr' of duplicate aswell as Z77\ value is also restricted.

    1B. What is a #)IW8Answer: A #iew is a database obect that is a logical representation of a table. )t isderived from a table but has no storage space of its own and often ma' be used in thesame manner as a table.

    1C. What is a ROW)D8Answer: ROW)D is the logical address of a row! and it is uni;ue within the database.

    Ratnabhumi Page 11 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    12/32

    .Net Interview Questions

    2E. What is )DI@8Answer: )DI@ is a general term for an &67 feature used primaril' to speed upe9ecution and impose )6II&& upon data.ou can use an inde9 to gain fastaccess to specific information in a database table. An inde9 is a structure that ordersthe values of one or more columns in a database table."he inde9 provides pointersto the data values stored in specified columns of the table! and then orders thosepointers according to the sort order 'ou specif'.

    21. What is a cursor8Answer: An entit' 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 bloc4 of rows starting at that position. "he mostcommon operation is to fetch (retrieve the current row or bloc4 of rows.

    22. "he Diversities between ount and ount (?8Answer: ount: ounts the number of nonnull values. ount (?: ounts thenumber of rows in the table! including null values and duplicates.

    2%. Which are the default databases get installed with the >&&67 installation8Answer: >aster! >odel! msdb! orthwind! 5ubs! tempdb.

    2*. What is the purpose of using O77A"I in a ;uer'82-. What is the &"FF function and how does it differ from the RI57AI function8

    Answer: &"FF deletes a specified length of characters and inserts another set of

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

    20. What does the parameter )nitial atalog define inside onnection &tring8Answer: "he database name to connect to.

    23. What,s the data provider name to connect to Access database8Answer: >icrosoft.Access.

    2B. What does Dispose ( method do with the connection obect8Answer: Deletes it from the memor'.

    2C. What is a prere;uisite for connection pooling8Answer: >ultiple processes must agree that the' will share the same connection!where ever' parameter is the same! including the securit' settings.

    Mlossar' $ "erms

    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 obect.%. abstract class :A class that can,t be instantiated and can onl' be derived from.*. Arra': A collection of samet'pe variables or elements identified with an inde9.-. Arra'7ist: A d'namic arra' class:

    a. )t has a default capacit' of 10 obects.b. )t automaticall' increases in si+e.c. )t holds an' t'pe of obect reference.When accessing the obects! the' need to be cast to the appropriate t'pe.

    0. Assembl': A repositor' (e.g.! .dll or .e9e to store multiple and related code

    constructs or functionalit'.3. const: A static modifier used on local variables or member fields/ once its value isassigned! it can,t be changed at runtime.

    B. constructor: A special method that instantiates a class into an obect.C. destructor: >ethod declaration to terminate an obect^e.g.! Xalass(: used with

    Finali+e(.1E. delegate: A class that is a reference to a method that has a given signature (parameter

    list and return t'pe. "his is also 4nown as functional pointer.11. deseriali+e: A process to reconstruct from a binar' stream bac4 to a < obect.12. dictionar':ollection with a 4e' and value association.

    Ratnabhumi Page 12 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    13/32

    .Net Interview Questions

    1%. Iarl' Linding: >ethodolog' whereb' binding is determined as design time.1*. enum: A value t'pe that contains an enumerator list (a set of named numeric

    constants. Inumeration list of named constants: enum 4e'word or value t'pe thatholds a ;uantit' of named numeric constants (b'te! sb'te! short! ushort! long! ulong!int! unit.

    1-. e9tern: >odifies a method! indicating that unmanaged code is used to implement it.10. ash"able: &ame as Dictionar' that is twea4ed for speed' retrieval.13. Menerics: >ethodologies that enable class! delegate! interface! struct t'pes! and

    methods to be created with t'pe parameters! which are JplaceholderK t'pes that canbe substituted when the t'pe is 4nown (< 2.E feature.

    1B. Meneric method: A method that accepts t'pe parameters (< 2.E feature.1C. immutable: nchangeable: a string ma' appear to change! but a method merel'

    returns a modified string obect. (&trings are immutable! stringbuilder class ismutable.

    2E. inheritance: a methodolog' in which functionalit' is inherited (class and interfacet'pe.

    21. agged arra': A multidimensional arra' where the rows are of var'ing si+es: an arra'is comprised of elements that are themselves arra's. )t is also 4nown as Arra' ofArra's.

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

    2%. late binding: A methodolog' in which binding is determined at runtime.2*. manifest: An assembl',s contents/ it is also referred to as assembl' metadata.2-. multidimensional arra': An arra' with multiple dimensions (rows and columns. 7 schema: faster and moreefficient than unt'ped dataset because the schema is defined and does not re;uireruntime t'pe identification when run.

    %C. value t'pe: Data that is stored in a variable: value t'pes are stored with their contentson the stac4. onsists of structures! primitives! and enumerations.

    Ratnabhumi Page 13 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    14/32

    .Net Interview Questions

    Write ode For1. Write a program in < to find the angle between the hours and minutes in a cloc48

    "esting 6uestions1. What debugging tools come with the .I" &D]8

    1. orDLM P commandline debugger. "o use orDbg! 'ou must compile the

    original < file using the =debug switch.2. Dbg7R P graphic debugger. #isual &tudio .I" uses the Dbg7R.

    2. What does assert ( method do8)n debug compilation! assert ta4es in a Loolean condition as a parameter! and showsthe error dialog if the condition is false. "he program proceeds without an'interruption if the condition is true.

    %. What,s the Diversities between the Debug class and "race class8Documentation loo4s the same. se Debug class for debug builds! use "race classfor both debug and release builds.

    *. Wh' are there five tracing levels in &'stem.Diagnostics."race&witcher8"he tracing dumps can be ;uite verbose. For applications that are constantl' running'ou run the ris4 of overloading the machine and the hard drive. Five levels rangefrom one to #erbose! allowing 'ou to finetune the tracing activities.

    -. Where is the output of "e9tWriter"race7istener redirected8"o the onsole or a te9t file depending on the parameter passed to the constructor.

    0. ow do 'ou debug an A&5.I" Web application8Attach the aspnet[wp.e9e process to the Dbglr debugger.

    3. What are three test cases 'ou should go through in unit testing81. 5ositive test cases (correct data! correct output.2. egative test cases (bro4en or missing data! proper handling.%. I9ception test cases (e9ceptions are thrown and caught properl'.

    B. an 'ou change the value of a variable while debugging a < application8 es. )f'ou are debugging via #isual &tudio.I"! ust go to J)mmediate windowK.

    Lasic Design 5attern 6uestions1. I9plain the three services model (threetier application.

    Answer: 5resentation ()! business (logic and underl'ing code and data (fromstorage or other sources.

    2. I9plain A)D rule of thumb for transactions.Answer: "ransaction must be _Atomic (it is one unit of wor4 and does not dependent on previous and followingtransactions!onsistent (data is either committed or roll bac4! no JinbetweenK case wheresomething has been updated and something hasn,t!)solated (no transaction sees the intermediate results of the current transaction!Durable (the values persist if the data had been committed even if the s'stem crashesright after.

    6uestions with answer options &tate "rue or False: )f 'ou set AutoMenerateolumnsG"rue and still provide custom

    column definitions! the DataMrid will render botho "rue

    o False

    "he data from an @&7 "ransform with @mlReader can be returned in one of the

    following wa's

    Ratnabhumi Page 14 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    15/32

    .Net Interview Questions

    o obReader G ob@sl"."ransform(obav! nothing

    o ob@sl"."ransform(obav! nothing

    o obReader G ob@sl"."ransform(obav! nothing! obWriter

    o ob@sl"."ransform(obav! nothing! obWriter

    5ic4 the command line that would result in the < compiler generating an @>7

    documentation file

    o csc =doc:ewome.9ml ewome.cso c =doc =docfile: ewome.9ml ewome.cs

    o csc =doc =out: ewome.9ml ewome.cs

    o csc =9ml ewome.cs

    What is the comment s'nta9 for 7based documentation8

    o =?? and ??=

    o ==ain(stringUV args

    &'stem.onsole.Write7ine(argsU1V/

    Ratnabhumi Page 1 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    17/32

    .Net Interview Questions

    ==end >ain==end class testlasso ompiler Irror

    o Runtime Irror

    o ello < world

    o one of the above

    What will be the values of 9 and '8int 9 G -/ int ' G 1E/' G 9/&'stem.onsole.Write7ine(H9:H 9.to&tring( H ':H '.to&tring(/

    o 9: 0 ': 10

    o 9: 0 ': 1-

    o 9: 1E ': 1-

    o 9: 1E ': 20

    One of the possible wa' of writing an A&5.I" handler that wor4s li4e an )&A5)

    filter that is! that sees re;uests and responses and modifies them also! is b'!o writing a module that e9tends FormsAuthenticaton>odule and using it

    o writing a component class that e9tends ttp>oduleollection and using ito writing an ""5 modulea lass that implements )http>odule and

    registering it in Web.onfig

    o All of the above

    "he A&5.I" directive that lets 'ou cache different versions of a page based on

    var'ing input parameters! ""5 headers and browser t'pe iso SOutputache

    o SacheOutput

    o S5ageache

    o SacheAll

    )f we develop an application that must accommodate multiple securit' levels through

    secure login and A&5.I" web application is spanned across three webservers

    (using roundrobin load balancing what would be the best approach to maintainloginin state for the users8

    o ZSession&tate modeGH)n5rocHstateonnection&tringGH

    tcpipG123.E.E.1:*2*2*H s;lonnection&tringGH data sourceG123.E.E.1/useridGsa/passwordGHcoo4ielessGHfalseH timeoutGH%EH =\

    o ZSession&tate modeGHOut5rocH

    stateonnection&tringGHtcpipG123.E.E.1:*2*2*H s;lonnection&tringGHdatasourceG123.E.E.1/user idGsa/passwordGH coo4ielessGHfalseHtimeoutGH%EH =\

    o ZSession&tate modeGHstateserverH

    stateonnection&tringGHtcpipG123.E.E.1:*2*2*H s;lonnection&tringGHdatasourceG123.E.E.1/user idGsa/passwordGH coo4ielessGHfalseHtimeoutGH%EH =\

    What is the output for the below mentioned compilation command\csc =addmodule:A.I9e L.s

    o A.e9e

    o L.e9e

    o A.dll

    o L.dll

    ow can be the web application get configured with the following authori+ation

    ruleso Anon'mous users must not be allowed to access the application.

    Ratnabhumi Page 1! of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    18/32

    .Net Interview Questions

    o All persons e9cept David and Qohn must be allowed to access the

    application.

    Zauthori+ation\Zden' users G HapplicationnameTDavid!applicationnameTQohnH \Zallow roles GH?H\Zden' roles GH8H\Z=authori+ation\

    Zauthori+ation\Zallow users GH?H\Zden' users G

    HapplicationnameTDavid/ applicationnameTQohnH \Zden' users GH?H\Z=authori+ation\

    Zauthori+ation\Zden' users G HapplicationnameTDavid!applicationnameTQohnH \Zden' users G H8H\Zallow usersGH?H\Z=authori+ation\

    Zauthori+ation\Zallow users GH?H\Zden' users GHapplicationnameTDavid! applicationnameTQohnH \Z=authori+ation\

    What will be the output of the following code snippet8

    using &'stem/class >ainlass

    static void >ain(

    new >ainlass(.Displa'( %.-0 /

    private void Displa'( float anArg

    onsole.Write( JE 1K! anArg.Met"'pe(! anArg /

    double Displa'( double anArg

    onsole.Write( JE 1K! anArg.Met"'pe(! anArg /return anArg/

    public decimal Displa'( decimal anArg

    onsole.Write( JE 1K! anArg.Met"'pe(! anArg / returnanArg/

    o &'stem.&ingle %.-0

    o &'stem.Float %.-0

    o &'stem.Double %.-0

    o &'stem.Decimal %.-0

    What will be output for the given code8

    Dim ) as integer G -Do

    ) G ) 2Response.Write () $ H H

    7oop ntil ) \ 1Eo - B

    o - 3 C

    Ratnabhumi Page 1" of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    19/32

    .Net Interview Questions

    o 3 C 11

    o Irrors out

    A structure in < can be derived from one or more

    o class

    o interface

    o both

    o none &tate "rue or False: &tatic method cannot be overridden

    o "rue

    o False

    "he I;uivalent ">7 ontrol for the Zinput t'peGKbuttonK\ tag is

    o tml)nput

    o tmlLutton

    o tml5ushLutton

    o tml)nputLutton

    "he I;uivalent tml ontrol for the Zinput t'peGKchec4bo9K\ tag is

    o tmlhec4Lo9

    o tml)nputh4Lo9

    o tml)nputhec4Lo9o tml)nput"'peh4Lo9

    Which operator is used for connecting a event with a procedure in

  • 8/13/2019 Dotnet Interview Questions.doc

    20/32

    .Net Interview Questions

    o L' having the same method name and specif'ing different number of

    parameterso L' giving different method names and same number of parameters

    o L' having the same method name and specif'ing different t'pes of

    parameterso L' giving different method names and same t'pes of parameters

    "he Range#alidator control supports the following datat'peo )nteger and &tring

    o )nteger! Float! &tring! @>7Datat'pes

    o )nteger! &tring and Date

    o )nteger! Loolean! &hort! &tring and Date

    What is the Diversities between onvert."o)nt%2 and int.5arse8

    o Loth are same and both can handle null value.

    o onvert."o)nt%2 can handle null value but int.5arse throws

    ArgumentullI9ception error.o int.5arse can handle null value but onvert."o)nt%2 throws

    ArgumentullI9ception error.o Loth onvert."o)nt%2 and int.5arse cannot handle null value.

    &tate "rue or False: An' ODLcompliant database can be accessed through

    A&5.I"o "rue

    o False

    ou need to select a .I" language that has autodocumenting features built into the

    source code and compiler. Miven the scenario above what language compiler shouldbe selected8

    o vbc.e9e

    o cl.e9e

    o ilasm.e9e

    o cs.e9e

    A set of tables are maintained in a Dataset as

    o "ablesollection obect

    o Data"ableollection obecto DataRowsollection obect

    o "ableRowollection obect

    "he namespaces needed to use data mechanisms in A&5.I" pages are

    o Sstem.Data! Sstem.Data.OleDb or Sstem.Data.&67

    o Sstem.Data! Sstem.Data.ODL

    o Sstem.Data! Sstem.Data.DataRow

    o Sstem.Data.DataRowollection! Sstem.Data.Db"'pe

    What are the different methods to access Database in .I" 8

    o OleDL!ODL!&67lient

    o OleDL! QDL! &67&erver

    o ODLQDL! Data&et! &67lient

    o Datasource! Data&et! D& "he two properties of a DataMrid that has to be specified to turn on sorting and

    paging respectivel' are

    o Inable&orting G JtrueK and Inable5aging G JtrueK

    o Disable&orting G JfalseK and Disable5aging G JfalseK

    o Allow&orting G JtrueK and Allow5aging G JtrueK

    o &orting G JtrueK and 5aging G JtrueK

    Which one of the following obects is used to create a foreign 4e' between two

    Data"ables8

    Ratnabhumi Page 2$ of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    21/32

    .Net Interview Questions

    o DataRelation

    o DataRelationship

    o Dataonstraint

    o Data]e'

    "he &'nta9 for databinding e9pressions is

    o Z`< propert' or collection `\

    o Z`< propert' or collection

  • 8/13/2019 Dotnet Interview Questions.doc

    22/32

    .Net Interview Questions

    &tate "rue or False: A single .I" dll can contain unlimited classes

    o "rue

    o False

    &tate "rue or False: A&5.I" can currentl' run onl' on Windows 5latform

    o "rue

    o False

    Which one of the following best describes J"'pe&afeKo )t ensures that the data t'pe are safel' handled

    o )t ensures that t'pes are not mismatched when the' are called so uses a

    t'pecasting before referencing an' data obecto )t ensures that an obect onl' references memor' locations that it,s allowed

    to! preventing data corruption and the accidental misuse of obect t'peso All of the above

    "he number of obects in A&5.I" is

    o 0

    o 3

    o C

    o 1E

    "he code used to turn off buffering iso Luffering G false

    o OutputLuffer G false

    o LufferOutput G false

    o Luffer G Off

    an 'ou have two applications on the same machine one which is using .I"

    Framewor4 1.1 and the other using 2.E 8o es

    o o

    o Depends on Sstemconfiguration

    Which of the following DO".I" tools manages certificates! certificate trust lists

    ("7s! and certificate revocation lists (R7s8o sn.e9e

    o certnet.e9e

    o certmgr.e9e

    o gacutil.e9e

    ou need to generate a public=private 4e' pair for using in creating a shared

    assembl'. Miven the above scenario! which .I" &D] utilit' should be used8o certmgr.e9e

    o gacutil.e9e

    o sn.e9e

    o resgen.e9e

    "he obect that contains all the properties and methods for ever' A&5.I" page! that

    is built iso 5age Obect

    o ""55age Obecto Web5age Obect

    o &'stem.Web.).5age

    )n

    o S

    o

    o H

    o on4ing

    o oo4ie >oc4ing

    o oo4ie >unching

    "he method that transfers A&5.I" e9ecution to another page! but returns to the

    original page when it is done is

    Ratnabhumi Page 23 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    24/32

    .Net Interview Questions

    o &erver."ransfer(

    o &erver.Redirect(

    o &erver.I9ecute(

    o &erver.Return(

    .et Deplo'ment 6uestions:

    1. What do 'ou 4now about .I" assemblies8Answer: Assemblies are the smallest units of versioning and deplo'ment in the .I"application. Assemblies are also the building bloc4s for programs such as Web services!Windows services! serviced components! and .I" remoting applications.

    2. What,s the Diversities between private and shared assembl'8Answer: 5rivate assembl' is used inside an application onl' and does not have to be identifiedb' a strong name. &hared assembl' can be used b' multiple applications and has to have astrong name.

    %. What,s a strong name8Answer: A strong name includes the name of the assembl'! version number! culture identit'!

    and a public 4e' to4en.*. ow can 'ou tell the application to loo4 for assemblies at the locations other than its own

    install8Answer: se the directive in the @>7 .config file for a given application.Zprobing private5athGKc:Tm'libs/ binTdebugK =\should do the tric4. Or 'ou can add additional search paths in the 5roperties bo9 of thedeplo'ed application.

    -. ow can 'ou debug failed assembl' binds8Answer: se the Assembl' Linding 7og #iewer (fuslogvw.e9e to find out the pathssearched.

    0. Where are shared assemblies stored8Answer: Mlobal assembl' cache.

    3. ow can 'ou create a strong name for a .I" assembl'8

    Answer: With the help of &trong ame tool (sn.e9e.B. Where,s global assembl' cache located on the s'stem8Answer: suall' :TwinntTassembl' or :TwindowsTassembl'.

    C. an 'ou have two files with the same file name in MA8Answer: es! remember that MA is a ver' special folder! and while normall' 'ou would notbe able to place two files with the same name into a Windows folder! MA differentiates b'version number as well! so it,s possible for >'App.dll and >'App.dll to coe9ist in MA ifthe first one is version 1.E.E.E and the second one is 1.1.E.E.

    1E. &o let,s sa' ) have an application that uses >'App.dll assembl'! version 1.E.E.E. "here is asecurit' bug in that assembl'! and ) publish the patch! issuing it under name >'App.dll1.1.E.E. ow do ) tell the client applications that are alread' installed to start using this new>'App.dll8Answer: se publisher polic'. "o configure a publisher polic'! use the publisher polic'configuration file! which uses a format similar app .config file. Lut unli4e the app .config file!a publisher polic' file needs to be compiled into an assembl' and placed in the MA.

    11. What is dela' signing8Answer: Dela' signing allows 'ou to place a shared assembl' in the MA b' signing theassembl' with ust the public 4e'. "his allows the assembl' to be signed with the private 4e'at a later stage! when the development process is complete and the component or assembl' isread' to be deplo'ed. "his process enables developers to wor4 with shared assemblies as ifthe' were strongl' named! and it secures the private 4e' of the signature from being accessedat different stages of development.

    Ratnabhumi Page 24 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    25/32

    .Net Interview Questions

    .I" and O> )nterop 6uestions:

    1. Describe the advantages of writing a managed code application instead of unmanaged one.What,s involved in certain piece of code being managed8Answer: "he advantages include automatic garbage collection! memor' management! support

    for versioning and securit'. "hese advantages are provided through .I" F7 and 7R/while with the unmanaged code similar capabilities had to be implemented through thirdpart' libraries or as a part of the application itself.

    2. Are O> obects managed or unmanaged8Answer: &ince O> obects were written before .I"! apparentl' the' are unmanaged.

    %. &o can a O> obect tal4 to a .I" obect8Answer: es! through Runtime allable Wrapper (RW or 5)nvo4e.

    *. ow do 'ou generate an RW from a O> obect8Answer: se the "'pe 7ibrar' )mport utilit' shipped with &D]. tlbimp O>obect.dll=out:.I"obect.dll or reference the O> librar' from #isual &tudio in 'our proect.

    -. ) can,t import the O> obect that ) have on m' machine. Did 'ou write that obect8Answer: ou can onl' import 'our own obects. )f 'ou need to use a O> component fromanother developer! 'ou should obtain a 5rimar' )nterop Assembl' (5)A from whoever

    authored the original obect.0. ow do 'ou call unmanaged methods from 'our .I" code through 5)nvo4e8

    Answer: &uppl' a Dll)mport attribute. Declare the methods in 'our .I" code asstaticextern. Do not implement the methods as the' are implemented in 'our unmanaged code!'ou,re ust providing declarations for method signatures.

    3. an 'ou retrieve comple9 data t'pes li4e structs from the 5)nvo4e calls8Answer: es! ust ma4e sure 'ou redeclare that struct! so that managed code 4nows what todo with it.

    B. ) want to e9pose m' .I" obects to O> obects. )s that possible8Answer: es! but few things should be considered first. lasses should implement interfacese9plicitl'. >anaged t'pes must be public. >ethods! properties! fields! and events that aree9posed to O> must be public. "'pes must have a public default constructor with noarguments to be activated from O>. "'pes cannot be abstract.

    C. an 'ou inherit a O> class in a .I" application8Answer: "he .I" Framewor4 e9tends the O> model for reusabilit' b' addingimplementation inheritance. >anaged t'pes can derive directl' or indirectl' from a O>coclass/ more specificall'! the' can derive from the runtime callable wrapper generated b' theruntime. "he derived t'pe can e9pose all the method and properties of the O> obect as wellas methods and properties implemented in managed code. "he resulting obect is partl'implemented in managed code and partl' implemented in unmanaged code.

    1E. &uppose ) call a O> obect from a .I" applicaiton! but O> obect throws an error. Whathappens on the .I" end8Answer: O> methods report errors b' returning RI&7"s/ .I" methods report them b'throwing e9ceptions. "he runtime handles the transition between the two. Iach e9ceptionclass in the .I" Framewor4 maps to an RI&7".

    .I" Windows &ervices 6uestions1. I9plain Windows service.

    Answer: ou often need programs that run continuousl' in the bac4ground. For e9ample! anemail server is e9pected to listen continuousl' on a networ4 port for incoming emailmessages! a print spooler is e9pected to listen continuousl' to print re;uests! and so on.

    2. What,s the ni9 name for a Windows service e;uivalent8Answer: Daemon.

    Ratnabhumi Page 25 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    26/32

    .Net Interview Questions

    %. &o basicall' a Windows service application is ust another e9ecutable8 What,s different abouta Windows service as compared to a regular application8Answer: Windows services must support the interface of the &ervice ontrol >anager(&>. A Windows service must be installed in the Windows service database before it canbe launched.

    *. ow is development of a Windows service different from a Windows Forms application8Answer: A Windows service t'picall' does not have a user interface! it supports a set ofcommands and can have a M) that,s built later to allow for easier access to those commands.

    -. ow do 'ou give Windows service specific permissions8Answer: Windows service alwa's runs under someone,s identit'. an be &'stem orAdministrator account! but if 'ou want to restrict the behavior of a Windows service! the bestbet is to create a new user account! assign and den' necessar' privileges to that account! andthen associate the Windows service with that new account.

    0. an 'ou share processes between Windows services8Answer: es.

    3. Where,s Windows service database located8Answer: ]I[7OA7[>A)IT&&"I>Turrentontrol&etT&ervices

    B. What does &> do8Answer: &> is Windows &ervice ontrol >anager. )ts responsibilities are as follows:

    o Accepts re;uests to install and uninstall Windows services from the Windows

    service database.o "o start Windows services either on s'stem startup or re;uested b' the user.

    o "o enumerate installed Windows services.

    o "o maintain status information for currentl' running Windows services.

    o "o transmit control messages (such as &tart! &top! 5ause! and ontinue to available

    Windows services.

    o "o loc4=unloc4 Windows service database.

    C. When developing a Windows service for .I"! which namespace do 'ou t'picall' loo4 in forre;uired classes8Answer: &'stem.&ervice5rocess. "he classes are &erviceLase! &ervice5rocess)nstaller!&ervice)nstaller and &erviceontroller.

    1E. ow do 'ou handle &tart! 5ause! ontinue and &top calls from &> within 'our application8Answer: L' implementing On&tart! On5ause! Onontinue and On&top methods.

    11. Describe the startup process for a Windows service.Answer: >ain ( is e9ecuted to create an instance of a Web service! then Run( to launch it!then On&tart( from within the instance is e9ecuted.

    12. ) want to write a Windows service that cannot be paused! onl' started and stopped. ow do )accomplish that8Answer: &et an5auseAndontinue attribute to false.

    1%. What application do 'ou use to install a Windows service8Answer: installutil.e9e

    1*. ow can 'ou see which services are running on a Windows bo98Answer: Admin "ools \ omputer >anagement \ &ervices and Application \ &ervices.ou can also open the omputer >anagement tool b' rightclic4ing on >' omputer andselecting >anage from the popup menu.

    1-. ow do 'ou start! pause! continue or stop a Windows service off the command line8

    Answer: net start &erviceame! net pause &erviceame and so on. Also sc.e9e provides acommandline interface for Windows services. #iew the O& documentation or proper boo4chapters on using sc.e9e.

    "abled points

    Ratnabhumi Page 2 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    27/32

    .Net Interview Questions

    $nter%aces vs. "bstract Classes

    Ratnabhumi Page 2! of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    28/32

    .Net Interview Questions

    eature $nter%ace "bstract class

    >ultipleinheritance

    A class ma' implement severalinterfaces.

    A class ma' e9tend onl' one abstractclass.

    Default

    implementation

    An interface cannot provide

    an' code at all! much lessdefault code.

    An abstract class can provide

    complete code! default code! and=orust stubs that have to be overridden.

    onstants

    &tatic final constants onl'! canuse them without ;ualificationin classes that implement theinterface. On the other paw!these un;ualified namespollute the namespace. oucan use them and it is notobvious where the' are comingfrom since the ;ualification isoptional.

    Loth instance and static constants arepossible. Loth static and instanceintialiser code are also possible tocompute the constants.

    "hird part'convenience

    An interface implementationma' be added to an' e9istingthird part' class.

    A third part' class must be rewrittento e9tend onl' from the abstractclass.

    isa vs able orcando

    )nterfaces are often used todescribe the peripheral abilitiesof a class! not its centralidentit'! e.g. an Automobileclass might implement theRec'clable interface! whichcould appl' to man' otherwise

    totall' unrelated obects.

    An abstract class defines the coreidentit' of its descendants. )f 'oudefined a Dog abstract class thenDamamation descendants are Dogs!the' are not merel' dogable.)mplemented interfaces enumeratethe general things a class can do! not

    the things a class is.

    Ratnabhumi Page 2" of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    29/32

    .Net Interview Questions

    5lugin

    ou can write a newreplacement module for aninterface that contains not onestic4 of code in common withthe e9isting implementations.When 'ou implement theinterface! 'ou start fromscratch without an' defaultimplementation. ou have toobtain 'our tools from otherclasses/ nothing comes withthe interface other than a fewconstants. "his gives 'oufreedom to implement aradicall' different internal

    design.

    ou must use the abstract class asisfor the code base! with all itsattendant baggage! good or bad. "heabstract class author has imposedstructure on 'ou. Depending on the

    cleverness of the author of theabstract class! this ma' be good orbad. Another issue thats important iswhat ) call Hheterogeneous vs.homogeneous.H )fimplementors=subclasses arehomogeneous! tend towards anabstract base class. )f the' areheterogeneous! use an interface.(ow all ) have to do is come upwith a good definition ofhetero=homogeneous in this conte9t.)f the various obects are all ofa

    4ind! and share a common state andbehavior! then tend towards acommon base class. )f all the' shareis a set of method signatures! thentend towards an interface.

    omogeneit'

    )f the entire variousimplementations share is themethod signatures! then aninterface wor4s best.

    )f the various implementations are allof a 4ind and share a common statusand behavior! usuall' an abstractclass wor4s best.

    >aintenance

    )f 'our client code tal4s onl' in

    terms of an interface! 'ou caneasil' change the concreteimplementation behind it!using a factor' method.

    Qust li4e an interface! if 'our client

    code tal4s onl' in terms of anabstract class! 'ou can easil' changethe concrete implementation behindit! using a factor' method.

    &peed

    &low! re;uires e9tra indirectionto find the correspondingmethod in the actual class.>odern Q#>s are discoveringwa's to reduce this speedpenalt'.

    Fast

    "erseness

    "he constant declarations in an

    interface are all presumedpublic static final! so 'ou ma'leave that part out. ou cantcall an' methods to computethe initial values of 'ourconstants. ou need notdeclare individual methods ofan interface abstract. "he' areall presumed so.

    ou can put shared code into an

    abstract class! where 'ou cannot intoan interface. )f interfaces want toshare code! 'ou will have to writeother bubblegum to arrange that. ouma' use methods to compute theinitial values of 'our constants andvariables! both instance and static.ou must declare all the individualmethods of an abstract class abstract.

    Ratnabhumi Page 2# of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    30/32

    .Net Interview Questions

    Addingfunctionalit'

    )f 'ou add a new method to aninterface! 'ou must trac4 downall implementations of thatinterface in the universe andprovide them with a concrete

    implementation of that method.

    )f 'ou add a new method to anabstract class! 'ou have the option ofproviding a default implementationof it. "hen all e9isting code willcontinue to wor4 without change.

    Order o% events in an asp.net pa#e

    Control 'ecution i%eccle?

    *hase What a control needs to do +ethod or event to override

    )nitiali+e )nitiali+e settings needed during thelifetime of the incoming Web re;uest.

    $nitevent (On$nitmethod

    7oad view state At the end of this phase! the ,iewState

    propert' of a control is automaticall'populated as described in >aintaining&tate in a ontrol. A control can overridethe default implementation of theoad,iewStatemethod to customi+estate restoration.

    oad,iewStatemethod

    5rocesspostbac4 data

    5rocess incoming form data and updateproperties accordingl'.

    oad*ostDatamethod (if$*ost-acData/andlerisimplemented

    7oad 5erform actions common to all re;uests!such as setting up a database ;uer'. Atthis point! server controls in the tree are

    created and initiali+ed! the state isrestored! and form controls reflect clientside data.

    oadevent

    (Onoadmethod

    &end postbac4changenotifications

    Raise change events in response to statechanges between the current and previouspostbac4s.

    Raise*ostDataChan#ed'ventmethod (if $*ost-acData/andleris implemented

    andle postbac4events

    andle the clientside event that causedthe postbac4 and raise appropriate eventson the server.

    Raise*ost-ac'ventmethod(if$*ost-ac'vent/andlerisimplemented

    5rerender 5erform an' updates before the output isrendered. An' changes made to the state

    of the control in the prerender phase canbe saved! while changes made in therendering phase are lost.

    *reRenderevent(On*reRendermethod

    &ave state "he ,iewStatepropert' of a control isautomaticall' persisted to a string obectafter this stage. "his string obect is sentto the client and bac4 as a hiddenvariable. For improving efficienc'! acontrol can override the Save,iewState

    Save,iewStatemethod

    Ratnabhumi Page 3$ of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    31/32

    .Net Interview Questions

    method to modif' the ,iewStatepropert'.

    Render Menerate output to be rendered to theclient.

    Rendermethod

    Dispose 5erform an' final cleanup before the

    control is torn down. References toe9pensive resources such as databaseconnections must be released in thisphase.

    Disposemethod

    nload 5erform an' final cleanup before thecontrol is torn down. ontrol authorsgenerall' perform cleanup in Disposeanddo not handle this event.

    0noad event (On 0noadmethod

    Diversities betweenWeb user controls Web custom controls

    Iasier to create arder to create

    7imited support for consumers who use avisual design tool

    Full visual design tool support for consumers

    A separate cop' of the control is re;uired ineach application

    Onl' a single cop' of the control is re;uired! in theglobal assembl' cache

    annot be added to the "oolbo9 in #isual&tudio

    an be added to the "oolbo9 in #isual &tudio

    Mood for static la'out Mood for d'namic la'out

    1he di%%erent authentication modes in the .!'1 environment

    "ttribut

    e

    Option Description

    mode ontrols the default authentication mode for an application.

    Windows &pecifies Windows authentication as the default authentication mode. sethis mode when using an' form of >icrosoft )nternet )nformation &ervices())& authentication: Lasic! Digest! )ntegrated Windows authentication("7>=]erberos! or certificates.

    Forms &pecifies A&5.I" formsbased authentication as the default

    authentication mode.

    5assport &pecifies >icrosoft 5assport authentication as the default authenticationmode.

    one &pecifies no authentication. Onl' anon'mous users are e9pected orapplications can handle events to provide their own authentication.

    Ratnabhumi Page 31 of 32 [email protected]

  • 8/13/2019 Dotnet Interview Questions.doc

    32/32

    .Net Interview Questions

    Diversities between web services & remotin#

    "S*.!'1 Web Services .!'1 Remotin#

    5rotocol an be accessed onl' over ""5an be accessed over an' protocol(including "5! ""5! &>"5 and so on

    &tate>anagement

    Web services wor4 in a statelessenvironment

    5rovide support for both stateful andstateless environments through &ingletonand &ingleall obects

    "'pe &'stem

    Web services support onl' thedatat'pes defined in the @&D t'pes'stem! limiting the number ofobects that can be seriali+ed.

    sing binar' communication! .I"Remoting can provide support for richt'pe s'stem

    )nteroperabilit'

    Web services supportinteroperabilit' across platforms! andare ideal for heterogeneousenvironments.

    .I" remoting re;uires the client be builtusing .I"! enforcing homogenousenvironment.

    Reliabilit' ighl' reliable due to the fact thatWeb services are alwa's hosted in))&

    an also ta4e advantage of ))& for fault

    isolation. )f ))& is not used! applicationneeds to provide plumbing for ensuring thereliabilit' of the application.

    I9tensibilit'

    5rovides e9tensibilit' b' allowing usto intercept the &OA5 messagesduring the seriali+ation anddeseriali+ation stages.

    #er' e9tensible b' allowing us tocustomi+e the different components ofthe .I" remoting framewor4.

    Iaseof5rogramming

    Ias'tocreate and deplo'. omple9 to program.