CSE Final Exam Solutions

download CSE  Final Exam  Solutions

of 11

Transcript of CSE Final Exam Solutions

  • 8/9/2019 CSE Final Exam Solutions

    1/11

    CSE 219 – Spring 2011 – FINAL Exam – Group 0 – Solutions

    Tuesda! "a 1#! 2011

    Name$ First Last

    Student I% & ''''''''''''''''''''''''''''''''' 

    • Please show your ID when requested.

    • Please leave at least one seat between yourself and the person next to you.

    • Use a #2 Pencil to fill in the appropriate bubble on your answer sheet.

    • Fill in one answer per question

    •  No boos! notes! or electronic equip"ent can be used durin the exa".

    • An C(EATING )ill result in an F as )ell as *eing )ritten+up on a,ademi, dis-onest.

    FI/ST$

    • $rite and fill in the bubbles for your full na"e on the answer sheet

    • $rite and fill in the bubbles for your ID Nu"ber on the answer sheet

    • In the %&'(D) *' )DU+, field! fill in the bubble correspondin to you exa" version # -/01

    For all questions! select the best  answer fro" the choices provided

    ATTENTIN$ ae sure your exa" has 10 pages and all 50 questions.

    +3) 245 6 3prin 244 6 Fall )xa" 6 &roup 6 3olutions 4

  • 8/9/2019 CSE Final Exam Solutions

    2/11

    uestion 1

    $hat ter" best  describes %a description of a proble" and its solution that can apply to "any si"ilar 

     prora""in situations,.

    (1 (bstraction

    71 Desin Pattern

    +1 )nu"eration

    D1 &enerics

    )1 Poly"orphis"

    uestion 2

    Instance variables are stored inside what se"ent of "e"ory8

    (1 +all 3tac 

    71 &lobal

    +1 9eap

    D1 :ext

    )1 (ll of the above

    uestion

    $hich of the followin ;ava technoloies can adversely affect perfor"ance if overused in ones prora"8

    (1 )xception handlin71 Inheritance

    +1 ethod callin

    D1 (ll of the above

    )1 None of the above

    uestion 3

    :he 3oftware Develop"ent

  • 8/9/2019 CSE Final Exam Solutions

    3/11

    uestion #

    For ClassWithSyntaxError as defined below! which line of code is the source of a syntax error8

    (1 >71 42

    +1 4@

    D1 4A

    )1 4?

    uestion 6

    In lecture we taled about lass/box testin and how it tests all paths throuh a "ethod definition. For theglass7ox"et-od below! how "any paths are there throuh this "ethod8

    (1 =

    71 >

    +1 A

    D1 ?

    )1 5

    +3) 245 6 3prin 244 6 Fall )xa" 6 &roup 6 3olutions 0

    1. 

    2. 

    3. 

    4. 

    5. 6. 

    7. 

    8. 

    9. 

    10.

    11.

    12.

    13.

    14.

    15.

    16.

    17.

    18.

    19.

    20.

    21.

     public class ClassWithSyntaxError

     public ClassWithSyntaxError!int x"

    try

      init!x"#  t$st!x"#

      %

      catch!Exc$ption $"

      $.printStac&'rac$!"# %

     %

     public (oi) init!int i" thro*s Exc$ption

      i+ !i , 0" thro* n$* Exc$ption!"#

      $ls$ thro* n$* -unti$Exc$ption!"#

     %

     public (oi) t$st!)oubl$ )" thro*s -unti$Exc$ption

      i+ !) , 0" thro* n$* Exc$ption!"#

      $ls$ thro* n$* -unti$Exc$ption!"#

     %

    %

     public (oi)  glassBoxMethod(int x, int y)

    { i+ (y == 0) r$turn;

    $ls$ i+ (x < 0) {

      i+ (y < 0) {

      System.out.println("A");

     

      $ls$ {

      System.out.println("B");

     

    $ls$ i+ (x == 0){  i+ (y < 0){

      System.out.println("!");

     

    $ls$ i+ (y 0){

      System.out.println("#");

  • 8/9/2019 CSE Final Exam Solutions

    4/11

    uestion 9

    (t what stae is redesinin a software syste" the least expensive8

    (1 Deploy"ent 3tae

    71 Desin 'eview 3tae

    +1 Profilin 3tae

    D1 Interation 3tae

    )1 None of the above! they are all equally expensive

    uestion 10

    $hich of the followin could be described as input to a "ethod8

    (1 Instance Bariables

    71 ethod (ru"ents

    +1 3tatic Bariables

    D1 (ll of the above

    )1 None of the above

    uestion 11

    $hich of the followin desin patterns does not use inheritance as part of its i"ple"entation8

    (1 Factory

    71 Iterator +1 3inleton

    D1 3tate

    )1 3tratey

    uestion 12

    In 9$ 4 we created a prora" that e"ployed B+ for loadin and "anipulatin D7F files. $hat class

     played the role of %, in B+ in that prora"8 -note this is specific to the 3prin 244 9$1

    (1 (ction

  • 8/9/2019 CSE Final Exam Solutions

    5/11

    uestion 14

    $hen usin ;Unit! one typically calls static "ethods in what class to co"pare actual and expected values8

    (1 (ssert

    71 ;Unit

    +1 *bect

    D1 3trin

    )1 3yste"

    uestion 15

    $hich of the followin can an interface have8

    (1 (bstract variable

    71 +oncrete "ethod

    +1 +onstructor

    D1 Instance variable

    )1 3tatic final constant

    uestion 1#

    $hich of the followin best describes the obective of a sinle U< Use +ase Diara"8

    (1

  • 8/9/2019 CSE Final Exam Solutions

    6/11

    uestion 21

    In 9$ 4! when loadin in the D7F file! we stored each row of table data inside what type of obect8 -note

    this is specific to the 3prin 244 9$1

    (1 D7FField

    71 D7F'ecord

    +1 D7F'ow

    D1 9ashap

    )1 :reeap

    uestion 22

    In 9$ 2! what type of file stored all the eoraphic infor"ation for our "aps8 -note this is specific to the

    3prin 244 9$1

    (1 D7F

    71 9ashap

    +1 39P

    D1 3B&

    )1 :reeap

    uestion 2

    In 9$s 4 E 2! what type of ;ava strea" did we use to load the data files8 -note this is specific to the3prin 244 9$1

    (1 7uffered'eader 

    71 D7F3trea"

    +1 DataInput3trea"

    D1 *bectInput3trea"

    )1 'ando"(ccess3trea"

    uestion 23

    3uppose you were to desin your own ;ava

    4. 'equire"ents (nalysis

    2. Desin0. )valuate Desin

    @. +ode=. :est! Debu! E Profile +o"ponents

    >. 8A. :est! Debu! E Profile $hole

    ?. Deploy

  • 8/9/2019 CSE Final Exam Solutions

    7/11

    D1 *pti"iin)1 Profilin

    uestion 2#

    $e discussed how developers use a ter" to describe writin code without testin while you o! but rather!

    waitin until lare pieces are written before perfor"in any testin. $hat is this ter" called8

    (1 7lob

    71 Desin to Fail

    +1 Desin to :estD1 onster Prora""in

    )1 3pahetti +ode

    uestion 26

    $hat desin pattern wors by dyna"ically chanin the actual type of an instance variable as needed.

    (1 +o""and

    71 Iterator 

    +1 *bserver 

    D1 3inleton

    )1 3tate

    uestion 29:his se"ester I encouraed usin %narrow interfaces, in desinin connections between "odules. $hich

    desin pattern! typically used as an alternative to static "ethods! uses a prora""in style that can

    easily lead to wide interfaces between classes and "odules8

    (1 Flyweiht

    71 Iterator 

    +1 *bserver 

    D1 3inleton

    )1 3tratey

    uestion 0

    $hat ter" best describes the process of testin a previously worin syste" after a series of chanes8

    (1 'eression :estin71 3a"pled :estin+1 Unit :estin

    D1 Balidation

    )1 Berification

    uestion 1

    $hich of the followin staes of software develop"ent is often perfor"ed by so"eone with little to no

     prora""in experience8

    (1 7eta :estin

    71 'equire"ents (nalysis

    +1 3yste" :estin

    D1 (ll of the above)1 None of the above 6 :hey all require prora""in experience

    uestion 2

    In lecture and in a 9$ description! I referenced the hilarious  Stonehenge scene fro" the fil" This is

     Spinal Tap. $hat is the lesson we learned fro" this scene8

    (1 ( bad desin will result in a bad i"ple"entation

    71 Desin reviews can be unnecessary+1 DonCt dress lie an (ustralianCs niht"are

    D1 DonCt pay software enineers per G

  • 8/9/2019 CSE Final Exam Solutions

    8/11

    )1 &ood coders can "ae up for a bad desin

    +3) 245 6 3prin 244 6 Fall )xa" 6 &roup 6 3olutions ?

  • 8/9/2019 CSE Final Exam Solutions

    9/11

    uestion

    :his se"ester I wanted to brainwash you usin three "antrasH First Define the Proble"! (lways Provide

    Feedbac! andH

    (1 (lways opti"ie your code

    71 +ode opti"iation is "ore i"portant than alorith" selection

    +1 Data structures are overrated

    D1 Desin! then +ode

    )1 Use 3win for all ;ava 3ervlet develop"ent

    uestion 3

    In lecture we stressed how a"ain it is that code written by a ;ava (PI developer 4 years ao is able to

    invoe "ethods we write today. $hat is the pri"ary reason why this is possible8

    (1 &enerics

    71 ;(' files

    +1 ;ava +o"piler is :ype 3afe

    D1 Poly"orphis"

    )1 $(' files

    uestion 4

    $hat could be the actual type of an aru"ent sent to the +ontainer classC s$t/ayoutana$r "ethod8(1 +ontainer 

    71 Flow

  • 8/9/2019 CSE Final Exam Solutions

    10/11

    uestion 9

    $hich of the followin classes would "ae a ood candidate for the Flyweiht Pattern8

    (1 +olor  

    71 D7F:able

    +1 ;Fra"e

    D1 ;:able

    )1 Bector 

    uestion 30

    :his se"ester we learned that ;ava is a stronly typed obect oriented lanuae with auto"atic "e"ory

    "anae"ent syste". $hat other hih/level lanuae have we pointed out has all of these properties in

    co""on with ;ava8

    (1 (sse"bly

    71 +

    +1 +

    D1 +#

    )1 9:<

    uestion 31

    (lorith" expert Donald Gnuth fa"ously said that pre"ature JJJJJJJJJJJJJJ is the root of all evil.(1 Debuin

    71 Deploy"ent

    +1 *pti"iation

    D1 Profilin

    )1 :estin

    uestion 32

    $hat types of exceptions are typically thrown as a result of prora""er error8

    (1 +heced )xceptions

    71 Descendants of )xception but not 'unti"e)xception

    +1 I*)xception

    D1 Passed )xceptions)1 Uncheced )xceptions

    uestion 3

    $hat technoloy! distributed under the (pache license! is fast beco"in the industry standard for Bersion

    +ontrol 3yste"s8(1 +oncurrent +ontrol 3yste"

    71 ;aarta

    +1 'evision +ontrol 3yste"

    D1 3ubversion

    )1 :ortoise

    uestion 33$hat data can the 9Prof tool provide to the developer8

    (1 data structure is best for a iven proble"

    71 the reason for a particular co"piler error 

    +1 which line of code is the source of a loical error 

    D1 which line of code is the source of a runti"e error 

    )1 which "ethods in a prora" tae up the "ost ti"e

    +3) 245 6 3prin 244 6 Fall )xa" 6 &roup 6 3olutions 4

  • 8/9/2019 CSE Final Exam Solutions

    11/11