Sunteți pe pagina 1din 10

Short Answer .

NET Interview Questions (PAGE 1)


Q1. Explain the differences between Server-side and Client-side code?
Ans. Server side code will execute at server (where the website is hosted) end ! all the
business lo"ic will execute at server end where as client side code will execute at client
side (usuall# written in $avascri%t vbscri%t $scri%t) at browser end.
Q2. What type of code (server or client is fo!nd in a Code-"ehind class?
Ans. Server side code.
Q#. $ow to %a&e s!re that val!e is entered in an asp'(extbox control?
Ans. &se a 'e(uired)ield*alidator control.
Q). Which property of a validation control is !sed to associate it with a server
control on that pa*e?
Ans. +ontrolTo*alidate %ro%ert#.
Q+. $ow wo!ld yo! i%ple%ent inheritance !sin* ,".-E( . C/?
Ans. +, -erived +lass . /aseclass
*/.NEt . -erived +lass Inherits /aseclass
Q0. Which %ethod is invo&ed on the 1ata2dapter control to load the *enerated
dataset with data?
Ans. )ill() 0ethod.
Q3. What %ethod is !sed to explicitly &ill a !ser4s session?
Ans. Session.Abandon()
Q5. What property within the asp'*ridview control is chan*ed to bind col!%ns
%an!ally?
Ans. Auto"enerated colu0ns is set to 1alse
Q6. Which %ethod is !sed to redirect the !ser to another pa*e witho!t perfor%in* a
ro!nd trip to the client?
Ans. Server.Trans1er 0ethod.
Q17. $ow do we !se different versions of private asse%blies in sa%e application
witho!t re-b!ild?
Ans.Inside the Asse0bl#in1o.cs or Asse0bl#in1o.vb 1ile we need to s%eci1# asse0bl#
version.
asse0bl#. Asse0bl#*ersion
Q11. 8s it possible to deb!* 9ava-script in .-E( 81E? 8f yes: how?
Ans. 2es si0%l# write 3debu""er3 state0ent at the %oint where the brea4%oint needs to
be set within the $avascri%t code and also enable $avascri%t debu""in" in the browser
%ro%ert# settin"s.
Q12. $ow %any ways can we %aintain the state of a pa*e?
Ans. 1. +lient Side 5 Quer# strin" hidden variables viewstate coo4ies
6. Server side 5 a%%lication cache context session database
Q1#. What is the !se of a %!lticast dele*ate?
Ans. A 0ulticast dele"ate 0a# be used to call 0ore than one 0ethod.
Q1). What is the !se of a private constr!ctor?
Ans. A %rivate constructor 0a# be used to %revent the creation o1 an instance 1or a class.
Q1+. What is the !se of Sin*leton pattern?
Ans. A Sin"leton %attern .is used to 0a4e sure that onl# one instance o1 a class exists.
Q10. When do we !se a 1;< parser and when do we !se a S2= parser?
Ans. The -78 A%%roach is use1ul 1or s0all docu0ents in which the %ro"ra0 needs to
%rocess a lar"e %ortion o1 the docu0ent whereas the SA9 a%%roach is use1ul 1or lar"e
docu0ents in which the %ro"ra0 onl# needs to %rocess a s0all %ortion o1 the docu0ent.
Q13. Will the finally bloc& be exec!ted if an exception has not occ!rred?
Ans.2es it will execute.
Q15. What is a 1ataset?
Ans. A dataset is an in 0e0or# database 4indo1 ob$ect that can hold database in1or0ation
in a disconnected environ0ent.
Q16. 8s =<> a case-sensitive %ar&!p lan*!a*e?
Ans. 2es.
Q27. What is an .ashx file?
Ans. It is a web handler 1ile that %roduces out%ut to be consu0ed b# an x0l consu0er
client (rather than a browser).
Short Answer .NET Interview Questions (PAGE 6)
Q21. What is encaps!lation?
Ans. Enca%sulation is the 77Ps conce%t o1 bindin" the attributes and behaviors in a class
hidin" the i0%le0entation o1 the class and ex%osin" the 1unctionalit#.
Q22. What is ;verloadin*?
Ans. :hen we add a new 0ethod with the sa0e na0e in a sa0e;derived class but with
di11erent nu0ber;t#%es o1 %ara0eters the conce%t is called overluoad and this ulti0atel#
i0%le0ents Pol#0or%his0.
Q2#. What is ;verridin*?
Ans. :hen we need to %rovide di11erent i0%le0entation in a child class than the one
%rovided b# base class we de1ine the sa0e 0ethod with sa0e si"natures in the child
class and this is called overridin".
Q2). What is a 1ele*ate?
Ans. A dele"ate is a stron"l# t#%ed 1unction %ointer ob$ect that enca%sulates a re1erence
to a 0ethod and so the 1unction that needs to be invo4ed 0a# be called at runti0e.
Q2+. 8s Strin* a ?eference (ype or ,al!e (ype in .-E(?
Ans. Strin" is a 'e1erence T#%e ob$ect.
Q20. What is a Satellite 2sse%bly?
Ans. Satellite asse0blies contain resource 1iles corres%ondin" to a locale (+ulture <
=an"ua"e) and these asse0blies are used in de%lo#in" an a%%lication "loball# 1or
di11erent lan"ua"es.
Q23. What are the different types of asse%blies and what is their !se?
Ans. Private Public(also called shared) and Satellite Asse0blies.
Q25. 2re <S8> and C8> the sa%e thin*?
Ans. 2es +I= is the new na0e 1or 8SI=.
Q26. What is the base class of all web for%s?
Ans. S#ste0.:eb.&I.Pa"e
Q#7. $ow to add a client side event to a server control?
Ans. Exa0%le...
/tnSub0it.Attributes.Add(3onclic433$avascri%t.1nSo0e)unctionIn>avascri%t()3)?
Q#1. $ow to re*ister a client side script fro% code-behind?
Ans. &se the Pa"e.'e"ister+lientScri%t/loc4 0ethod in the server side code to re"ister
the scri%t that 0a# be built usin" a Strin"/uilder.
Q#2. Can a sin*le .-E( 1>> contain %!ltiple classes?
Ans. 2es a sin"le .NET -== 0a# contain an# nu0ber o1 classes within it.
Q##. What is 1>> $ell?
Ans. -== @ell is the na0e "iven to the %roble0 o1 old un0ana"ed -==As due to which
there was a %ossibilit# o1 version con1lict a0on" the -==s.
Q#). can we p!t a brea& state%ent in a finally bloc&?
Ans. The 1inall# bloc4 cannot have the brea4 continue return and "oto state0ents.
Q#+. What is a Co%positeControl in .-E(?
Ans. +o0%osite+ontrol is an abstract class in .NET that is inherited b# those web
controls that contain child controls within the0.
Q#0. Which control in asp.net is !sed to display data fro% an x%l file and then
displayed !sin* =S>(?
Ans. &se the as%.90l control and set its -ocu0entSource %ro%ert# 1or associatin" an
x0l 1ile and set its Trans1or0Source %ro%ert# to set the x0l controlAs xsl 1ile 1or the
9S=T trans1or0ation.
Q#3. Can we r!n 2S@.-E( 1.1 application and 2S@.-E( 2.7 application on the
sa%e co%p!ter?
Ans. 2es thou"h chan"es in the IIS in the %ro%erties 1or the site have to be 0ade durin"
de%lo#0ent o1 each.
Q#5. What are the new feat!res in .-E( 2.7?
Ans. Plent# o1 new controls Generics anon#0ous 0ethods %artial classes iterators
%ro%ert# visibilit# (se%arate visibilit# 1or "et and set) and static classes.
Q#6. Can we pop a <essa*e"ox in a web application?
Ans. 2es thou"h this is done clientside usin" an alert %ro0%t or con1ir0 or b# o%enin" a
new web %a"e that loo4s li4e a 0essa"ebox.
Q)7. What is %ana*ed data?
Ans. The data 1or which the 0e0or# 0ana"e0ent is ta4en care b# .Net runti0eBs "arba"e
collector and this includes tas4s 1or allocation de5allocation.
Q)1. $ow to instr!ct the *arba*e collector to collect !nreferenced data?
Ans. :e 0a# call the "arba"e collector to collect unre1erenced data b# executin" the
S#ste0.G+.+ollect() 0ethod.
Q)2. $ow can we set the Aoc!s on a control in 2S@.-E(?
Ans. txt/ox16C.)ocus()? 7' Pa"e.Set)ocus(Na0e71+ontrol)?
Q)#. What are @artial Classes in 2sp.-et 2.7?
Ans. In .NET 6.D a class de1inition 0a# be s%lit into 0ulti%le %h#sical 1iles but %artial
classes do not 0a4e an# di11erence to the co0%iler as durin" co0%ile ti0e the co0%iler
"rou%s all the %artial classes and treats the0 as a sin"le class.
Q)). $ow to set the defa!lt b!tton on a Web Aor%?
Ans. Eas%.1or0 idF31or013 runatF3server3 de1aultbuttonF3btnGo3;G
Q)+.Can we force the *arba*e collector to r!n?
Ans. 2es usin" the S#ste0.G+.+ollect() the "arba"e collector is 1orced to run in case
re(uired to do so.
Q)0. What is "oxin* and Bnboxin*?
Ans. /oxin" is the %rocess where an# value t#%e can be i0%licitl# converted to a
re1erence t#%e ob$ect while &nboxin" is the o%%osite o1 boxin" %rocess where the
re1erence t#%e is converted to a value t#%e.
Q)3. What is Code 2ccess sec!rity? What is C2S in .-E(?
Ans. +AS is the 1eature o1 the .NET securit# 0odel that deter0ines whether an
a%%lication or a %iece o1 code is %er0itted to run and decide the resources it can use while
runnin".
Q)5. What is <!lti-tas&in*?
Ans. It is a 1eature o1 o%eratin" s#ste0s throu"h which 0ulti%le %ro"ra0s 0a# run on the
o%eratin" s#ste0 at the sa0e ti0e $ust li4e a scenario where a Note%ad a +alculator and
the +ontrol Panel are o%en at the sa0e ti0e.
Q)6. What is <!lti-threadin*?
Ans. :hen an a%%lication %er1or0s di11erent tas4s at the sa0e ti0e the a%%lication is
said to exhibit 0ultithreadin" as several threads o1 a %rocess are runnin".6
Q+7. What is a (hread?
Ans. A thread is an activit# started b# a %rocess and its the basic unit to which an
o%eratin" s#ste0 allocates %rocessor resources.
Q+1. What does 2ddress;f in ,".-E( operator do?
Ans. The Address71 o%erator is used in */.NET to create a dele"ate ob$ect to a 0ethod
in order to %oint to it.
Q+2. $ow to refer to the c!rrent thread of a %ethod in .-E(?
Ans. In order to re1er to the current thread in .NET the Thread.+urrentThread 0ethod
can be used. It is a %ublic static %ro%ert#.
Q+#. $ow to pa!se the exec!tion of a thread in .-E(?
Ans. The thread execution can be %aused b# invo4in" the Thread.Slee%(Inte"er*alue)
0ethod where Inte"er*alue is an inte"er that deter0ines the 0illiseconds ti0e 1ra0e 1or
which the thread in context has to slee%.
Q+). $ow can we force a thread to sleep for an infinite period?
Ans. +all the Thread.Interu%t() 0ethod.
Q++. What is S!spend and ?es!%e in .-E( (hreadin*?
Ans. >ust li4e a son" 0a# be %aused and %la#ed usin" a 0usic %la#er a thread 0a# be
%aused usin" Thread.Sus%end 0ethod and 0a# be started a"ain usin" the Thread.'esu0e
0ethod. Note that slee% 0ethod i00ediatel# 1orces the thread to slee% whereas the
sus%end 0ethod waits 1or the thread to be in a %ersistable %osition be1ore %ausin" its
activit#.
Q+0. $ow can we prevent a deadloc& in .-et threadin*?
Ans. &sin" 0ethods li4e 8onitorin" Interloc4ed classes :ait handles Event raisin"
1ro0 between threads usin" the ThreadState %ro%ert#.
Q+3. What is 29ax?
Ans. As#ncronous >avascri%t and 98= 5 A$ax is a co0bination o1 client side
technolo"ies that sets u% as#nchronous co00unication between the user inter1ace and the
web server so that %artial %a"e renderin" occur instead o1 co0%lete %a"e %ostbac4s.
Q+5. What is =%l$ttp?eC!est in 29ax?
Ans. It is an ob$ect in >avascri%t that allows the browser to co00unicate to a web server
as#nchronousl# without 0a4in" a %ostbac4.
Q+6. What are the different %odes of storin* an 2S@.-E( session?
Ans. InProc (the session state is stored in the 0e0or# s%ace o1 the As%netHw%.exe
%rocess but the session in1or0ation is lost when IIS reboots) StateServer (the Session
state is serialiIed and stored in a se%arate %rocess call *iewstate is an ob$ect in .NET that
auto0aticall# %ersists control settin" values across the 0ulti%le re(uests 1or the sa0e
%a"e and it is internall# 0aintained as a hidden 1ield on the web %a"e thou"h its hashed
1or securit# reasons.
Q07. What is a dele*ate in .-E(?
Ans. A dele"ate in .NET is a class that can have a re1erence to a 0ethod and this class
has a si"nature that can re1er onl# those 0ethods that have a si"nature which co0%lies
with the class.
Short Answer .NET Interview Questions (PAGE J)
Q01. 8s a dele*ate a type-safe f!nctions pointer?
Ans. 2es
Q02. What is the ret!rn type of an event in .-E(?
Ans. There is No return t#%e o1 an event in .NET.
Q0#. 8s it possible to specify an access specifier to an event in .-E(?
Ans. 2es thou"h the# are %ublic b# de1ault.
Q0). 8s it possible to create a shared event in .-E(?
Ans. 2es but shared events 0a# onl# be raised b# shared 0ethods.
Q0+. $ow to prevent overridin* of a class in .-E(?
Ans. &se the 4e#word Not7verridable in */.NET and sealed in +,.
Q00. $ow to prevent inheritance of a class in .-E(?
Ans. &se the 4e#word NotInheritable in */.NET and sealed in +,.
Q03. What is the p!rpose of the <!st8nherit &eyword in ,".-E(?
Ans. 8ustInherit 4e#word in */.NET is used to create an abstract class.
Q05. What is the access %odifier of a %e%ber f!nction of in an 8nterface created
in .-E(?
Ans. It is alwa#s %ublic we cant use an# other 0odi1ier other than the %ublic 0odi1ier 1or
the 0e0ber 1unctions o1 an Inter1ace.
Q06. What does the virt!al &eyword in C/ %ean?
Ans. The virtual 4e#word si"ni1ies that the 0ethod and %ro%ert# 0a# be overridden.
Q37. $ow to create a new !niC!e 81 for a control?
Ans. +ontrolNa0e.I- F 3+ontrolNa0e3 < Guid.NewGuid().ToStrin"()? ;;8a4e use o1 the
Guid class
Q312. What is a $ash(able in .-E(?
Ans. A @ashtable is an ob$ect that i0%le0ents the I-ictionar# inter1ace and can be used
to store 4e# value %airs. The 4e# 0a# be used as the index to access the values 1or that
index.
Q31". What is an 2rray>ist in .-E(?
Ans. Arra#list ob$ect is used to store a list o1 values in the 1or0 o1 a list such that the siIe
o1 the arra#list can be increased and decreased d#na0icall# and 0oreover it 0a# hold
ite0s o1 di11erent t#%es. Ite0s in an arra#list 0a# be accessed usin" an index.
Q32. What is the val!e of the first ite% in an En!%? 7 or 1?
Ans. D
Q3#. Can we achieve operator overloadin* in ,".-E(?
Ans. 2es it is su%%orted in the .NET 6.D version the 3o%erator3 4e#word is used.
Q3). What is the !se of AinaliDe %ethod in .-E(?
Ans. .NET Garba"e collector %er1or0s all the clean u% activit# o1 the 0ana"ed ob$ects
and so the 1inaliIe 0ethod is usuall# used to 1ree u% the un0ana"ed ob$ects li4e )ile
ob$ects :indows API ob$ects -atabase connection ob$ects +78 ob$ects etc.
Q3+. $ow do yo! save all the data in a dataset in .-E(?
Ans. &se the Acce%t+han"es 0ethod which co00its all the chan"es 0ade to the dataset
since last ti0e Acce%tchan"es was %er1or0ed.
Q30. 8s there a way to s!ppress the finaliDe process inside the *arba*e collector
forcibly in .-E(?
Ans. &se the G+.Su%%ress)inaliIe() 0ethod.
Q33. What is the !se of the dispose( %ethod in .-E(?
Ans. The -is%ose 0ethod in .NET belon"s to I-is%osable inter1ace and it is best used to
release un0ana"ed ob$ects li4e )ile ob$ects :indows API ob$ects -atabase connection
ob$ects +78 ob$ects etc 1ro0 the 0e0or#. Its %er1or0ance is better than the 1inaliIe()
0ethod.
Q35. 8s it possible to have have different access %odifiers on the *et and set %ethods
of a property in .-E(?
Ans. No we can not have di11erent 0odi1iers o1 a co00on %ro%ert# which 0eans that i1
the access 0odi1ier o1 a %ro%ert#As "et 0ethod is %rotected and it 0ust be %rotected 1or
the set 0ethod as well.
Q36. 8n .-E(: is it possible for two catch bloc&s to be exec!ted in one *o?
Ans. This is N7T %ossible because once the correct catch bloc4 is executed then the code
1low "oes to the 1inall# bloc4.
Q57. 8s there any difference between Syste%.Strin* and Syste%.Strin*"!ilder
classes?
Ans. S#ste0.Strin" is i00utable b# nature whereas S#ste0.Strin"/uilder can have a
0utable strin" in which %lent# o1 %rocesses 0a# be %er1or0ed.
Q51. What techniC!e is !sed to fi*!re o!t that the pa*e reC!est is a postbac&?
Ans. The IsPost/ac4 %ro%ert# o1 the %a"e ob$ect 0a# be used to chec4 whether the %a"e
re(uest is a %ostbac4 or not. IsPost/ac4 %ro%ert# is o1 the t#%e /oolean.
Q52. Which event of the 2S@.-E( pa*e life cycle co%pletely loads all the controls on
the web pa*e?
Ans. The Pa"eHload event o1 the ASP.NET %a"e li1e c#cle assures that all controls are
co0%letel# loaded. Even thou"h the controls are also accessible in Pa"eHInit event but
here the viewstate is inco0%lete.
Q5#. $ow is ,iewState infor%ation persisted across postbac&s in an 2S@.-E(
webpa*e?
Ans. &sin" @T8= @idden )ields ASP.NET creates a hidden 1ield with an
I-F3HH*IE:STATE3 and the value o1 the %a"eAs viewstate is encoded (hashed) 1or
securit#.
Q5). What is the ,alidationS!%%ary control in 2S@.-E( !sed for?
Ans. The *alidationSu00ar# control in ASP.NET dis%la#s su00ar# o1 all the current
validation errors.
Q5+. What is 2!to@ost"ac& feat!re in 2S@.-E(?
Ans. In case it is re(uired 1or a server side control to %ostbac4 when an# o1 its event is
tri""ered then the AutoPost/ac4 %ro%ert# o1 this control is set to true.
Q50. What is the difference between Web.confi* and <achine.Confi* in .-E(?
Ans. :eb.con1i" 1ile is used to 0a4e the settin"s to a web a%%lication whereas
8achine.con1i" 1ile is used to 0a4e settin"s to all ASP.NET a%%lications on a server(the
server 0achine).
Q53. What is the difference between a session ob9ect and an application ob9ect?
Ans. A session ob$ect can %ersist in1or0ation between @TTP re(uests 1or a %articular
user whereas an a%%lication ob$ect can be used "loball# 1or all the users.
Q55. Which control has a faster perfor%ance: ?epeater or 1atalist?
Ans. 'e%eater.
Q56. Which control has a faster perfor%ance: 1ata*rid or 1atalist?
Ans. -atalist.
Q67. $ow to we add c!sto%iDed col!%ns in a Eridview in 2S@.-E(?
Ans. 8a4e use o1 the Te0%late)ield colu0n.
Q61. 8s it possible to stop the clientside validation of an entire pa*e?
Ans. Set Pa"e.*alidate F 1alse?
Q62. 8s it possible to disable client side script in validators?
Ans. 2es. si0%l# Enable+lientScri%t F 1alse.
Q6#. $ow do we enable tracin* in .-E( applications?
Ans. EKL Pa"e TraceF3true3 KG
Q6). $ow to &ill a !ser session in 2S@.-E(?
Ans. &se the Session.abandon() 0ethod.
Q6+. 8s it possible to perfor% for%s a!thentication with coo&ies disabled on a
browser?
Ans. 2es it is %ossible.
Q60. What are the steps to !se a chec&box in a *ridview?
Ans. EIte0Te0%lateG
Eas%.+hec4/ox idF3+hec4/ox13 runatF3server3 AutoPost/ac4F3True3
7n+hec4ed+han"edF3+hec4H+lic4ed3GE;as%.+hec4/oxG
E;Ite0Te0%lateG
Q63. What are desi*n patterns in .-E(?
Ans. A -esi"n %attern is a re%eatitive solution to a re%eatitive %roble0 in the desi"n o1 a
so1tware architecture.
Q65. What is difference between dataset and datareader in 21;.-E(?
Ans. A -ata'eader %rovides a 1orward5onl# and read5onl# access to data while the
-ataSet ob$ect can carr# 0ore than one table and at the sa0e ti0e hold the relationshi%s
between the tables. Also note that a -ata'eader is used in a connected architecture
whereas a -ataset is used in a disconnected architecture.
Q66. Can connection strin*s be stored in web.confi*?
Ans. 2es in 1act this is the best %lace to store the connection strin" in1or0ation.
Q177. Whats the difference between web.confi* and app.confi*?
Ans. :eb.con1i" is used 1or web based as%.net a%%lications whereas a%%.con1i" is used
1or windows based a%%lications.

S-ar putea să vă placă și