Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
hard

Integrating Transit Modules

Mark
< Prev
Next >

A transit information service uses two independently developed modules. Module A provides getRoute(start, end), which returns a list of integer stop IDs. Module B provides printRoute(stopNames), which requires a list of string names to display the route.

A developer writes the following code to integrate the modules, using a helper function getStopName(id) that returns a string:

route <- getRoute(“North”, “South”)

names <- [] ; FOR EACH stop IN route { APPEND(names, getStopName(stop)) } ; printRoute(route)

Assume getRoute(“North”, “South”) returns the list [12, 45] and getStopName correctly returns “Elm” and “Oak”.

If the developer executes this sequence, what data is passed to printRoute and how does it affect the integration?

A

It passes [], which violates Module B’s interface because the loop fails to modify the route list.

B

It passes [12, 45], which violates Module B’s interface because it provides integers instead of strings.

C

It passes [“Elm”, “Oak”], which successfully integrates the modules according to the stated interfaces.

D

It passes [“Elm”, “Oak”], which violates Module B’s interface because it provides a list instead of a single string.

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Instagram: @_apfive_|Privacy Policy|