Transcript

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


Recommended