Cs 125 Midterm 1 FA 2012 Solutions

Home - Cs 125 Midterm one particular FA 2012 - Cs 125 Midterm 1 FA 2012 Solutions
 Cs a hundred and twenty-five Midterm you FA 2012 Solutions Composition

IfВ youВ feelВ confident, В pleaseВ changeВ theВ answersВ toВ whatВ youВ thinkВ isВ right, В otherwise, В xuseВ CtrlВ­AltВ­MВ toВ comment. В В

0125В

AllВ codingВ questionsВ areВ onВ theВ codeshareВ link. В

MultipleВ ChoiceВ

1 .

dВ isВ correct

//В d)В derefrencingВ garbage? В ieВ noВ memoryВ actuallyВ allocatedВ В //В 2 .

c)В В В В В В В В В В В В В В В В В В В В В В В В В В В В В В В //В В d)В neitherВ winner()В norВ loser()В canВ makeВ theВ assignmentВ //IВ thinkВ 2В isВ c, В becauseВ itВ isВ aВ virtualВ functionВ butВ notВ aВ pureВ virtualВ function, В soВ weВ canВ callВ itВ fromВ theВ baseВ classВ В

3.

c)В anВ insidiousВ runtimeВ memoryВ errorВ В CANВ SOMEONEВ EXPLAINВ WHYВ becauseВ compilerВ doesn'tВ knowВ thatВ b'sВ memoryВ isВ freedВ beforeВ theВ codeВ isВ actuallyВ running. В soВ itВ hasВ toВ beВ aВ runtimeВ error. В dereferencingВ toВ NULLВ alwaysВ resultsВ inВ aВ runtimeВ errorВ 4.

a)В ThisВ codeВ isВ horribleВ becauseВ itВ returnsВ theВ memoryВ addressВ ofВ aВ localВ variableВ 5.

c)В 15В isВ sentВ toВ standardВ outВ В В //d)В spring09В MC3В hasВ aВ similarВ question, В check? В //itВ shouldВ beВ 15, В IВ ranВ theВ code. В

six.

c)В GrowlВ Run! В StompВ stompВ stompВ В­В JustВ gotВ wordВ fromВ aВ TAВ thatВ byВ callingВ BearВ bearyНѕ, В weВ areВ initializingВ bearyВ usingВ theВ defaultВ constructorВ CANВ SOMEONEВ EXPLAINВ HOWВ STOMPВ STOMPВ STOMPВ PRINTS? В MyВ guessВ isВ thatВ StompВ stompВ stompВ printsВ becauseВ bearyВ goesВ outВ ofВ scopeВ andВ needsВ toВ beВ deleted, В soВ theВ destructorВ isВ calledВ В

six.

b) operator= ­ must be set sbased on ​

Rule of 3​

Shouldn'tВ aВ noВ parameterВ constructorВ

needВ toВ beВ implemented? В OtherwiseВ you'dВ neverВ beВ ableВ toВ actuallyВ createВ anВ objectВ ofВ thatВ classВ

8.

c)

9.

d)В PartsВ aВ andВ bВ causeВ compileВ errorsВ becauseВ theВ createВ modPNG's//В What'sВ wrongВ withВ (a)В though? В CallingВ aВ constructorВ ofВ anВ abstractВ baseВ classВ isВ notВ allowedВ (thereВ isВ nothingВ toВ initialize). В В

//youВ can'tВ doВ " modPNGВ a” sinceВ itВ isВ anВ abstractВ baseВ classВ sinceВ itВ hasВ aВ pureВ virtualВ В function. В //В YouВ can'tВ createВ anВ objectВ fromВ anВ abstractВ classВ butВ youВ canВ createВ aВ ptrВ toВ pointВ toВ aВ derivedВ class. В

10....

Related