solved assignments for bsci- 61

Upload: rachit-khandelwal

Post on 01-Jun-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Solved Assignments for Bsci- 61

    1/5

    Solved Assignments for B.Sc.(IT) BSIT - 61 TA Basics of.NETQus 1) !at does .NET frame"or# com$rised off%

     ANS& T!e .NET 'rame"or# is icrosofts $latform for *uilding a$$lications t!at !ave visuall+ stunning usere,$eriences seamless and secure communication and t!e a*ilit+ to model a range of *usiness $rocesses. T!e.NET 'rame"or# consists of &

    /ommon 0anguage untime - $rovides an a*straction la+er over t!e o$erating s+stem.

    Base /lass 0i*raries - $re-*uilt code for common lo"-level $rogramming tas#s 2evelo$ment frame"or#s andtec!nologies - reusa*le customi3a*le solutions for larger $rogramming tas#s.

    Qus 4)!ic! are t!e $latform tec!nologies su$$orted *+ .NET frame"or#%

    ANS& T!e $latform tec!nologies mainl+ su$$orted *+ .NET frame"or# are A25.NET internet tec!nologies andinterface designing.

    Qus ) 7o" t!e "indo"s $rogramming is different from .NET $rogramming%

    ANS& In "indo"s $rogramming t!e a$$lication $rogram calls t!e "indo"s A8I function directl+. T!e a$$licationruns on t!e "indo"s environment ie o$erating s+stem itself. T!ese t+$e of a$$lication are called unmanaged orunsafe a$$lication. In .NET $rogramming t!e a$$lication $rogram call .NET Base /lass 0i*rar+ function "!ic! "illcommunicate "it! t!e o$erating s+stem. T!e a$$lication runs in .NET untime environment. T!ese t+$e ofa$$lication are called managed or safe a$$lication. T!e .net untime starts code e,ecution manages t!read$rovides services managesmemor+ etc. T!e .NET Base /lasses are full+ o*9ect oriented. It $rovides all t!efunctionalities of traditional "indo"s A8I along "it! functionalities in ne" areas li#e accessing data*ase internetconnection and "e* services.

    Qus :)!at is t!e function of /TS% E,$lain t!e classification of t+$es in /TS "it! a diagram.%%

    ANS& T!e /ommon T+$e S$ecification (/TS) $erforms t!e follo"ing functions&Esta*lis!es a common frame"or#t!at ena*les cross language integration t+$e safet+ and !ig! $erformance code e,ecution.8rovides an o*9ect-oriented model.defines rules t!at a language must follo" so t!at different language can interact "it! ot!erlanguage.T!e classification for t+$es of /TS

  • 8/9/2019 Solved Assignments for Bsci- 61

    2/5

    Qus ;)!at are assem*lies% !at are static and d+namic assem*lies%

    ANS& Assem*lies are t!e *uilding *loc#s of .NET 'rame"or# a$$lications< t!e+ form t!e fundamental unit ofde$lo+ment version control reuse activation sco$ing and securit+ $ermissions. An assem*l+ is a collection oft+$es and resources t!at are *uilt to "or# toget!er and form a logical unit of functionalit+. An assem*l+ $rovidest!e common language runtime "it! t!e information it needs to *e a"are of t+$e im$lementations. To t!e runtime att+$e does not e,ist outside t!e conte,t of an assem*l+.

     Static assem*lies can include .NET 'rame"or# t+$es(interfaces and classes) as "ell as resources for t!eassem*l+ (*itma$s =8E> files resource files and so on). Static assem*lies are stored on dis# in 8E files. ?ou canalso use t!e .NET 'rame"or# to create d+namic assem*lies"!ic! are run directl+ from memor+ and are not savedto dis# *efore e,ecution. ?ou can save d+namic assem*lies to dis# after t!e+ !ave e,ecuted.

    Qus 6)E,$lain general structure of c@%

    ANS& /@ $rograms can consist of one or more files. Eac! file can contain one or more names$aces. A names$acecan contain t+$es suc! as classesstructs interfaces enumerations and delegates in addition to ot!ernames$aces. T!e follo"ing is t!e s#eleton of a /@ $rogram t!at contains all of t!ese elements.

      A s#eleton of a /@ $rogram.

  • 8/9/2019 Solved Assignments for Bsci- 61

    3/5

     using S+stem<

    names$ace +Names$ace1

    class +/lass1

    Cstruct +Struct

    C

    interface I+Interface

    Cdelegate int +2elegate()<

    enum +Enum

    C

    names$ace +Names$ace4

     

    C

    class +/lass4

    $u*lic static void ain(stringD args)

    C

    C

    C

    Qus F)7o" do names$aces and t+$es in c@ !ave uniGue names% >ive e,am$les.

    ANS& Names$aces are /@ $rogram elements designed to !el$ +ou organi3e +our $rograms. T!e+ also $rovideassistance in avoiding name clas!es *et"een t"o sets of code. Im$lementing Names$aces in +our o"n code is agood !a*it *ecause it is li#el+ to save +ou from $ro*lems later "!en +ou "ant to reuse some of +our code. 'ore,am$le if +ou created a class named /onsole +ou "ould need to $ut it in +our o"n names$ace to ensure t!att!ere "asnt an+ confusion a*out "!en t!e S+stem. /onsole class s!ould *e used or "!en +our class s!ould *eused. >enerall+ it "ould *e a *ad idea to create a class named /onsole *ut in man+ cases +our classes "ill *enamed t!e same as classes in eit!er t!e .NET 'rame"or# /lass 0i*rar+ or a t!ird $art+ li*rar+ and names$aces!el$ +ou avoid t!e $ro*lems t!at identical class names "ould cause. Names$aces dont corres$ond to file or

  • 8/9/2019 Solved Assignments for Bsci- 61

    4/5

    director+ names. If naming directories and files to corres$ond to names$aces !el$s +ou organi3e +our code t!en+ou ma+ do so *ut it is not reGuired. 'or e,$-m+names$ace1 m+nams$ace4 etc.

    Qus H)!at is delegate% !at is t!e use of it% >ive e,am$le.

    ANS& A delegate is a t+$e t!at references a met!od. 5nce a delegate is assigned a met!od it *e!aves e,actl+ li#et!at met!od. T!e delegate met!od can *e used li#e an+ ot!er met!od "it! $arameters and a return value.Adelegate is e,tremel+ im$ortant for /@ as it is one of t!e four entities t!at can *e $laced in a names$ace. T!isma#es it s!area*le among classes. 2elegates are full+ o*9ect oriented as t!e+ entirel+ enclosed or enca$sulate ano*9ect instance and a met!od. A delegate defines a class and e,tends S+stem. 2elegate. It can call an+ function aslong as t!e

    met!ods signature matc!es t!e delegates. T!is ma#es delegates ideal for anon+mous invocation. T!e met!odssignature onl+ includes t!e return t+$e and t!e $arameter list. If t"o delegates !ave t!e same $arameter and returnt+$e t!at is t!e+ s!are t!e same signature< "e consider t!em as different delegates 8u*lic delegate int 8erform/alculation (int , int +)<

    Qus ) rite a $rogram to demonstrate use of enums in /@%

    ANS&

    JJJ E,am$le $rogram t!at uses enums (/@) JJJ

    Ksing S+stem<

    /lass 8rogram

    Enum Im$ortance

    None

    Trivial

    egular

    Im$ortant

    /ritical

    C<

    static void ain()

      1.Im$ortance i1 J Im$ortance. /ritical<

      4.

    If (i1 JJ Im$ortance. Trivial)

  • 8/9/2019 Solved Assignments for Bsci- 61

    5/5

    /onsole.rite0ine(LNot trueL)<

    C

    Else if (i1 JJ Im$ortance. /ritical)

    /onsole.rite0ine (LTrueL)<

    C

    C

    C5ut$ut of t!e $rogram True

    Qus 1M)!at is t!e use of attri*utes in /@ $rograms%

    ANS&

     T!e advantage of using attri*utes resides in t!e fact t!at t!e information t!at it contains is inserted into t!eassem*l+. T!is information can t!en *e consumed at various times for all sorts of $ur$oses&

    An attri*ute can *e consumed *+ t!e com$iler. T!e S+stem.5*soleteAttri*ute attri*ute t!at "e !ave 9ustdescri*ed is a good e,am$le of !o" an attri*ute is used *+ t!e com$iler< certain standard attri*utes "!ic! are onl+destined for t!e com$iler are not stored in t!e assem*l+. 'or e,am$le t!e Seriali3ation Attri*ute Attri*ute does notdirectl+ mar# a t+$e *ut rat!er tells t!e com$iler t!at t+$e can *e seriali3ed. /onseGuentl+ t!e com$iler sets certainflags on t!e concerned t+$e "!ic! "ill *e consumed *+ t!e /0 during e,ecution suc! attri*utes are also named$seudo-attri*utes.

    An attri*ute can *e consumed *+ t!e /0 during e,ecution. 'or E,am$le t!e .NET 'rame"or# offers t!eS+stem.T!readStaticAttri*ute attri*ute. !en a static field is mar#ed "it! t!is attri*ute t!e /0 ma#es sure t!atduring t!e e,ecution t!ere is onl+ one version of t!is field $er t!read.

    An attri*ute can *e consumed *+ a de*ugger during e,ecution. 7encet!eS+stem.2iagnostics.2e*ugger2is$la+Attri*ute attri*ute allo"s $ersonali3ing t!e dis$la+ of an element of t!e code(t!e state of an o*9ect for e,am$le) during de*ugging.

    An attri*ute can *e consumed *+ a tool for e,am$le t!e .NET frame"or# offers t!eS+stem.untime.Intero$Services./omisi*leAttri*ute attri*ute. !en A class is mar#ed "it! t!is attri*ute t!etl*e,$.e,e tool generates a file "!ic! "ill allo" t!is class to *e consumed as if it "as a /5 o*9ect.

    An attri*ute can *e consumed *+ +our o"n code during e,ecution *+ using t!e reflection mec!anism to accesst!e information. 'or E,am$le it can *e interesting to use suc! attri*utes to validate t!e value of fields in +ourclasses. Suc! a field must *e "it!in a certain range. Anot!er reference field must not *e null. A string field can *eatmost 1MM c!aracters. Because of t!e reflection mec!anism it is eas+ to "rite code to validate t!e state of an+mar#ed fields. A little later "e "ill s!o" +ou suc! an e,am$le "!ere +ou can consume attri*utes *+ +our o"ncode.

    An attri*ute can *e consumed *+ a user "!ic! anal+ses an assem*l+ "it! a tool suc! as ildasm.e,e or eflector.7ence +ou could imagine an attri*ute "!ic! "ould associate a c!aracter string to an element of +our code. T!isstring *eing contained in t!e assem*l+ it is t!en $ossi*le to consult t!ese comments "it!out needing to accesssource code.