COIMBATORE 35 DEPARTMENT OF COMPUTER SIENCE AND ENGINEERING (UG & PG) Third Year Electronic and Intr!"entation En#ineerin#$ % th Se"eter & Mar' (!etion and An)er S!*+ect Code & Na"e,CS&-.. & O*+ect Oriented Pro#ra""in# Pre/ared *0, P.DHIVYA, AP/CSE Unit I 2 Mark Questions and Answers .1 Gi2e o"e characteritic o3 /roced!re4oriented lan#!a#e1 Te !ara!teristi!s o" #ro!edure$oriented %an&ua&e are, i. E'#asis is on doin& tin&s (a%&orit's). ii. *ar&er #ro&ra's are di+ided into s'a%%er #ro&ra's known as "un!tions. iii. Most o" te "un!tions sare &%o,a% data. i+. Data 'o+e o#en%- around te s-ste' "ro' "un!tion to "un!tion. +. It e'#%o-s to#$down a##roa! in #ro&ra' desi&n. &1 5hat are the *aic conce/t o3 OOPS6 Te ,asi! !on!e#ts o" ..PS are, i. .,/e!ts. ii. C%asses. iii. Data a,stra!tion and En!a#su%ation. i+. Ineritan!e. +. Po%-'or#is'. +i. D-na'i! ,indin&. +ii. Messa&e #assin&. -1 5hat i an o*+ect6 An o,/e!t is ,asi! run$ti'e entit- in an o,/e!t$oriented s-ste'. Te- 'a- re#resent a #erson, a #%a!e, a ,ank a!!ount, a ta,%e o" data or an- ite' tat te #ro&ra' as to and%e. Ea! o,/e!t as te data and !ode to 'ani#u%ate te data and teses o,/e!ts intera!t wit ea! oter. 71 5hat i a cla6 A !%ass is a !o%%e!tion o" o,/e!ts o" si'i%ar t-#e. .n!e a !%ass as ,een de"ined, we !an !reate an- nu',er o" o,/e!ts ,e%on&in& to te !%ass. C%ass is a user$de"ined data t-#e and ,ea+es %ike ,ui%t$in t-#es o" te #ro&ra''in& %an&ua&e. %1 5hat i an enca/!lation6 0ra##in& u# o" data and "un!tion witin te stru!ture is !a%%ed as en!a#su%ation. Te insu%ation o" data "ro' dire!t a!!ess ,- te #ro&ra' is !a%%ed as data idin& or in"or'ation ,indin&. Te data is not a!!essi,%e to te outside wor%d and on%- tose "un!tions, wi! are wra##ed in te !%ass, !an a!!ess it. 81 5hat i "eant *0 d0na"ic *indin# or late *indin#6 D-na'i! ,indin& 'eans tat te !ode asso!iated wit a &i+en #ro!edure !a%% is not known unti% te ti'e o" te !a%% at te run$ti'e. 91 5rite the /roce o3 /ro#ra""in# in an o*+ect4oriented lan#!a#e6 Te #ro!ess o" #ro&ra''in& in an o,/e!t$oriented %an&ua&e are, i. Create !%asses tat de"ine o,/e!ts and teir ,ea+ior. ii. Creatin& o,/e!ts "ro' !%ass de"inition. iii. Esta,%isin& !o''uni!ation a'on& o,/e!ts. :1 ;it an0 3o!r ad2anta#e o3 OOPS1 Te ad+anta&es o" ..PS are, i. Te #rin!i#%e o" data idin& e%#s te #ro&ra''er to ,ui%d se!ure #ro&ra's tat !annot ,e in+aded ,- !ode in oter #arts o" te #ro&ra'. ii. It is #ossi,%e to a+e 'u%ti#%e instan!es o" an o,/e!t to !o$e1ist witout an- inter"eren!e. iii. .,/e!t oriented #ro&ra''in& !an ,e easi%- u#&raded "ro' s'a%% to %ar&e s-ste's. i+. So"tware !o'#%e1it- !an ,e easi%- 'ana&ed. <1 5hat are the 3eat!re re=!ired 3or o*+ect4*aed /ro#ra""in# lan#!a#e6 Te "eatures re2uired "or o,/e!t$,ased #ro&ra''in& are, i. Data en!a#su%ation. ii. Data idin& and a!!ess 'e!anis's. iii. Auto'ati! initia%i3ation and !%ear u# o" o,/e!ts. i+. .#erator o+er%oadin&. .>1 Gi2e an0 3o!r a//lication o3 the OOPS1 Te "our a##%i!ations o" ..PS are, i. 4ea%$ti'e s-ste's. ii. Si'u%ation and 'ode%in&. iii. .,/e!t$oriented data,ases. i+. AI and e1#ert s-ste's. ..1 5hat are the o/erator a2aila*le in C??6 Te o#erators a+ai%a,%e in C55 are, i. 66 $ S!o#e reso%ution o#erator. ii. 66 7 $ Pointer$to$'e',er de!%arator . iii. $87 $ Pointer$to$'e',er o#erator. i+. .7 $ Pointer$to$'e',er o#erator. +. de%ete $ Me'or- re%ease o#erator . +i. end% $ *ine "eed o#erator +ii. new $ Me'or- a%%o!ation o#erator +iii. setw $ 9ie%d widt o#erator .&1 5hat i a co/e reol!tion o/erator6 S!o#e reso%ution o#erator is used to un!o+er te idden +aria,%es. It a%so a%%ows a!!ess to &%o,a% +ersion o" +aria,%es. S!o#e reso%ution o#erator is used to de"ine te "un!tion outside te !%ass. S-nta16 return t-#e :!%ass na'e8 6 6 :"un!tion na'e8 E1a'#%e6 ;in!%ude:iostrea'. 8 int '<=>? // &%o,a% +aria,%e ' +oid 'ain ( ) @ int '<2>? // %o!a% +aria,%e ' !out::A'<A::'::ABnA? !out::A6 6 '<A::6 6 '::ABnA? C .ut#ut6 2> => (6 6 ' a!!ess &%o,a% ') .-1 5hat i a de3a!lt ar#!"ent6 De"au%t ar&u'ent assi&ns a de"au%t +a%ue to te #ara'eter, wi! does not a+e 'at!in& ar&u'ent in te "un!tion !a%%. De"au%t +a%ues are s#e!i"ied wen te "un!tion is de!%ared. E1a'#%e6 "%oat a'ount ("%oat #rin!i#%e, int #eriod, "%oat rate<>. =D) @ C .71 5hat i contant ar#!"ent6 Ee-word is !onst. Te 2ua%i"ier !onst te%%s te !o'#i%er tat te "un!tion sou%d not 'odi"- te ar&u'ent. Te !o'#i%er wi%% &enerate an error wen tis !ondition is +io%ated. Tis t-#e o" de!%aration is si&ni"i!ant on%- wen we #ass ar&u'ents ,- re"eren!e or #ointers E1a'#%e6 int str%en (!onst !ar 7#)? .%1 @o) the cla i /eci3iedF Genera%%- !%ass s#e!i"i!ation as two #arts. Te- are, i. C%ass de!%aration $ It des!ri,es te t-#e and s!o#e o" its 'e',er ii. C%ass "un!tion de"inition $ It des!ri,es ow te !%ass "un!tions are i'#%e'ented Te &enera% "or' is6 !%ass !%assHna'e @ #ri+ate6 +aria,%e de!%arations? "un!tion de!%aration? #u,%i!6 +aria,%e de!%aration? "un!tion de!%aration? C? .81 @o) do 0o! create an o*+ect6 .n!e te !%ass as ,een de!%ared, we !an !reate o,/e!t "or a !%ass usin& te !%ass na'e. E1a'#%e6 !%assna'e 1? //'e'or- "or 1 is !reated .91 @o) do 0o! acce a cla "e"*er6 0e !an a!!ess te 'e',er "un!tion ,- usin& te "o%%owin& s-nta16 S-nta16 .,/e!t$na'e. 9un!tion$na'e (a!tua% ar&u'ents)? E1a'#%e6 1.&etdata (=>>, ID.D)? .:1 @o) i the "e"*er 3!nction de3ined6 Me',er "un!tions !an ,e de"ined in two wa-s. Te- are, i. ii. .utside te !%ass de"inition $ Me',er "un!tion !an ,e de"ined ,- usin& s!o#e reso%ution o#erator (66). Genera% "or'at is return t-#e !%assH na'e66 "un!tion$na'e (ar&u'ent de!%aration) @ JJJJ..//"un!tion ,od- C Inside te !%ass de"inition $ Tis 'etod o" de"inin& 'e',er "un!tion is to re#%a!e te "un!tion de!%aration ,- te a!tua% "un!tion de"inition inside te !%ass. It is treated as in%ine "un!tion E1a'#%e6 !%ass ite' @ int a, ,? +oid &etdata (int 1, int -) @ a<1? ,<-? C C? .<1 5hat are the 3eat!re o3 tatic data "e"*er6 Te "eatures o" stati! data 'e',er are, i. It is initia%i3ed to 3ero wen te "irst o,/e!t is !reated ii. .n%- one !o#- o" tat 'e',er is !reated "or te entire !%ass iii. It is on%- +isi,%e witin te !%ass i+. It is stored se#arate%- rater tan o,/e!ts &>1 5hat are the it!ation that inline 3!nction "a0 not )or'6 Te situations tat in%ine "un!tions 'a- not work is 9or "un!tion returnin& +a%ues, i" a %oo#, a swit!, or a &oto e1ists. 9or "un!tion not returnin& +a%ues, i" a return state'ent e1ists. I" "un!tion !ontains stati! +aria,%es. I" in%ine "un!tions are re!ursi+e. Unit II 2 Mark Questions and Answers .1 De3ine Contr!ctor1 A !onstru!tor is de"ined as a s#e!ia% 'e',er o" a !%ass, wi! as no return t-#e. It !an ,e used to initia%i3es an o,/e!t i''ediate%- u#on !reation. &1 5rite o"e /ecial characteritic o3 contr!ctor1 So'e s#e!ia% !ara!teristi!s o" !onstru!tor are, i. Te- sou%d ,e de!%ared in te #u,%i! se!tion. ii. Te- are in+oked auto'ati!a%%- wen te o,/e!ts are !reated. iii. Te- do not a+e return t-#es, not e+en +oid and tere"ore, and te- !annot return +a%ues. i+. Te- !annot ,e inerited, tou& a deri+ed !%ass !an !a%% te ,ase !%ass +. Te- !an a+e de"au%t ar&u'ents. +i. Constru!tors !annot ,e +irtua% "un!tion. -1 @o) the o*+ect are initialiAed d0na"icall06 Te o,/e!ts an initia%i3ed d-na'i!a%%- to !a%% #ara'eteri3ed !onstru!tor or 'etods we sou%d te #ass +a%ues to te o,/e!t ie, "or te !onstru!tor inte&er add(int a, int ,) it is in+oked ,- inte&er a (=>, =K). Tis +a%ue !an ,e &et durin& run ti'e. i.e., " or a,o+e !onstru!tor E1a'#%e6 int #,2? !in88#882? inte&er add(#,2)? 71 5hat i "eant *0 o/erator o2erloadin#6 .#erator o+er%oadin& is te 'e!anis' o" &i+in& su! s#e!ia% 'eanin&s to an o#erator is known. It #ro+ides a "%e1i,%e o#tion "or te !reation o" new de"initions "or C55 o#erators. %1 ;it o!t the o/erator that cannot *e o2erloaded1 Te o#erators tat !annot ,e o+er%oaded are, i. ii. iii. i+. C%ass 'e',er a!!ess o#erator (., .7) S!o#e reso%ution o#erator (66) Si3e o#erator (si3eo") Conditiona% o#erator (F 6) 81 5hat i the /!r/oe o3 !in# o/erator 3!nction6 5rite it 0ntaB1 To de"ine an additiona% task to an o#erator, we 'ust s#e!i"- wat it 'eans in re%ation to te !%ass to wi! te o#erator is a##%ied. Tis is done ,- .#erator "un!tion , wi! des!ri,es te task. .#erator "un!tions are eiter 'e',er "un!tions or "riend "un!tions. Te &enera% "or' is 6 return t-#e !%assna'e 66 o#erator o#(ar&%ist ) @ // "un!tion ,od- C 91 5rite an0 3o!r r!le 3or o/erator o2erloadin#1 4u%es "or .#erator o+er%oadin& are, i. .n%- te e1istin& o#erators !an ,e o+er%oaded. ii. Te o+er%oaded o#erator 'ust a+e at%east one o#erand tat is o" user de"ined data t-#e. iii. Te ,asi! 'eanin& o" te o#erator sou%d not ,e !an&ed. i+. .+er%oaded o#erators "o%%ow te s-nta1 ru%es o" te ori&ina% o#erators. +. Te- !annot ,e o+erridden. :1 5hat are the di33erent t0/e o3 con2erion6 Te di""erent t-#es o" !on+ersions are, i. Lasi! t-#e to C%ass t-#e. ii. C%ass t-#e to Lasi! t-#e. iii. C%ass t-#e to C%ass t-#e. i+. Lasi! t-#e to Lasi! t-#e <1 5rite the 0ntaB to con2ert 3ro" cla to *aic t0/e1 Te s-nta1 to !on+ert "ro' !%ass to ,asi! t-#e is, .#erator t-#eHna'e ( ) @ JJJJ 9un!tion state'ents? JJJJ C .>1 5hat are the condition to ati30 the t0/e catin# 3!nction6 Te !onditions to satis"- te t-#e !astin& "un!tion are, i. It 'ust ,e a !%ass 'e',er. ii. It 'ust not s#e!i"- a return t-#e. iii. It 'ust not a+e an- ar&u'ents. ..1 5hat i Friend 3!nction6 5rite the 0ntaB. A "un!tion tat as a!!ess to te #ri+ate 'e',er o" te !%ass ,ut is not itse%" a 'e',er o" te !%ass is !a%%ed "riend "un!tions. 9riend "un!tion is #re!eded ,- te ke-word M3riendN. Te &enera% "or' is6 3riend datat-#e "un!tion na'e (o,/e!t de!)? .&1 5rite o"e /ro/ertie o3 3riend 3!nction1 Te #ro#erties o" "riend "un!tion are, i. 9riend "un!tion is not in te s!o#e o" te !%ass to wi! it as ,een de!%ared as "riend. Hen!e it !annot ,e !a%%ed usin& te o,/e!t o" tat !%ass. ii. Usua%%- it as o,/e!t as ar&u'ents. iii. It !an ,e de!%ared eiter in te #u,%i! or #ri+ate #art o" a !%ass. i+. It !annot a!!ess 'e',er na'es dire!t%-. It as to use an o,/e!t na'e and dot 'e',ersi# o#erator wit ea! 'e',er na'e. e&6 ( A . 1 ) .-1 5hat i 3!nction o2erloadin#6 Gi2e an eBa"/le1 9un!tion o+er%oadin& 'eans we !an use te sa'e "un!tion na'e to !reate "un!tions tat #er"or' a +ariet- o" di""erent tasks. E1a'#%e6 An o+er%oaded add ( ) "un!tion and%es di""erent data t-#es as sown ,e%ow. // De!%arations int add (int a, int ,)? //add "un!tion wit 2 ar&u'ents o" sa'e t-#e int add (int a, int ,, int !)? //add "un!tion wit O ar&u'ents o" sa'e t-#e .71 5rite at leat 3o!r r!le 3or O/erator o2erloadin#1 4u%es "or .#erator o+er%oadin& are, i. .n%- te e1istin& o#erators !an ,e o+er%oaded. ii. Te o+er%oaded o#erator 'ust a+e at %east one o#erand tat is o" user de"ined data t-#e. iii. Te ,asi! 'eanin& o" te o#erator sou%d not ,e !an&ed. i+. .+er%oaded o#erators "o%%ow te s-nta1 ru%es o" te ori&ina% o#erators. +. Te- !annot ,e o+erridden. .%1 5hat i "eant *0 tatic in2ocation o3 2irt!al 3!nction6 It is #ossi,%e to !a%% +irtua% "un!tion usin& as o,/e!t o" te !%ass or usin& a s!o#e reso%ution o#erator. In tat !ase, +irtua% "un!tion is in+oked stati!a%%-. Tis is known as stati! in+o!ation o" te +irtua% "un!tion. Te s-nta1 "or stati! in+o!ation o" +irtua% "un!tion is, #ointer$o,/e!t !%assna'e66+irtua%$"un!tion()? .81 5hat i "eant *0 inheritance6 Ineritan!e is te #ro!ess ,- wi! o,/e!ts o" one !%ass a!2uire te #ro#erties o" anoter !%ass. It su##orts te !on!e#t o" ierar!i!a% !%assi"i!ation. It #ro+ides te idea o" reusa,i%it-. 0e !an add additiona% "eatures to an e1istin& !%ass witout 'odi"-in& it ,- deri+in& a new !%ass "ro' it. .91 5hat i "eant *0 2ii*ilit0 "ode6 Mention the 2ii*ilit0 "ode a2aila*le1 Visi,i%it- 'ode s#e!i"ies weter te "eatures o" te ,ase !%ass are #ri+ate%- deri+ed or #u,%i!%- deri+ed. Tere are tree +isi,i%it- 'odes. Te- are, i. Pri+ate ii. Pu,%i! iii. Prote!ted .:1 5hat are the t0/e in inheritance6 Te t-#es in ineritan!e are, i. Sin&%e ineritan!e ii. Mu%ti#%e ineritan!e iii. Mu%ti%e+e% ineritan!e i+. Hierar!i!a% ineritan!e +. H-,rid ineritan!e Unit III 2 Mark Questions and Answers .1 5hat are the 2ario! traditional error handlin# "ethod6 Te +arious traditiona% error and%in& 'etods are, i. 4eturnin& error nu',er. ii. G%o,a% "%a& 'ani#u%ation. iii. A,nor'a% ter'ination. &1 5hat i the i"/ortance o3 eBce/tional handlin#6 Te i'#ortan!e o" e1!e#tiona% and%in& is, i. Di+ide te error and%in&. ii. To #ro+ide un!onditiona% ter'ination and #ro&ra''er #re"erred ter'ination iii. 9or se#aratin& error re#ortin& and error and%in&. i+. To so%+e te o,/e!t destro- #ro,%e'. -1 5hat are the three 'e0)ord !ed 3or eBce/tion handlin# "echani"6 Te tree ke-words used "or e1!e#tion and%in& 'e!anis' are, i. tr- "or indi!atin& #ro&ra' area were te e1!e#tion !an ,e trown. ii. trow "or trowin& an e1!e#tion. iii. !at! "or takin& an a!tion "or s#e!i"i! e1!e#tion. 71 5hat i the !e o3 !neB/ected 3!nction6 Te une1#e!ted "un!tion is !a%%ed wen a "un!tion trows an e1!e#tion not %isted in its e1!e#tion s#e!i"i!ation. Interna%%-, it !a%%s te ter'inate "un!tion to ter'inate te #ro&ra' e1e!ution. Te "un!tion set une1#e!ted () is used to !a%% our own une1#e!ted "un!tion in #%a!e o" te ,ui%t$in une1#e!ted "un!tion. %1 5hat are the challen#e in the eBce/tion handlin# "echani"6 Te !a%%en&es in te e1!e#tion and%in& 'e!anis' are, i. 9indin& #ro#er !at! ,%o!k. ii. 9indin& #ro#er !at! ,%o!k "or #o%-'or#i! o,/e!t. iii. La!ktra!kin& ti%% te ,e&innin& o" te tr- ,%o!k. 81 5h0 Te"/late are !ed in C??6 Te Te'#%ates are used to de+e%o# reusa,%e so"tware !o'#onent su! as "un!tions, !%asses, et!. Te'#%ates a%%ow te !onstru!tion o" a "a'i%- o" te'#%ates "un!tions and !%asses to #er"or' te sa'e o#erations on di""erent data t-#es. 91 5hat are r!le 3or in2alid 3!nction te"/late declaration6 Te ru%es "or in+a%id "un!tion te'#%ate de!%aration are, i. Po$ar&u'ent te'#%ate "un!tion. ii. Te'#%ateQt-#e ar&u'ent unused. iii. Usa&e o" #artia% nu',er o" te'#%ate ar&u'ents. :1 5rite the 0ntaB 3or 3!nction Te"/late1 Te s-nta1 "or "un!tion Te'#%ate is, Te'#%ate :!%ass T, JJ..8 4eturn T-#e 9unHPa'e (ar&u'ents) @ JJJ. // ,od- o" te te'#%ate C <1 5hat are the error handlin# 3!nction in C??6 Te error and%in& "un!tion in C55 is, i. ii. iii. i+. eo"() "ai%() ,ad() &ood() .>1 5hat are the r!le 3or 2irt!al 3!nction6 Te ru%es "or +irtua% "un!tion are, i. ii. iii. Te- !annot ,e stati! 'e',ers. Te- are a!!ess ,- usin& o,/e!t #ointers. A +irtua% "un!tion !an ,e a "riend o" anoter !%ass. ..1 5hat are Strea"6 Strea' is a 'e!anis', wi! su##%ies te in#ut data to a #ro&ra' and #resents te #ro!essed data in te desired "or'. .&1 5hat are the 3ile trea" clae in C??6 Te "i%e strea' !%asses in C55 are, "i%e,u" "strea',ase o"strea' "strea' .71 ;it o!t the )a0 o3 Cla Te"/late inheritance1 Te wa-s o" C%ass Te'#%ate ineritan!e are, i. Deri+e a !%ass te'#%ate "ro' a ,ase !%ass, wi! is a te'#%ate !%ass ii. Deri+e a !%ass te'#%ate "ro' te ,ase !%ass , wi! is a te'#%ate !%ass, add 'ore te'#%ate 'e',ers in te deri+ed !%ass iii. Deri+e a !%ass te'#%ate "ro' a ,ase !%ass wi! is not a te'#%ate !%ass, and add te'#%ate 'e',ers to tat !%ass i+. Deri+e a !%ass te'#%ate "ro' a ,ase !%ass wi! is a te'#%ate !%ass and restri!t te te'#%ate "eature. .%1 5hat are the three 3ar"atted ICO o/eration clae6 Te tree in#ut/out#ut o#eration !%asses are, i. istrea' Q does "or'atted in#ut. ii. ostrea' Q does "or'atted out#ut. iii. iostrea' $ does "or'atted in#ut and out#ut. .81 5hat are the 3!nction o3 io clae6 Te "un!tions o" ios !%asses are, .91 5hat are "ani/!lator6 Mani#u%ators are s#e!ia% "un!tions tat are s#e!i"i!a%%- desi&ned to 'odi"- te workin& o" a strea'. Te- !an ,e e',edded in te I/. state'ents to 'odi"- te "or' #ara'eters o" a strea'. A%% te #rede"ined 'ani#u%ators are de"ined in te eader "i%e io'ani#.. .:1 5hat are the "ode !ed 3ile trea" cla6 Te 'odes used "i%e strea' !%ass is, i. in Q o#en "or readin& ii. out Q o#en "or writin& iii. a## Q a%% write o!!ur at end o" "i%e i+. trun! Q trun!ate te "i%e i" a%read- e1its +. no!reate Q o#en "ai%s i" "i%e does not e1its +i. nore#%a!e Q o#en "ai%s i" "i%e a%read- e1its +ii. ,inar- Q o#en as a ,inar- "i%e .<1 5hat i #et () and /!t () 3!nction6 &et() is a 'e',er "un!tion o" a strea' !%ass "strea' and is used to read a sin&%e !ara!ter "ro' a "i%e. #ut() is a 'e',er "un!tion o" a strea' !%ass "strea' and is used to write a sin&%e !ara!ter to te "i%e. &>1 5hat are t)o t0/e o3 3ile /ointer !ed in C??6 Te two t-#es o" "i%e #ointers used in C55 are, i. &et #ointer Q s#e!i"ies a %o!ation "ro' were te !urrent readin& o#eration is initiated ii. #ut #ointer $ s#e!i"ies a %o!ation "ro' were te !urrent writin& o#eration is initiated Unit IV 2 Mark Questions and Answers .1 5hat i Da2a6 Ra+a is a i&$%e+e%, tird &eneration #ro&ra''in& %an&ua&e, %ike C, 9.4T4AP, S'a%%ta%k, Per%, and 'an- oters. You !an use Ra+a to write !o'#uter a##%i!ations tat !run! nu',ers, #ro!ess words, #%a- &a'es, store data or do an- o" te tousands o" oter tin&s !o'#uter so"tware !an do. &1 5hat are the 3eat!re o3 Da2a6 Te "eatures o" Ra+a are, i. Si'#%e. ii. .,/e!t .riented. iii. P%at"or' Inde#endent. i+. 4o,ust. +. Mu%titreaded. +i. Se!ure1 -1 5hat are the 2ario! a//lication o3 Da2a6 Te +arious a##%i!ations o" Ra+a are, i. ii. iii. i+. +. +i. A##%ets Petworkin& Internationa%i3ation Se!urit- .,/e!t seria%i3ation Ra+a Data,ase Conne!ti+it- (RDLC) 71 5hat i "eant *0 2irt!al "achine6 A Ra+a +irtua% 'a!ine (RVM), an i'#%e'entation o" te Ra+a Virtua% Ma!ine S#e!i"i!ation, inter#rets !o'#i%ed Ra+a ,inar- !ode (!a%%ed ,-te!ode) "or a !o'#uterSs #ro!essor (or Tardware #%at"or'T) so tat it !an #er"or' a Ra+a #ro&ra'Ss instru!tions %1 5hat are the t)o co"/onent o3 Da2a /lat3or"6 Te two !o'#onents o" Ra+a #%at"or' are, i. ii. Te Ra+a Virtua% Ma!ine Te Ra+a A##%i!ation Pro&ra''in& Inter"a!e (API) T0/eDe3inition,-teone$,-te si&ned twoSs !o'#%e'ent inte&ersorttwo$,-te si&ned twoSs !o'#%e'ent inte&erintU$ ,-te si&ned twoSs !o'#%e'ent inte&er %on&K$,-te si&ned twoSs !o'#%e'ent inte&er"%oatU$,-te IEEE IDU sin&%e$#re!ision "%oatdou,%eK$,-te IEEE IDU dou,%e$ #re!ision "%oat!ar2$,-te unsi&ned Uni!ode !ara!ter 81 5hat i *0tecode in Da2a6 Ra+a ,-te!ode is te "or' o" instru!tions tat te Ra+a +irtua% 'a!ine e1e!utes. Ea! ,-te!ode o#!ode is one ,-te in %en&t, a%tou& so'e re2uire #ara'eters, resu%tin& in so'e 'u%ti$,-te instru!tions. Pot a%% o" te #ossi,%e 2DV o#!odes are used. 91 5hat i an O*+ect6 An o,/e!t !onsists o" data and "un!tions known as methods wi! use or !an&e te data. (Metods are si'i%ar to #ro!edures or "un!tions in oter %an&ua&es.) .,/e!ts o" te sa'e kind are said to a+e te sa'e t-#e or ,e in te sa'e !%ass. A class de"ines wat data !an ,e in an o,/e!t, and wat o#erations are #er"or'ed ,- te 'etods. .ne or 'ore o,/e!ts !an ,e !reated or WinstantiatedA "ro' a !%ass. :1 5hat i an O*+ect and ho) do 0o! allocate "e"or0 to it6 .,/e!t is an instan!e o" a !%ass and it is a so"tware unit tat !o',ines a stru!tured set o" data wit a set o" o#erations "or ins#e!tin& and 'ani#u%atin& tat data. 0en an o,/e!t is !reated usin& new o#erator, 'e'or- is a%%o!ated to it. <1 5hat are di33erent t0/e o3 acce "odi3ier6 Te di""erent t-#es o" a!!ess 'odi"iers are, i. ii. iii. i+. #u,%i!6 An- tin& de!%ared as #u,%i! !an ,e a!!essed "ro' an-were. #ri+ate6 An- tin& de!%ared as #ri+ate !anNt ,e seen outside o" its !%ass. #rote!ted6 An- tin& de!%ared as #rote!ted !an ,e a!!essed ,- !%asses in te sa'e #a!ka&e and su,!%asses in te oter #a!ka&es. de"au%t 'odi"ier 6 Can ,e a!!essed on%- to !%asses in te sa'e #a!ka&e. .>1 5hat i "ethod o2erloadin# and "ethod o2erridin#6 Metod o+er%oadin&6 0en a 'etod in a !%ass a+in& te sa'e 'etod na'e wit di""erent ar&u'ents is said to ,e 'etod o+er%oadin&. Metod o+erridin&6 0en a 'etod in a !%ass a+in& te sa'e 'etod na'e wit sa'e ar&u'ents is said to ,e 'etod o+erridin&. ..1 ;it o!t the /ri"iti2e t0/e in Da2a1 Te se+en #ri'iti+e t-#es are %isted in te "o%%owin& ta,%e6 .&1 5hat i Strin#6 A Strin& is a !%ass used to store a se2uen!e o" !ara!ters in Ra+a. Strin&s are !onstant. Teir +a%ues !annot ,e !an&ed a"ter te- are !reated. Strin& ,u""ers su##ort 'uta,%e strin&s. Le!ause Strin& o,/e!ts are i''uta,%e te- !an ,e sared. E1a'#%e6 Strin& str < Ta,!T? .-1 5hat i an arra06 An arra- is a s#e!ia% o,/e!t !ontainin& a &rou# o" !onti&uous 'e'or- %o!ations tat a+e te sa'e na'e and te sa'e t-#e and a se#arate +aria,%e !ontainin& an inte&er !onstant e2ua% to te nu',er o" arra- e%e'ents. Te e%e'ents o" Ra+a arra-s are nu',ered startin& "ro' >. E1a'#%e6 dou,%e 1 XY? // !reate an arra- re"eren!e 1 < new dou,%e XDY? // !reate arra- o,/e!t .71 5hat are the "ethod !ed in Strin# cla6 Te 'etods used in Strin& !%ass are, i. ii. iii. i+. +. !arAt(int inde1) !o'#areTo(Strin& anoterStrin&) !on!at(Strin& str) !o#-Va%ue."(!arXY data) e2ua%s(.,/e!t an.,/e!t) .%1 5hat are /ac'a#e6 A Ra+a #a!ka&e is a 'e!anis' "or or&ani3in& Ra+a !%asses into na'es#a!es si'i%ar to te 'odu%es o" Modu%a. Ra+a #a!ka&es !an ,e stored in !o'#ressed "i%es !a%%ed RA4 "i%es, a%%owin& !%asses to down%oad "aster as a &rou# rater tan one at a ti'e. .81 ;it o!t the Da2a /ac'a#e1 Te Ra+a #a!ka&es are, i. ii. iii. i+. +. +i. /a+a.%an& /a+a.io /a+a.awt /a+a.net /a+a.a##%et /a+a.r'i .91 5h0 Da2a !e Unicode6 Ra+a use Uni!ode to re#resent a !ara!ter. Uni!ode de"ines a "u%%- internationa% !ara!ter set tat !an re#resent a%% o" te !ara!ters "ound in a%% u'an %an&ua&es. .:1 5hat i Cla/ath6 Te C%ass#at is an ar&u'ent we !an set eiter on te !o''and$%ine, or trou& an en+iron'ent +aria,%e tat te%%s te Ra+a Virtua% Ma!ine were to %ook "or user de"ined !%asses and #a!ka&es wen runnin& Ra+a #ro&ra's. .<1 5hat i Gar*a#e collection6 Te Gar,a&e !o%%e!tion is te #ro!ess tat is used to "ree te 'e'or- o" te o,/e!ts tat are no %on&er in use. 0en a #ro&ra' sto#s re"eren!in& an o,/e!t, it is not re2uired an- 'ore and !an ,e de%eted. Te s#a!e tat is used ,- te o,/e!t is re%eased "or use ,- anoter o,/e!t. &>1 5hat are Neted clae6 A nested !%ass is a !%ass de"ined as a 'e',er o" anoter !%ass. Te s!o#e o" nested !%ass is ,ounded ,- te s!o#e o" its en!%osin& !%ass. Te nested !%ass as a!!ess to te 'e',ers o" its en!%osin& !%ass in!%udin& #ri+ate 'e',ers. Unit V 2 Mark Questions and Answers .1 5hat do 0o! "ean *0 inheritance6 A su,!%ass inerits +aria,%es and 'etods "ro' its su#er!%ass and a%% o" its an!estors. Te su,!%ass !an use tese 'e',ers as is, or it !an ide te 'e',er +aria,%es or o+erride te 'etods. &1 5hat are the ad2anta#e o3 inheritance6 Te ad+anta&es o" ineritan!e are, i. It #er'its !ode reusa,i%it-. ii. 4eusa,i%it- sa+es ti'e in #ro&ra' de+e%o#'ent. iii. It en!oura&es te reuse o" #ro+en and de,u&&ed i&$2ua%it- so"tware, tus redu!in& #ro,%e' a"ter a s-ste' ,e!o'es "un!tiona%. -1 5hat Me"*er Doe a S!*cla Inherit6 A su,!%ass inerits a%% o" te 'e',ers in its su#er!%ass tat are a!!essi,%e to tat su,!%ass un%ess te su,!%ass e1#%i!it%- ides a 'e',er +aria,%e or o+errides a 'etod. Pote tat !onstru!tors are not 'e',ers and are not inerited ,- su,!%asses. 71 5hat are Enca/!lation$ Inheritance and Pol0"or/hi"6 i. En!a#su%ation is te 'e!anis' tat ,inds to&eter !ode and data it 'ani#u%ates and kee#s ,ot sa"e "ro' outside inter"eren!e and 'isuse. ii. Ineritan!e is te #ro!ess ,- wi! one o,/e!t a!2uires te #ro#erties o" anoter o,/e!t. iii. Po%-'or#is' is te "eature tat a%%ows one inter"a!e to ,e used "or &enera% !%ass a!tions. %1 5hat i the !e o3 !/er 'e0)ord6 A Ra+a(TM) #ro&ra''in& %an&ua&e ke-word used to a!!ess 'e',ers o" a !%ass inerited ,- te !%ass in wi! it a##ears. 81 5hat do "ean *0 o2erridin# "ethod6 Te a,i%it- o" a su,!%ass to o+erride a 'etod in its su#er!%ass a%%ows a !%ass to inerit "ro' a su#er!%ass wose ,ea+ior is T!%ose enou&T and ten su##%e'ent or 'odi"- te ,ea+ior o" tat su#er!%ass. 91 ;it o!t the 2ario! t0/e o3 inheritance1 Te +arious t-#es o" ineritan!e are, i. Si'#%e ineritan!e $ .ne ,ase !%ass and one deri+ed !%ass ii. Mu%ti%e+e% ineritan!e $ a su, !%ass deri+ed "ro' anoter su, !%ass iii. Hierar!i!a% ineritan!e $ two or 'ore su, !%ass a+e te sa'e ,ase !%ass :1 De3ine Inter3ace1 An Inter"a!e is de"ined as a na'ed !o%%e!tion o" 'etod de"initions (witout i'#%e'entations). An inter"a!e !an a%so de!%are !onstants. A%% te 'etods de!%ared in te inter"a!e are a,stra!t 'etods ,- de"au%t. And a%% te data 'e',ers are stati! "ina% 'e',ers. <1 @o) "!lti/le inheritance i i"/le"ented in +a2a6 A !%ass !an i'#%e'ent 'ore tan one inter"a!e (te Ra+a #%at"or' su##orts 'u%ti#%e ineritan!e "or inter"a!es), so te implements ke-word is "o%%owed ,- a !o''a$se#arated %ist o" te inter"a!es i'#%e'ented ,- te !%ass. .>1 5hat i an EBce/tion6 An E1!e#tion is an e+ent tat o!!urs durin& te e1e!ution o" a #ro&ra' tat disru#ts te nor'a% "%ow o" instru!tions durin& te e1e!ution o" a #ro&ra'. ..1 @o) an EBce/tion i handled in +a2a6 A #ro&ra' !an !at! e1!e#tions ,- usin& a !o',ination o" te tr-, !at!, and "ina%%- state'ents. Te tr- state'ent identi"ies a ,%o!k o" !ode in wi! an e1!e#tion !an o!!ur. Te !at! state'ent identi"ies a ,%o!k o" !ode, known as an e1!e#tion and%er tat !an and%e a #arti!u%ar t-#e o" e1!e#tion. .&1 5hat i the !e o3 3inall0 *loc'6 Te "ina%%- state'ent identi"ies a ,%o!k o" !ode tat !%eans u# re&ard%ess o" weter an e1!e#tion o!!urred witin te tr- ,%o!k. A tr- state'ent 'ust ,e a!!o'#anied ,- at %east one !at! state'ent or a "ina%%- state'ent and 'a- a+e 'u%ti#%e !at! state'ents. .-1 @o) Thread are created in Da2a6 Teads are !reated in two wa-s, i. e1tendin& te Tread !%ass ii. i'#%e'entin& 4unna,%e inter"a!e. .71 5hat i Thread /ool6 A Tread #oo% is a 'ana&ed !o%%e!tion o" treads tat are a+ai%a,%e to #er"or' tasks. Tread #oo%s usua%%- #ro+ide, i. I'#ro+ed #er"or'an!e wen e1e!utin& %ar&e nu',ers o" tasks due to redu!ed #er$task in+o!ation o+eread. ii. A 'eans o" ,oundin& te resour!es, in!%udin& treads, !onsu'ed wen e1e!utin& a !o%%e!tion o" tasks. .%1 De3ine Dead ;oc'1 A Dead *o!k is de"ined as a s#e!ia% t-#e o" error tat re%ates s#e!i"i!a%%- to 'u%titaskin& is dead %o!k, wi! o!!urs wen two treads a+e a !ir!u%ar de#enden!- on a #air o" s-n!roni3ed o,/e!ts. .81 5hat do 0o! "ean *0 Thread Sched!lin#6 E1e!ution o" 'u%ti#%e treads on a sin&%e CPU in so'e order is !a%%ed Tread s!edu%in&. Te Ra+a runti'e en+iron'ent su##orts a +er- si'#%e, deter'inisti! s!edu%in& a%&orit' !a%%ed fixed-priority scheduling. Tis a%&orit' s!edu%es treads on te ,asis o" teir #riorit- re%ati+e to oter 4unna,%e treads. .91 5hat i the !e o3 Data in/!t and o!t/!t trea"6 Data in#ut and out#ut Strea's are used to read or write #ri'iti+e data t-#es in a 'a!ine$inde#endent "or'at. .:1 5hat i the !e o3 E!33ered Strea"6 Lu""ered strea's, ,u""er data wi%e readin& or writin&, tere,- redu!in& te nu',er o" a!!esses re2uired on te ori&ina% data sour!e. Lu""ered strea's are t-#i!a%%- 'ore e""i!ient tan si'i%ar non,u""ered strea's and are o"ten used wit oter strea's. .<1 5hat i 3iltered Strea"6 A "i%tered strea' "i%ters data as its ,ein& read "ro' or written to te strea'. Te /a+a.io #a!ka&e #ro+ides a set o" a,stra!t !%asses tat de"ine and #artia%%- i'#%e'ent "i%ter strea's.
Dimensionality Reduction in Automated Evaluation of Descriptive Answers Through Zero Variance, Near Zero Variance and Non Frequent Words Techniques - A Comparison