12
Object‐Oriented Analysis, Design and Programming Re‐examination Medialogy Semester 4 Wednesday 12 August 2009 09:00 – 11:00 Instructions You have 2 hours to complete this examination. Neither written material nor electronic equipment may be brought into the examination room. There are 20 questions. The maximum score on this examination is 100 marks. Each question is worth 5 marks. You must get at least 50 marks in order to pass. Answers must be in English or Danish. Question 1 With reference to the Ariane 5 disaster, which one of the following statements is true? A. They used an expensive new system instead of modifying an existing one. B. The software was insufficiently flexible and not designed to be future‐ proof. C. Software was reused without properly testing it in its new context. D. The failure was caused by software trying to convert a 16‐bit integer value for a vertical velocity component into a 64‐bit floating‐point value. Question 2 According to the Standish Group CHAOS report (1994) which one of the following was the biggest cause of software project failure? A. The use of programming languages that do not properly support object‐oriented design. B. Failures in requirements capture. C. Failure to reuse existing software (“re‐inventing the wheel”). D. Insufficient testing. continued

Object‐Oriented Analysis, Design and Programming 20 questions. The maximum score on this examination is 100 marks. Each question is worth 5 marks. • ... two UML diagrams below

  • Upload
    vuthuy

  • View
    218

  • Download
    4

Embed Size (px)

Citation preview

Object‐OrientedAnalysis,DesignandProgramming

Re‐examinationMedialogySemester4Wednesday12August200909:00–11:00

Instructions

• Youhave2hourstocompletethisexamination.• Neitherwrittenmaterialnorelectronicequipmentmaybebrought

intotheexaminationroom.• Thereare20questions.Themaximumscoreonthisexaminationis

100marks.Eachquestionisworth5marks.• Youmustgetatleast50marksinordertopass.• AnswersmustbeinEnglishorDanish.

Question1

WithreferencetotheAriane5disaster,whichoneofthefollowingstatementsistrue?

A. Theyusedanexpensivenewsysteminsteadofmodifyinganexistingone.

B. Thesoftwarewasinsufficientlyflexibleandnotdesignedtobefuture‐proof.

C. Softwarewasreusedwithoutproperlytestingitinitsnewcontext.D. Thefailurewascausedbysoftwaretryingtoconverta16‐bitinteger

valueforaverticalvelocitycomponentintoa64‐bitfloating‐pointvalue.

Question2

AccordingtotheStandishGroupCHAOSreport(1994)whichoneofthefollowingwasthebiggestcauseofsoftwareprojectfailure?

A. Theuseofprogramminglanguagesthatdonotproperlysupportobject‐orienteddesign.

B. Failuresinrequirementscapture.C. Failuretoreuseexistingsoftware(“re‐inventingthewheel”).D. Insufficienttesting.

continued

OOADPRe‐Examination Wednesday12August2009

2

Question3

Whichthreeofthefollowingadjectivesdescribethemodulesinagoodsoftwaresystem?

A. reusableB. cohesiveC. replaceableD. abstract

Question4

StudythefollowingUMLoperationdeclarationandanswerthequestionsthatfollowit.+ computeSum(x : int, y: int) : int

a. Whatistheselectorofthisoperation?b. Whatarethenamesoftheargumentsofthisoperation?c. Whatisthereturntypeofthisoperation?d. Whatisthevisibilityofthisoperation?

Question5

Writedowntheoutputofthefollowingprogram. package dk.aau.imi.med4.ooadp2009.reexam; public class ReExam5 { public static void main(String[] args) { int d = -5; System.out.println(d + d); System.out.println("a" + d + d); System.out.println("a" + (d + d)); } }

Question6

Writedowntheoutputofthefollowingprogram. package dk.aau.imi.med4.ooadp2009.reexam; public class ReExam6 { public static void main(String[] args) { int[] intArray = {1,2,3,4,5}; for(int i = intArray.length - 1; i >= 0; i--) System.out.println(intArray[i]); } }

continued

OOADPRe‐Examination Wednesday12August2009

3

Question7

Inthecontextofadiagrammaticmodellinglanguage,explainthemeaningsofthefollowingterms.Useexampleswhereappropriate.

a. modelelementsb. syntaxc. semantics

Question8

ExplainthedifferencebetweenusingUMLinsketchmodeandblueprintmode.

Question9

ThefollowingshowsthecontentsofafilecalledSimplePoint.java. package dk.aau.imi.med4.ooadp2009.reexam; public class SimplePoint { int x = 1, y = 2; } ThefollowingshowsthecontentsofafilecalledReExam9.java.package dk.aau.imi.med4.ooadp2009.reexam; public class ReExam9 { public static void main(String[] args) { System.out.println(new SimplePoint().x); } } WhatistheoutputwhentheReExam9classisrunasaprogramme?

continued

OOADPRe‐Examination Wednesday12August2009

4

Question10

ThefollowingshowsthecontentsofafilecalledSimplePoint.java. package dk.aau.imi.med4.ooadp2009.reexam; public class SimplePoint { int x = 1, y = 2; } ThefollowingshowsthecontentsofafilecalledReExam10.java.package dk.aau.imi.med4.ooadp2009.reexam; public class ReExam10 { public static void main(String[] args) { SimplePoint p = new SimplePoint(); SimplePoint q = p; q.y *= 2; System.out.println(p.y); } } WhatistheoutputwhentheReExam10classisrunasaprogramme?

continued

OOADPRe‐Examination Wednesday12August2009

5

Question11

ThefollowingshowsthecontentsofafilecalledPoint.java.(Thenumbersatthebeginningsofthelinesarejustlabels–theyarenotpartofthecode.) 1 package dk.aau.imi.med4.ooadp2009.reexam; 2 public class Point { 3 int x, y; 4 public Point(int x, int y) { 5 this.x = x; 6 this.y = y; 7 } 8 } ThefollowingshowsthecontentsofafilecalledReExam11.java.package dk.aau.imi.med4.ooadp2009.reexam; public class ReExam11 { public static void main(String[] args) { Point p = new Point(); System.out.println("x = "+p.x+", y = "+p.y); } } Writedownthecodethatneedstobeinsertedbetweenlines3and4inPoint.javainordertomakeReExam11outputthefollowingwhenitisrun:x = 1, y = 2

continued

OOADPRe‐Examination Wednesday12August2009

6

Question12

StudythefollowingUMLdiagramandanswerthequestionsthatfollowit.

a. WhatkindofUMLdiagramisthis?b. ListtheattributesoftheBookclass.c. ListtheoperationsoftheBookclass.d. HowmanyCopyobjectsareassociatedwitheachLibraryMemberobject?e. DoesthediagramtellusthateachCopyobjecthasnoattributes?Explain

youranswer.

Question13

StudythetwoUMLdiagramsbelowandanswerthequestionsthatfollow.

a. Whichofthetwodiagrams,Diagram1orDiagram2,representsacomposition?

b. HowmanyDegreeprogrammescaneachCoursebeapartof?c. IfaSquareobject,s,isassociatedwithaChessBoardobject,C,what

happenstosifCisdeleted?d. IfaCourseobject,c,isassociatedwithaDegreeprogrammeobject,D,

whathappenstocifDisdeleted?e. Isthetypeofrelationshipthatexistsbetweenfootballplayersandthe

teamstheyplayforanexampleofanaggregationoracomposition?Explainyouranswer.

continued

Diagram0

Diagram0

OOADPRe‐Examination Wednesday12August2009

7

Question14

StudythefollowingUMLdiagram.

Whichofthefollowingstatementsaretrue?(Theremaybemorethanonetruestatement.)

a. AisasuperclassofBb. AisaspecializationofBc. Acontainsonlyoneattributewhichisc.d. Bcontainsthreeattributes:a,bandc.e. Theoperatione()inBisoverriddeninclassA.f. Theoperationd(x:int)inBisoverloadedinclassA.g. ClassAcontainsatleastthreeattributes:a,bandc.h. Theoperationd(x:int)inBisoverriddeninclassA.i. Theoperatione()inBisoverloadedinclassA.j. AttributesaandbareinheritedbyclassA.

continued

OOADPRe‐Examination Wednesday12August2009

8

Question15

Studythefollowingdiagramandanswerthequestionthatfollowsit.

Whichofthefollowingstatementsaretrue?(Oneormorestatementsmaybetrue.)

a. Aisanactor.b. disanasynchronousmessage.c. Aisaparticipant.d. TheliveactivationofBstartsatthepointatwhichthearrowdtouches

B’slifeline.e. eisavaluereturnedbythemethodcalledbythemessaged.f. Bisaclass.g. ThediagramisanexampleofaUMLactivitydiagram.h. Timeincreasesasonemovesfromlefttorightinthediagram.i. disasynchronousmessage.j. Bisanobject.

continued

OOADPRe‐Examination Wednesday12August2009

9

Question16

StudythefollowingthreediagramswhichdescribethestateofaCopyobjectinalibrarysoftwaresystem.Thenanswerthequestionsbelowthediagrams.

a. Whatsortofdiagramsarethese?b. Whichtwoofthethreediagramsareequivalent?c. Towhatdoes“self”referin“book.copyReturned(self)”?d. Indiagram(3),whathappenswhenaCopyobjectthatisonloanreceives

a“returned()”message?e. Inthetext“entry/book.copyReturned(self)”,whatistheactionandwhat

istheevent?

continued

OOADPRe‐Examination Wednesday12August2009

10

Question17

Studythefollowingdiagramsandanswerthequestionsthatfollowthem.

a. Whattypeofdiagramsarethese?b. Thereisonetimesignalinthesediagrams.Whatisitslabel?c. Thereisonesendsignalinthesediagrams.Whatisitslabel?d. Underwhatconditionsisanordercancelled?e. Underwhatconditionsdoesthesystemstartlisteningforapaymenttobe

received?f. Howoftenisthemetrereadingread?

Question18

StudythefollowingthreeclassdefinitionsandwritedowntheoutputgeneratedwhenReExam18isrun,assumingthatthethreeclassesaredefinedinseparatefilesinthesamepackage.

public class SimplePoint { int x = 1, y = 2;

} public class Simple3DPoint extends SimplePoint { int z = 3; } public class ReExam18 { public static void main(String[] args) { Simple3DPoint p = new Simple3DPoint(); p.x += 2; System.out.println("x = "+p.x+", y = "+p.y+", z =

"+ p.z); } }

continued

OOADPRe‐Examination Wednesday12August2009

11

Question19

Writedowntheoutputofthefollowingprogram.

public class Boop { private static int nextId = 0; private int id = 0; public Boop() { id = ++nextId; } public int getId() { return id; } public static void main(String[] args) { for(int i = 5; i >= 0; i--) System.out.println(new Boop().getId()); } } continued

OOADPRe‐Examination Wednesday12August2009

12

Question20

Writedowntheoutputofthefollowingprogram. package dk.aau.imi.med4.ooadp2009.reexam; public class Exceptions { static class JumpException extends Exception { private static final long serialVersionUID = 1L; public String getMessage() { return "JumpException thrown!"; } } private static void countDown() throws JumpException { for(int i = 5; true; i--) { if (i > 0) System.out.println(i); else throw new JumpException(); } } public static void main(String[] args) { try { try { countDown(); } catch(JumpException e) { System.out.println(e.getMessage()); countDown(); } } catch(JumpException e) { System.out.println(e.getMessage()); } } }

ENDOFEXAMINATION