<div class="xblock xblock-public_view xblock-public_view-vertical" data-has-score="False" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="vertical" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="VerticalStudentView" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@vertical+block@Instructions">
<h2 class="hd hd-2 unit-title">Instructions</h2>
<div class="vert-mod">
<div class="vert vert-0" data-id="block-v1:MITx+6.005.2x+1T2017+type@html+block@html_90482c758bb8">
<div class="xblock xblock-public_view xblock-public_view-html xmodule_display xmodule_HtmlBlock" data-has-score="False" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="html" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@html+block@html_90482c758bb8">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "HTMLModule"}
</script>
<link href="/assets/courseware/v1/d93415c23438bb0217f0599a34bdff10/asset-v1:MITx+6.005.2x+1T2017+type@asset+block/prism-edx-v1.css" rel="stylesheet" type="text/css" />
<p><strong>There is no time limit for this exam. Just submit your answers before the deadline.</strong></p>
<p>This exam is designed to take about an hour. You can start the exam whenever convenient for you, and work on it for as long as you want, but you must submit all your answers by the deadline.</p>
<p>This is an individual exam. It is not OK to communicate about the exam to other peopleĀ until the exam deadline passed. But it is OK to use any resources on the course website during the exam, to use Eclipse on your personal computer, and to use other resources on the Internet.</p>
<p>During the exam period, the discussion forum is shut down, to avoid any accidental discussion of exam material. You will be able to see past posts but not ask questions. The forum will reopen at the end of the exam period.</p>
<p>If you want to go back and study some more before starting this exam you can certainly do so.</p>
<p>Good luck!</p>
</div>
</div>
</div>
</div>
<div class="xblock xblock-public_view xblock-public_view-vertical" data-has-score="False" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="vertical" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="VerticalStudentView" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@vertical+block@Part_1">
<h2 class="hd hd-2 unit-title">Part 1</h2>
<div class="vert-mod">
<div class="vert vert-0" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-recursive-decomposition">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-recursive-decomposition">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-01-recursive-decomposition" class="problems-wrapper" role="group"
aria-labelledby="exam-01-recursive-decomposition-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-recursive-decomposition" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-recursive-decomposition/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-01-recursive-decomposition-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-recursive-decomposition-problem-progress" tabindex="-1">
Recursion 1
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-recursive-decomposition-problem-progress"></div>
<div class="problem">
<div>
<pre>
public static String subsequences(String word) {
if (word.isEmpty()) {
return ""; // base case
} else {
char firstLetter = word.charAt(0);
String restOfWord = word.substring(1);
String subsequencesOfRest = subsequences(restOfWord);
String result = "";
for (String subsequence : subsequencesOfRest.split(",", -1)) {
result += "," + subsequence;
result += "," + firstLetter + subsequence;
}
result = result.substring(1); // remove extra leading comma
return result;
}
}
</pre>
<p>What does subsequences("c") return?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-01-recursive-decomposition_2_1">
<fieldset aria-describedby="status_exam-01-recursive-decomposition_2_1">
<div class="field">
<input type="radio" name="input_exam-01-recursive-decomposition_2_1" id="input_exam-01-recursive-decomposition_2_1_choice_0" class="field-input input-radio" value="choice_0"/><label id="exam-01-recursive-decomposition_2_1-choice_0-label" for="input_exam-01-recursive-decomposition_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-01-recursive-decomposition_2_1"> "c"
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-01-recursive-decomposition_2_1" id="input_exam-01-recursive-decomposition_2_1_choice_1" class="field-input input-radio" value="choice_1"/><label id="exam-01-recursive-decomposition_2_1-choice_1-label" for="input_exam-01-recursive-decomposition_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-01-recursive-decomposition_2_1"> ""
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-01-recursive-decomposition_2_1" id="input_exam-01-recursive-decomposition_2_1_choice_2" class="field-input input-radio" value="choice_2"/><label id="exam-01-recursive-decomposition_2_1-choice_2-label" for="input_exam-01-recursive-decomposition_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-01-recursive-decomposition_2_1"> ",c"
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-01-recursive-decomposition_2_1" id="input_exam-01-recursive-decomposition_2_1_choice_3" class="field-input input-radio" value="choice_3"/><label id="exam-01-recursive-decomposition_2_1-choice_3-label" for="input_exam-01-recursive-decomposition_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-01-recursive-decomposition_2_1"> "c,"
</label>
</div>
<span id="answer_exam-01-recursive-decomposition_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-01-recursive-decomposition_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-01-recursive-decomposition_solution_1"/>
</div><p>What does subsequences("gc") return?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 2" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-01-recursive-decomposition_3_1">
<fieldset aria-describedby="status_exam-01-recursive-decomposition_3_1">
<div class="field">
<input type="radio" name="input_exam-01-recursive-decomposition_3_1" id="input_exam-01-recursive-decomposition_3_1_choice_0" class="field-input input-radio" value="choice_0"/><label id="exam-01-recursive-decomposition_3_1-choice_0-label" for="input_exam-01-recursive-decomposition_3_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-01-recursive-decomposition_3_1"> "g,c"
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-01-recursive-decomposition_3_1" id="input_exam-01-recursive-decomposition_3_1_choice_1" class="field-input input-radio" value="choice_1"/><label id="exam-01-recursive-decomposition_3_1-choice_1-label" for="input_exam-01-recursive-decomposition_3_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-01-recursive-decomposition_3_1"> ",g,c,gc"
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-01-recursive-decomposition_3_1" id="input_exam-01-recursive-decomposition_3_1_choice_2" class="field-input input-radio" value="choice_2"/><label id="exam-01-recursive-decomposition_3_1-choice_2-label" for="input_exam-01-recursive-decomposition_3_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-01-recursive-decomposition_3_1"> ",gc,g,c"
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-01-recursive-decomposition_3_1" id="input_exam-01-recursive-decomposition_3_1_choice_3" class="field-input input-radio" value="choice_3"/><label id="exam-01-recursive-decomposition_3_1-choice_3-label" for="input_exam-01-recursive-decomposition_3_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-01-recursive-decomposition_3_1"> "g,c,gc"
</label>
</div>
<span id="answer_exam-01-recursive-decomposition_3_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-01-recursive-decomposition_3_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-01-recursive-decomposition_solution_2"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Recursion 1" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-01-recursive-decomposition" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-01-recursive-decomposition">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-01-recursive-decomposition-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-01-recursive-decomposition-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-01-recursive-decomposition-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-1" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-nq">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-nq">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-01-nq" class="problems-wrapper" role="group"
aria-labelledby="exam-01-nq-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-nq" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-nq/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-01-nq-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-nq-problem-progress" tabindex="-1">
Recursion 2
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-01-nq-problem-progress"></div>
<div class="problem">
<div>
<p>
Consider this recursive function:
</p>
<pre><code>
public static int factorial(int n) {
if (n == 0) {
return 1;
} else {
return n * factorial(n-1);
}
}
</code></pre>
<p>
Suppose the machine is running <code>factorial(7)</code> recursively, and has just entered a call for <code>factorial(0)</code>. Which of the following are true about the state of the machine at this point?
</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-01-nq_2_1">
<fieldset aria-describedby="status_exam-01-nq_2_1">
<div class="field">
<input type="checkbox" name="input_exam-01-nq_2_1[]" id="input_exam-01-nq_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-01-nq_2_1-choice_0-label" for="input_exam-01-nq_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-01-nq_2_1"> There are multiple active calls to <code>factorial()</code> on the stack.
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-01-nq_2_1[]" id="input_exam-01-nq_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-01-nq_2_1-choice_1-label" for="input_exam-01-nq_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-01-nq_2_1"> There are multiple instances of <code>n</code> on the stack.
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-01-nq_2_1[]" id="input_exam-01-nq_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-01-nq_2_1-choice_2-label" for="input_exam-01-nq_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-01-nq_2_1"> The stack is at its deepest point in the recursion.
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-01-nq_2_1[]" id="input_exam-01-nq_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-01-nq_2_1-choice_3-label" for="input_exam-01-nq_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-01-nq_2_1"> The return value from <code>factorial(0)</code> will be the return value from the whole recursion.
</label>
</div>
<span id="answer_exam-01-nq_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-01-nq_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-01-nq_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Recursion 2" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-01-nq" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-01-nq">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-01-nq-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-01-nq-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-01-nq-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-2" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-datatype-definition">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-datatype-definition">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-02-datatype-definition" class="problems-wrapper" role="group"
aria-labelledby="exam-02-datatype-definition-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-datatype-definition" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-datatype-definition/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-02-datatype-definition-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-datatype-definition-problem-progress" tabindex="-1">
Datatype definitions
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-datatype-definition-problem-progress"></div>
<div class="problem">
<div>
<p>Consider the datatype definition:</p>
<pre>
Geology = Core(a:int, b:int, c:int, d:int)
+ Planet(core:Core, a:int, b:int, c:int, d:int)
+ System(geology:Geology, a:int, b:int)
</pre>
<p>Suppose you have a reference to a <code>Geology</code> object. How many integers might it have in its representation?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-02-datatype-definition_2_1">
<fieldset aria-describedby="status_exam-02-datatype-definition_2_1">
<div class="field">
<input type="checkbox" name="input_exam-02-datatype-definition_2_1[]" id="input_exam-02-datatype-definition_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-02-datatype-definition_2_1-choice_0-label" for="input_exam-02-datatype-definition_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-02-datatype-definition_2_1"> 1
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-datatype-definition_2_1[]" id="input_exam-02-datatype-definition_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-02-datatype-definition_2_1-choice_1-label" for="input_exam-02-datatype-definition_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-02-datatype-definition_2_1"> 2
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-datatype-definition_2_1[]" id="input_exam-02-datatype-definition_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-02-datatype-definition_2_1-choice_2-label" for="input_exam-02-datatype-definition_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-02-datatype-definition_2_1"> 4
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-datatype-definition_2_1[]" id="input_exam-02-datatype-definition_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-02-datatype-definition_2_1-choice_3-label" for="input_exam-02-datatype-definition_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-02-datatype-definition_2_1"> 8
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-datatype-definition_2_1[]" id="input_exam-02-datatype-definition_2_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-02-datatype-definition_2_1-choice_4-label" for="input_exam-02-datatype-definition_2_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-02-datatype-definition_2_1"> 10
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-datatype-definition_2_1[]" id="input_exam-02-datatype-definition_2_1_choice_5" class="field-input input-checkbox" value="choice_5"/><label id="exam-02-datatype-definition_2_1-choice_5-label" for="input_exam-02-datatype-definition_2_1_choice_5" class="response-label field-label label-inline" aria-describedby="status_exam-02-datatype-definition_2_1"> 12
</label>
</div>
<span id="answer_exam-02-datatype-definition_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-02-datatype-definition_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-02-datatype-definition_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Datatype definitions" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-02-datatype-definition" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-02-datatype-definition">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-02-datatype-definition-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-02-datatype-definition-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-02-datatype-definition-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-3" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-nq">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-nq">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-02-nq" class="problems-wrapper" role="group"
aria-labelledby="exam-02-nq-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-nq" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-nq/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-02-nq-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-nq-problem-progress" tabindex="-1">
Immutable lists
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-02-nq-problem-progress"></div>
<div class="problem">
<div>
<p>Consider the immutable <code>ImList&lt;E&gt;</code> datatype, which has these operations:</p>
<table class="table table-condensed no-markdown">
<tbody>
<tr>
<th>empty: void &#8594; ImList</th>
<td>returns an empty list</td>
</tr>
<tr>
<th style="white-space:nowrap">cons: E &#215; ImList &#8594; ImList&#8195;</th>
<td>returns a new list formed by adding an element to the front of another list</td>
</tr>
<tr>
<th>first: ImList &#8594; E</th>
<td>returns the first element of a list, requires the list to be nonempty</td>
</tr>
<tr>
<th>rest: ImList &#8594; ImList</th>
<td>returns the list of all elements of this list except for the first, requires the list to be nonempty</td>
</tr>
</tbody>
</table>
<p>and this datatype definition:</p>
<pre>
ImList&lt;E&gt; = Empty + Cons(first:E, rest:ImList)
</pre>
<p>If we run:</p>
<pre>
ImList&lt;String&gt; a = ImList.empty();
ImList&lt;String&gt; b = a.cons("blue").cons("red");
</pre>
<p>How many <code>ImList</code> objects are in only list <code>a</code> or <code>b</code>, <strong>not</strong> in both?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-02-nq_2_1">
<fieldset aria-describedby="status_exam-02-nq_2_1">
<div class="field">
<input type="radio" name="input_exam-02-nq_2_1" id="input_exam-02-nq_2_1_choice_0" class="field-input input-radio" value="choice_0"/><label id="exam-02-nq_2_1-choice_0-label" for="input_exam-02-nq_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_2_1"> 0
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-02-nq_2_1" id="input_exam-02-nq_2_1_choice_1" class="field-input input-radio" value="choice_1"/><label id="exam-02-nq_2_1-choice_1-label" for="input_exam-02-nq_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_2_1"> 1
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-02-nq_2_1" id="input_exam-02-nq_2_1_choice_2" class="field-input input-radio" value="choice_2"/><label id="exam-02-nq_2_1-choice_2-label" for="input_exam-02-nq_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_2_1"> 2 or more
</label>
</div>
<span id="answer_exam-02-nq_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-02-nq_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-02-nq_solution_1"/>
</div><p>How many <code>ImList</code> objects are shared by both lists <code>a</code> and <code>b</code>?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 2" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-02-nq_3_1">
<fieldset aria-describedby="status_exam-02-nq_3_1">
<div class="field">
<input type="radio" name="input_exam-02-nq_3_1" id="input_exam-02-nq_3_1_choice_0" class="field-input input-radio" value="choice_0"/><label id="exam-02-nq_3_1-choice_0-label" for="input_exam-02-nq_3_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_3_1"> 0
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-02-nq_3_1" id="input_exam-02-nq_3_1_choice_1" class="field-input input-radio" value="choice_1"/><label id="exam-02-nq_3_1-choice_1-label" for="input_exam-02-nq_3_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_3_1"> 1
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-02-nq_3_1" id="input_exam-02-nq_3_1_choice_2" class="field-input input-radio" value="choice_2"/><label id="exam-02-nq_3_1-choice_2-label" for="input_exam-02-nq_3_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_3_1"> 2 or more
</label>
</div>
<span id="answer_exam-02-nq_3_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-02-nq_3_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-02-nq_solution_2"/>
</div><p>The actual runtime type of the object returned by <code>b.first()</code> is (choose all that apply):</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 3" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-02-nq_4_1">
<fieldset aria-describedby="status_exam-02-nq_4_1">
<div class="field">
<input type="checkbox" name="input_exam-02-nq_4_1[]" id="input_exam-02-nq_4_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-02-nq_4_1-choice_0-label" for="input_exam-02-nq_4_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_4_1">
<code>Cons</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-nq_4_1[]" id="input_exam-02-nq_4_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-02-nq_4_1-choice_1-label" for="input_exam-02-nq_4_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_4_1">
<code>Empty</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-nq_4_1[]" id="input_exam-02-nq_4_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-02-nq_4_1-choice_2-label" for="input_exam-02-nq_4_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_4_1">
<code>ImList</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-nq_4_1[]" id="input_exam-02-nq_4_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-02-nq_4_1-choice_3-label" for="input_exam-02-nq_4_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_4_1">
<code>ImList&lt;String&gt;</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-nq_4_1[]" id="input_exam-02-nq_4_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-02-nq_4_1-choice_4-label" for="input_exam-02-nq_4_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_4_1">
<code>String</code>
</label>
</div>
<span id="answer_exam-02-nq_4_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-02-nq_4_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-02-nq_solution_3"/>
</div><p>The actual runtime type of the object returned by <code>b.rest()</code> is (choose all that apply):</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 4" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-02-nq_5_1">
<fieldset aria-describedby="status_exam-02-nq_5_1">
<div class="field">
<input type="checkbox" name="input_exam-02-nq_5_1[]" id="input_exam-02-nq_5_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-02-nq_5_1-choice_0-label" for="input_exam-02-nq_5_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_5_1">
<code>Cons</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-nq_5_1[]" id="input_exam-02-nq_5_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-02-nq_5_1-choice_1-label" for="input_exam-02-nq_5_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_5_1">
<code>Empty</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-nq_5_1[]" id="input_exam-02-nq_5_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-02-nq_5_1-choice_2-label" for="input_exam-02-nq_5_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_5_1">
<code>ImList</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-nq_5_1[]" id="input_exam-02-nq_5_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-02-nq_5_1-choice_3-label" for="input_exam-02-nq_5_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_5_1">
<code>ImList&lt;String&gt;</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-02-nq_5_1[]" id="input_exam-02-nq_5_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-02-nq_5_1-choice_4-label" for="input_exam-02-nq_5_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-02-nq_5_1">
<code>String</code>
</label>
</div>
<span id="answer_exam-02-nq_5_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-02-nq_5_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-02-nq_solution_4"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Immutable lists" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-02-nq" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-02-nq">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-02-nq-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-02-nq-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-02-nq-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="xblock xblock-public_view xblock-public_view-vertical" data-has-score="False" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="vertical" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="VerticalStudentView" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@vertical+block@Part_2">
<h2 class="hd hd-2 unit-title">Part 2</h2>
<div class="vert-mod">
<div class="vert vert-0" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-nq">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-nq">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-03-nq" class="problems-wrapper" role="group"
aria-labelledby="exam-03-nq-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-nq" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-nq/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-03-nq-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-nq-problem-progress" tabindex="-1">
Regular expressions
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-nq-problem-progress"></div>
<div class="problem">
<div>
<p>Which of these strings completely match the regular expression
<code>12+(3|5)*</code>?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-03-nq_2_1">
<fieldset aria-describedby="status_exam-03-nq_2_1">
<div class="field">
<input type="checkbox" name="input_exam-03-nq_2_1[]" id="input_exam-03-nq_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-03-nq_2_1-choice_0-label" for="input_exam-03-nq_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-03-nq_2_1">
<code>11111</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-nq_2_1[]" id="input_exam-03-nq_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-03-nq_2_1-choice_1-label" for="input_exam-03-nq_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-03-nq_2_1">
<code>12121235</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-nq_2_1[]" id="input_exam-03-nq_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-03-nq_2_1-choice_2-label" for="input_exam-03-nq_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-03-nq_2_1">
<code>1222</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-nq_2_1[]" id="input_exam-03-nq_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-03-nq_2_1-choice_3-label" for="input_exam-03-nq_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-03-nq_2_1">
<code>1253</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-nq_2_1[]" id="input_exam-03-nq_2_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-03-nq_2_1-choice_4-label" for="input_exam-03-nq_2_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-03-nq_2_1">
<code>123</code>
</label>
</div>
<span id="answer_exam-03-nq_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-03-nq_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-03-nq_solution_1"/>
</div><p>Which of these regular expressions completely match <code>foo</code> but not <code>boo</code>?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 2" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-03-nq_3_1">
<fieldset aria-describedby="status_exam-03-nq_3_1">
<div class="field">
<input type="checkbox" name="input_exam-03-nq_3_1[]" id="input_exam-03-nq_3_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-03-nq_3_1-choice_0-label" for="input_exam-03-nq_3_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-03-nq_3_1">
<code>(foo)?(boo)?</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-nq_3_1[]" id="input_exam-03-nq_3_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-03-nq_3_1-choice_1-label" for="input_exam-03-nq_3_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-03-nq_3_1">
<code>[a-z]o+</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-nq_3_1[]" id="input_exam-03-nq_3_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-03-nq_3_1-choice_2-label" for="input_exam-03-nq_3_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-03-nq_3_1">
<code>(b|fo*)o</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-nq_3_1[]" id="input_exam-03-nq_3_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-03-nq_3_1-choice_3-label" for="input_exam-03-nq_3_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-03-nq_3_1">
<code>f*o*b*o*</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-nq_3_1[]" id="input_exam-03-nq_3_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-03-nq_3_1-choice_4-label" for="input_exam-03-nq_3_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-03-nq_3_1">
<code>boofoo</code>
</label>
</div>
<span id="answer_exam-03-nq_3_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-03-nq_3_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-03-nq_solution_2"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Regular expressions" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-03-nq" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-03-nq">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-03-nq-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-03-nq-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-03-nq-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-1" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-reading-a-grammar">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-reading-a-grammar">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-03-reading-a-grammar" class="problems-wrapper" role="group"
aria-labelledby="exam-03-reading-a-grammar-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-reading-a-grammar" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-reading-a-grammar/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-03-reading-a-grammar-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-reading-a-grammar-problem-progress" tabindex="-1">
Grammars
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-03-reading-a-grammar-problem-progress"></div>
<div class="problem">
<div>
<p>Which strings match the root nonterminal of this grammar?</p>
<pre>
root ::= integer ('-' integer)+
integer ::= [0-9]+
</pre>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-03-reading-a-grammar_2_1">
<fieldset aria-describedby="status_exam-03-reading-a-grammar_2_1">
<div class="field">
<input type="checkbox" name="input_exam-03-reading-a-grammar_2_1[]" id="input_exam-03-reading-a-grammar_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-03-reading-a-grammar_2_1-choice_0-label" for="input_exam-03-reading-a-grammar_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-03-reading-a-grammar_2_1">
<code>617</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-reading-a-grammar_2_1[]" id="input_exam-03-reading-a-grammar_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-03-reading-a-grammar_2_1-choice_1-label" for="input_exam-03-reading-a-grammar_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-03-reading-a-grammar_2_1">
<code>617-253</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-reading-a-grammar_2_1[]" id="input_exam-03-reading-a-grammar_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-03-reading-a-grammar_2_1-choice_2-label" for="input_exam-03-reading-a-grammar_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-03-reading-a-grammar_2_1">
<code>617-253-1000</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-reading-a-grammar_2_1[]" id="input_exam-03-reading-a-grammar_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-03-reading-a-grammar_2_1-choice_3-label" for="input_exam-03-reading-a-grammar_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-03-reading-a-grammar_2_1">
<code>---</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-reading-a-grammar_2_1[]" id="input_exam-03-reading-a-grammar_2_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-03-reading-a-grammar_2_1-choice_4-label" for="input_exam-03-reading-a-grammar_2_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-03-reading-a-grammar_2_1">
<code>integer-integer-integer</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-reading-a-grammar_2_1[]" id="input_exam-03-reading-a-grammar_2_1_choice_5" class="field-input input-checkbox" value="choice_5"/><label id="exam-03-reading-a-grammar_2_1-choice_5-label" for="input_exam-03-reading-a-grammar_2_1_choice_5" class="response-label field-label label-inline" aria-describedby="status_exam-03-reading-a-grammar_2_1">
<code>5--5</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-03-reading-a-grammar_2_1[]" id="input_exam-03-reading-a-grammar_2_1_choice_6" class="field-input input-checkbox" value="choice_6"/><label id="exam-03-reading-a-grammar_2_1-choice_6-label" for="input_exam-03-reading-a-grammar_2_1_choice_6" class="response-label field-label label-inline" aria-describedby="status_exam-03-reading-a-grammar_2_1">
<code>3-6-293-1</code>
</label>
</div>
<span id="answer_exam-03-reading-a-grammar_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-03-reading-a-grammar_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-03-reading-a-grammar_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Grammars" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-03-reading-a-grammar" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-03-reading-a-grammar">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-03-reading-a-grammar-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-03-reading-a-grammar-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-03-reading-a-grammar-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-2" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-04-parsing">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-04-parsing">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-04-parsing" class="problems-wrapper" role="group"
aria-labelledby="exam-04-parsing-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-04-parsing" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-04-parsing/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-04-parsing-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-04-parsing-problem-progress" tabindex="-1">
Parse trees
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-04-parsing-problem-progress"></div>
<div class="problem">
<div>
<p>Which of the following statements are true of a parse tree?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-04-parsing_2_1">
<fieldset aria-describedby="status_exam-04-parsing_2_1">
<div class="field">
<input type="checkbox" name="input_exam-04-parsing_2_1[]" id="input_exam-04-parsing_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-04-parsing_2_1-choice_0-label" for="input_exam-04-parsing_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-04-parsing_2_1"> the root node of the tree corresponds to the starting symbol of the grammar
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-04-parsing_2_1[]" id="input_exam-04-parsing_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-04-parsing_2_1-choice_1-label" for="input_exam-04-parsing_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-04-parsing_2_1"> the leaves of the tree correspond to terminals
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-04-parsing_2_1[]" id="input_exam-04-parsing_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-04-parsing_2_1-choice_2-label" for="input_exam-04-parsing_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-04-parsing_2_1"> the internal nodes of the tree correspond to nonterminals
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-04-parsing_2_1[]" id="input_exam-04-parsing_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-04-parsing_2_1-choice_3-label" for="input_exam-04-parsing_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-04-parsing_2_1"> only a grammar with recursive productions can generate a parse tree
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-04-parsing_2_1[]" id="input_exam-04-parsing_2_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-04-parsing_2_1-choice_4-label" for="input_exam-04-parsing_2_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-04-parsing_2_1"> a parse tree is the same as an abstract syntax tree
</label>
</div>
<span id="answer_exam-04-parsing_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-04-parsing_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-04-parsing_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Parse trees" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-04-parsing" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-04-parsing">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-04-parsing-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-04-parsing-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-04-parsing-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-3" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq1">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq1">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-05-nq1" class="problems-wrapper" role="group"
aria-labelledby="exam-05-nq1-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq1" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq1/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-05-nq1-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq1-problem-progress" tabindex="-1">
Race conditions
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq1-problem-progress"></div>
<div class="problem">
<div>
<p>
Suppose two threads will both use <code>x</code>, which is declared with one of the declarations below.
They have no other shared state or interaction.
For which of these declarations of <code>x</code> would we be concerned about race conditions involving <code>x</code>?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-05-nq1_2_1">
<fieldset aria-describedby="status_exam-05-nq1_2_1">
<div class="field">
<input type="checkbox" name="input_exam-05-nq1_2_1[]" id="input_exam-05-nq1_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-05-nq1_2_1-choice_0-label" for="input_exam-05-nq1_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-05-nq1_2_1">
<code>public static boolean x = true;</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-nq1_2_1[]" id="input_exam-05-nq1_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-05-nq1_2_1-choice_1-label" for="input_exam-05-nq1_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-05-nq1_2_1">
<code>public static final boolean x = true;</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-nq1_2_1[]" id="input_exam-05-nq1_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-05-nq1_2_1-choice_2-label" for="input_exam-05-nq1_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-05-nq1_2_1">
<code>public static int x = 7;</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-nq1_2_1[]" id="input_exam-05-nq1_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-05-nq1_2_1-choice_3-label" for="input_exam-05-nq1_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-05-nq1_2_1">
<code>public static final String x = "7";</code>
</label>
</div>
<span id="answer_exam-05-nq1_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-05-nq1_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-05-nq1_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Race conditions" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-05-nq1" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-05-nq1">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-05-nq1-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-05-nq1-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-05-nq1-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-4" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq2">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq2">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-05-nq2" class="problems-wrapper" role="group"
aria-labelledby="exam-05-nq2-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq2" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq2/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-05-nq2-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq2-problem-progress" tabindex="-1">
Concurrency
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-nq2-problem-progress"></div>
<div class="problem">
<div>
<p>Which of the following make concurrency hard to test and debug?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-05-nq2_2_1">
<fieldset aria-describedby="status_exam-05-nq2_2_1">
<div class="field">
<input type="checkbox" name="input_exam-05-nq2_2_1[]" id="input_exam-05-nq2_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-05-nq2_2_1-choice_0-label" for="input_exam-05-nq2_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-05-nq2_2_1"> Time slicing is nondeterministic
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-nq2_2_1[]" id="input_exam-05-nq2_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-05-nq2_2_1-choice_1-label" for="input_exam-05-nq2_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-05-nq2_2_1"> Thread interleaving is nondeterministic
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-nq2_2_1[]" id="input_exam-05-nq2_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-05-nq2_2_1-choice_2-label" for="input_exam-05-nq2_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-05-nq2_2_1"> <code>System.out.println</code> is nondeterministic
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-nq2_2_1[]" id="input_exam-05-nq2_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-05-nq2_2_1-choice_3-label" for="input_exam-05-nq2_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-05-nq2_2_1"> Order of executing methods in a thread is nondeterministic
</label>
</div>
<span id="answer_exam-05-nq2_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-05-nq2_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-05-nq2_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Concurrency" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-05-nq2" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-05-nq2">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-05-nq2-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-05-nq2-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-05-nq2-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="xblock xblock-public_view xblock-public_view-vertical" data-has-score="False" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="vertical" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="VerticalStudentView" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@vertical+block@Part_3">
<h2 class="hd hd-2 unit-title">Part 3</h2>
<div class="vert-mod">
<div class="vert vert-0" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-interleaving-1">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-interleaving-1">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-05-interleaving-1" class="problems-wrapper" role="group"
aria-labelledby="exam-05-interleaving-1-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-interleaving-1" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-interleaving-1/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-05-interleaving-1-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-interleaving-1-problem-progress" tabindex="-1">
Interleaving 1
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-05-interleaving-1-problem-progress"></div>
<div class="problem">
<div>
<pre>
public class Moirai {
public static void main(String[] args) {
Thread clotho = new Thread(new Runnable() {
public void run() { System.out.println("spinning"); };
});
clotho.start();
new Thread(new Runnable() {
public void run() { System.out.println("measuring"); };
}).start();
new Thread(new Runnable() {
public void run() { System.out.println("cutting"); };
});
}
}
</pre>
<p>Which of the following are possible outputs from this program after all started threads have terminated?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-05-interleaving-1_2_1">
<fieldset aria-describedby="status_exam-05-interleaving-1_2_1">
<div class="field">
<input type="checkbox" name="input_exam-05-interleaving-1_2_1[]" id="input_exam-05-interleaving-1_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-05-interleaving-1_2_1-choice_0-label" for="input_exam-05-interleaving-1_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-05-interleaving-1_2_1"> spinning<br/>measuring<br/>cutting
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-interleaving-1_2_1[]" id="input_exam-05-interleaving-1_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-05-interleaving-1_2_1-choice_1-label" for="input_exam-05-interleaving-1_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-05-interleaving-1_2_1"> spinning<br/>measuring
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-interleaving-1_2_1[]" id="input_exam-05-interleaving-1_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-05-interleaving-1_2_1-choice_2-label" for="input_exam-05-interleaving-1_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-05-interleaving-1_2_1"> measuring<br/>spinning<br/>cutting
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-interleaving-1_2_1[]" id="input_exam-05-interleaving-1_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-05-interleaving-1_2_1-choice_3-label" for="input_exam-05-interleaving-1_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-05-interleaving-1_2_1"> measuring<br/>spinning
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-interleaving-1_2_1[]" id="input_exam-05-interleaving-1_2_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-05-interleaving-1_2_1-choice_4-label" for="input_exam-05-interleaving-1_2_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-05-interleaving-1_2_1"> spinning
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-05-interleaving-1_2_1[]" id="input_exam-05-interleaving-1_2_1_choice_5" class="field-input input-checkbox" value="choice_5"/><label id="exam-05-interleaving-1_2_1-choice_5-label" for="input_exam-05-interleaving-1_2_1_choice_5" class="response-label field-label label-inline" aria-describedby="status_exam-05-interleaving-1_2_1"> measuring
</label>
</div>
<span id="answer_exam-05-interleaving-1_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-05-interleaving-1_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-05-interleaving-1_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Interleaving 1" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-05-interleaving-1" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-05-interleaving-1">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-05-interleaving-1-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-05-interleaving-1-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-05-interleaving-1-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-1" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq1">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq1">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-06-nq1" class="problems-wrapper" role="group"
aria-labelledby="exam-06-nq1-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq1" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq1/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-06-nq1-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq1-problem-progress" tabindex="-1">
Interleaving 2
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq1-problem-progress"></div>
<div class="problem">
<div>
<p>Which of these are possible results for <code>s</code>
if <code>a()</code> and <code>b()</code> run concurrently?</p>
<pre>
private String s = "a";
public void a() { s = s + "z"; }
public void b() { s = "(" + s + ")"; }
</pre>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-06-nq1_2_1">
<fieldset aria-describedby="status_exam-06-nq1_2_1">
<div class="field">
<input type="checkbox" name="input_exam-06-nq1_2_1[]" id="input_exam-06-nq1_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-06-nq1_2_1-choice_0-label" for="input_exam-06-nq1_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq1_2_1">
<code>"a"</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-nq1_2_1[]" id="input_exam-06-nq1_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-06-nq1_2_1-choice_1-label" for="input_exam-06-nq1_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq1_2_1">
<code>"az"</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-nq1_2_1[]" id="input_exam-06-nq1_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-06-nq1_2_1-choice_2-label" for="input_exam-06-nq1_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq1_2_1">
<code>"(a)"</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-nq1_2_1[]" id="input_exam-06-nq1_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-06-nq1_2_1-choice_3-label" for="input_exam-06-nq1_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq1_2_1">
<code>"(z)"</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-nq1_2_1[]" id="input_exam-06-nq1_2_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-06-nq1_2_1-choice_4-label" for="input_exam-06-nq1_2_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq1_2_1">
<code>"(az)"</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-nq1_2_1[]" id="input_exam-06-nq1_2_1_choice_5" class="field-input input-checkbox" value="choice_5"/><label id="exam-06-nq1_2_1-choice_5-label" for="input_exam-06-nq1_2_1_choice_5" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq1_2_1">
<code>"()az"</code>
</label>
</div>
<span id="answer_exam-06-nq1_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-06-nq1_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-06-nq1_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Interleaving 2" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-06-nq1" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-06-nq1">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-06-nq1-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-06-nq1-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-06-nq1-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-2" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq2">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq2">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-06-nq2" class="problems-wrapper" role="group"
aria-labelledby="exam-06-nq2-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq2" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq2/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-06-nq2-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq2-problem-progress" tabindex="-1">
Thread safety strategies
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-nq2-problem-progress"></div>
<div class="problem">
<div>
<p>For each declaration below, pick all the strategies that could be useful for arguing that the program is threadsafe.</p>
<p>A local variable <code>char[] y;</code></p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-06-nq2_2_1">
<fieldset aria-describedby="status_exam-06-nq2_2_1">
<div class="field">
<input type="checkbox" name="input_exam-06-nq2_2_1[]" id="input_exam-06-nq2_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-06-nq2_2_1-choice_0-label" for="input_exam-06-nq2_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq2_2_1"> Confinement
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-nq2_2_1[]" id="input_exam-06-nq2_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-06-nq2_2_1-choice_1-label" for="input_exam-06-nq2_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq2_2_1"> Immutability
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-nq2_2_1[]" id="input_exam-06-nq2_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-06-nq2_2_1-choice_2-label" for="input_exam-06-nq2_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq2_2_1"> Using threadsafe data types
</label>
</div>
<span id="answer_exam-06-nq2_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-06-nq2_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-06-nq2_solution_1"/>
</div><p>A field <code>public static final List&lt;Double&gt; q;</code></p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 2" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-06-nq2_3_1">
<fieldset aria-describedby="status_exam-06-nq2_3_1">
<div class="field">
<input type="checkbox" name="input_exam-06-nq2_3_1[]" id="input_exam-06-nq2_3_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-06-nq2_3_1-choice_0-label" for="input_exam-06-nq2_3_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq2_3_1"> Confinement
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-nq2_3_1[]" id="input_exam-06-nq2_3_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-06-nq2_3_1-choice_1-label" for="input_exam-06-nq2_3_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq2_3_1"> Immutability
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-nq2_3_1[]" id="input_exam-06-nq2_3_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-06-nq2_3_1-choice_2-label" for="input_exam-06-nq2_3_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-06-nq2_3_1"> Using threadsafe data types
</label>
</div>
<span id="answer_exam-06-nq2_3_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-06-nq2_3_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-06-nq2_solution_2"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Thread safety strategies" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-06-nq2" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-06-nq2">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-06-nq2-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-06-nq2-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-06-nq2-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-3" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-bad-safety-argument">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-bad-safety-argument">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-06-bad-safety-argument" class="problems-wrapper" role="group"
aria-labelledby="exam-06-bad-safety-argument-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-bad-safety-argument" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-bad-safety-argument/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-06-bad-safety-argument-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-bad-safety-argument-problem-progress" tabindex="-1">
Bad safety argument
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-06-bad-safety-argument-problem-progress"></div>
<div class="problem">
<div>
<p>Consider the following ADT with a <b>bad</b> safety argument:</p>
<pre>
/** MyStringBuffer is a threadsafe mutable string of characters. */
public class MyStringBuffer {
private String text;
// Rep invariant:
// none
// Abstraction function:
// represents the sequence text[0],...,text[text.length()-1]
// Thread safety argument:
// text is an immutable (and hence threadsafe) String,
// so this object is also threadsafe
/** @return the string represented by this buffer, with all letters converted to uppercase */
public String toUpperCase() {
return text.toUpperCase();
}
/** @param pos position to insert text into the buffer. Requires 0 &lt;= pos &lt;= text.length().
@param s text to insert
Mutates this buffer to insert s as a substring at position pos. */
public void insert(int pos, String s) {
text = text.substring(0, pos) + s + text.substring(pos);
}
/** @return the string represented by this buffer */
public String toString() {
return text;
}
/** Resets this buffer to the empty string */
public void clear() {
text = "";
}
/** @return the first character of this buffer, or "" if this buffer is empty
public String first() {
if (text.length() &gt; 0) {
return String.valueOf(text.charAt(0));
} else {
return "";
}
}
</pre>
<p>Which of these methods are counterexamples to this buggy safety argument, because they have a race condition? In particular, you should mark some method A as a counterexample if it's possible for one thread running method A at the same time as another thread is running some other method, some particular interleaving would violate A's postcondition?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-06-bad-safety-argument_2_1">
<fieldset aria-describedby="status_exam-06-bad-safety-argument_2_1">
<div class="field">
<input type="checkbox" name="input_exam-06-bad-safety-argument_2_1[]" id="input_exam-06-bad-safety-argument_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-06-bad-safety-argument_2_1-choice_0-label" for="input_exam-06-bad-safety-argument_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-06-bad-safety-argument_2_1"> toUpperCase
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-bad-safety-argument_2_1[]" id="input_exam-06-bad-safety-argument_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-06-bad-safety-argument_2_1-choice_1-label" for="input_exam-06-bad-safety-argument_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-06-bad-safety-argument_2_1"> insert
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-bad-safety-argument_2_1[]" id="input_exam-06-bad-safety-argument_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-06-bad-safety-argument_2_1-choice_2-label" for="input_exam-06-bad-safety-argument_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-06-bad-safety-argument_2_1"> toString
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-bad-safety-argument_2_1[]" id="input_exam-06-bad-safety-argument_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-06-bad-safety-argument_2_1-choice_3-label" for="input_exam-06-bad-safety-argument_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-06-bad-safety-argument_2_1"> clear
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-06-bad-safety-argument_2_1[]" id="input_exam-06-bad-safety-argument_2_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-06-bad-safety-argument_2_1-choice_4-label" for="input_exam-06-bad-safety-argument_2_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-06-bad-safety-argument_2_1"> first
</label>
</div>
<span id="answer_exam-06-bad-safety-argument_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-06-bad-safety-argument_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-06-bad-safety-argument_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Bad safety argument" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-06-bad-safety-argument" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-06-bad-safety-argument">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-06-bad-safety-argument-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-06-bad-safety-argument-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-06-bad-safety-argument-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="xblock xblock-public_view xblock-public_view-vertical" data-has-score="False" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="vertical" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="VerticalStudentView" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@vertical+block@Part_4">
<h2 class="hd hd-2 unit-title">Part 4</h2>
<div class="vert-mod">
<div class="vert vert-0" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-07-block-block-block-block">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-07-block-block-block-block">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-07-block-block-block-block" class="problems-wrapper" role="group"
aria-labelledby="exam-07-block-block-block-block-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-07-block-block-block-block" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-07-block-block-block-block/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-07-block-block-block-block-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-07-block-block-block-block-problem-progress" tabindex="-1">
Blocking 1
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-07-block-block-block-block-problem-progress"></div>
<div class="problem">
<div>
<p>Since <code>BufferedReader.readLine()</code> is a <em>blocking</em> method, which of these is true:</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-07-block-block-block-block_2_1">
<fieldset aria-describedby="status_exam-07-block-block-block-block_2_1">
<div class="field">
<input type="checkbox" name="input_exam-07-block-block-block-block_2_1[]" id="input_exam-07-block-block-block-block_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-07-block-block-block-block_2_1-choice_0-label" for="input_exam-07-block-block-block-block_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-07-block-block-block-block_2_1"> When a thread calls <code>readLine</code>, all other threads <em>block</em> until <code>readLine</code> returns
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-07-block-block-block-block_2_1[]" id="input_exam-07-block-block-block-block_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-07-block-block-block-block_2_1-choice_1-label" for="input_exam-07-block-block-block-block_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-07-block-block-block-block_2_1"> When a thread calls <code>readLine</code>, that thread <em>blocks</em> until <code>readLine</code> returns
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-07-block-block-block-block_2_1[]" id="input_exam-07-block-block-block-block_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-07-block-block-block-block_2_1-choice_2-label" for="input_exam-07-block-block-block-block_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-07-block-block-block-block_2_1"> When a thread calls <code>readLine</code>, the call can be <em>blocked</em> and an exception is thrown
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-07-block-block-block-block_2_1[]" id="input_exam-07-block-block-block-block_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-07-block-block-block-block_2_1-choice_3-label" for="input_exam-07-block-block-block-block_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-07-block-block-block-block_2_1"> <code>BufferedReader</code> has its own thread for <code>readLine</code>, which runs a <em>block</em> of code passed in by the client
</label>
</div>
<span id="answer_exam-07-block-block-block-block_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-07-block-block-block-block_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-07-block-block-block-block_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Blocking 1" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-07-block-block-block-block" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-07-block-block-block-block">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-07-block-block-block-block-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-07-block-block-block-block-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-07-block-block-block-block-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-1" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-nq1">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-nq1">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-09-nq1" class="problems-wrapper" role="group"
aria-labelledby="exam-09-nq1-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-nq1" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-nq1/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-09-nq1-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-nq1-problem-progress" tabindex="-1">
Blocking 2
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-nq1-problem-progress"></div>
<div class="problem">
<div>
<p>A thread is blocked. Which of the following <em>might</em> cause this?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-09-nq1_2_1">
<fieldset aria-describedby="status_exam-09-nq1_2_1">
<div class="field">
<input type="checkbox" name="input_exam-09-nq1_2_1[]" id="input_exam-09-nq1_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-09-nq1_2_1-choice_0-label" for="input_exam-09-nq1_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-09-nq1_2_1"> Trying to acquire a lock held by some other thread
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-nq1_2_1[]" id="input_exam-09-nq1_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-09-nq1_2_1-choice_1-label" for="input_exam-09-nq1_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-09-nq1_2_1"> Trying to acquire a lock not held by any thread
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-nq1_2_1[]" id="input_exam-09-nq1_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-09-nq1_2_1-choice_2-label" for="input_exam-09-nq1_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-09-nq1_2_1"> Trying to call a <code>synchronized</code> method
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-nq1_2_1[]" id="input_exam-09-nq1_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-09-nq1_2_1-choice_3-label" for="input_exam-09-nq1_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-09-nq1_2_1"> Trying to read from a network socket
</label>
</div>
<span id="answer_exam-09-nq1_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-09-nq1_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-09-nq1_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Blocking 2" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-09-nq1" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-09-nq1">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-09-nq1-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-09-nq1-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-09-nq1-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-2" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq1">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq1">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-08-nq1" class="problems-wrapper" role="group"
aria-labelledby="exam-08-nq1-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq1" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq1/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-08-nq1-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq1-problem-progress" tabindex="-1">
Message passing
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq1-problem-progress"></div>
<div class="problem">
<div>
<p>Message passing between two threads can be done
safely with:</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-08-nq1_2_1">
<fieldset aria-describedby="status_exam-08-nq1_2_1">
<div class="field">
<input type="checkbox" name="input_exam-08-nq1_2_1[]" id="input_exam-08-nq1_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-08-nq1_2_1-choice_0-label" for="input_exam-08-nq1_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-08-nq1_2_1"> An immutable queue of immutable objects
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-08-nq1_2_1[]" id="input_exam-08-nq1_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-08-nq1_2_1-choice_1-label" for="input_exam-08-nq1_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-08-nq1_2_1"> A mutable queue of immutable objects
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-08-nq1_2_1[]" id="input_exam-08-nq1_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-08-nq1_2_1-choice_2-label" for="input_exam-08-nq1_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-08-nq1_2_1"> A mutable queue of mutable objects
</label>
</div>
<span id="answer_exam-08-nq1_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-08-nq1_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-08-nq1_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Message passing" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-08-nq1" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-08-nq1">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-08-nq1-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-08-nq1-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-08-nq1-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-3" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq2">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq2">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-08-nq2" class="problems-wrapper" role="group"
aria-labelledby="exam-08-nq2-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq2" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq2/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-08-nq2-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq2-problem-progress" tabindex="-1">
Poison pills
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-08-nq2-problem-progress"></div>
<div class="problem">
<div>
<p>Putting a poison pill in a message-passing queue is equivalent to what in programming with sockets?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-08-nq2_2_1">
<fieldset aria-describedby="status_exam-08-nq2_2_1">
<div class="field">
<input type="radio" name="input_exam-08-nq2_2_1" id="input_exam-08-nq2_2_1_choice_0" class="field-input input-radio" value="choice_0"/><label id="exam-08-nq2_2_1-choice_0-label" for="input_exam-08-nq2_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-08-nq2_2_1"> closing the socket
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-08-nq2_2_1" id="input_exam-08-nq2_2_1_choice_1" class="field-input input-radio" value="choice_1"/><label id="exam-08-nq2_2_1-choice_1-label" for="input_exam-08-nq2_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-08-nq2_2_1"> throwing an exception
</label>
</div>
<div class="field">
<input type="radio" name="input_exam-08-nq2_2_1" id="input_exam-08-nq2_2_1_choice_2" class="field-input input-radio" value="choice_2"/><label id="exam-08-nq2_2_1-choice_2-label" for="input_exam-08-nq2_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-08-nq2_2_1"> writing null to the socket
</label>
</div>
<span id="answer_exam-08-nq2_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-08-nq2_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-08-nq2_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Poison pills" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-08-nq2" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-08-nq2">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-08-nq2-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-08-nq2-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-08-nq2-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-4" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-array-list">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-array-list">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-09-array-list" class="problems-wrapper" role="group"
aria-labelledby="exam-09-array-list-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-array-list" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-array-list/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-09-array-list-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-array-list-problem-progress" tabindex="-1">
ArrayList
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-array-list-problem-progress"></div>
<div class="problem">
<div>
<p>Suppose <code>list</code> is an instance of <code>ArrayList&lt;String&gt;</code>.</p>
<p>What is true while A is in a <code>synchronized (list) { ... }</code> block?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-09-array-list_2_1">
<fieldset aria-describedby="status_exam-09-array-list_2_1">
<div class="field">
<input type="checkbox" name="input_exam-09-array-list_2_1[]" id="input_exam-09-array-list_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-09-array-list_2_1-choice_0-label" for="input_exam-09-array-list_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-09-array-list_2_1"> it owns the lock on <code>list</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-array-list_2_1[]" id="input_exam-09-array-list_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-09-array-list_2_1-choice_1-label" for="input_exam-09-array-list_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-09-array-list_2_1"> it does not own the lock on <code>list</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-array-list_2_1[]" id="input_exam-09-array-list_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-09-array-list_2_1-choice_2-label" for="input_exam-09-array-list_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-09-array-list_2_1"> no other thread can use observers of <code>list</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-array-list_2_1[]" id="input_exam-09-array-list_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-09-array-list_2_1-choice_3-label" for="input_exam-09-array-list_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-09-array-list_2_1"> no other thread can use mutators of <code>list</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-array-list_2_1[]" id="input_exam-09-array-list_2_1_choice_4" class="field-input input-checkbox" value="choice_4"/><label id="exam-09-array-list_2_1-choice_4-label" for="input_exam-09-array-list_2_1_choice_4" class="response-label field-label label-inline" aria-describedby="status_exam-09-array-list_2_1"> no other thread can acquire the lock on <code>list</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-array-list_2_1[]" id="input_exam-09-array-list_2_1_choice_5" class="field-input input-checkbox" value="choice_5"/><label id="exam-09-array-list_2_1-choice_5-label" for="input_exam-09-array-list_2_1_choice_5" class="response-label field-label label-inline" aria-describedby="status_exam-09-array-list_2_1"> no other thread can acquire locks on elements in <code>list</code>
</label>
</div>
<span id="answer_exam-09-array-list_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-09-array-list_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-09-array-list_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="ArrayList" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-09-array-list" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-09-array-list">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-09-array-list-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-09-array-list-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-09-array-list-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
<div class="vert vert-5" data-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-synchronized-list">
<div class="xblock xblock-public_view xblock-public_view-problem xmodule_display xmodule_ProblemBlock" data-has-score="True" data-runtime-class="LmsRuntime" data-graded="True" data-request-token="3f15f38ce9a511efbd7612d4917dea95" data-runtime-version="1" data-block-type="problem" data-course-id="course-v1:MITx+6.005.2x+1T2017" data-init="XBlockToXModuleShim" data-usage-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-synchronized-list">
<script type="json/xblock-args" class="xblock-json-init-args">
{"xmodule-type": "Problem"}
</script>
<div id="problem_exam-09-synchronized-list" class="problems-wrapper" role="group"
aria-labelledby="exam-09-synchronized-list-problem-title"
data-problem-id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-synchronized-list" data-url="/courses/course-v1:MITx+6.005.2x+1T2017/xblock/block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-synchronized-list/handler/xmodule_handler"
data-problem-score="0.0"
data-problem-total-possible="1.0"
data-attempts-used="0"
data-content="
<h3 class="hd hd-3 problem-header" id="exam-09-synchronized-list-problem-title" aria-describedby="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-synchronized-list-problem-progress" tabindex="-1">
Synchronized lists
</h3>
<div class="problem-progress" id="block-v1:MITx+6.005.2x+1T2017+type@problem+block@exam-09-synchronized-list-problem-progress"></div>
<div class="problem">
<div>
<p>Suppose <code>sharedList</code> is a <code>List</code> returned by <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Collections.html#synchronizedList-java.util.List-"><code>Collections.synchronizedList</code></a>.</p>
<p>It is now safe to use <code>sharedList</code> from multiple threads without acquiring any locks... except! Which of the following would require a <code>synchronized(sharedList) { ... }</code> block?</p>
<div class="wrapper-problem-response" tabindex="-1" aria-label="Question 1" role="group"><div class="choicegroup capa_inputtype" id="inputtype_exam-09-synchronized-list_2_1">
<fieldset aria-describedby="status_exam-09-synchronized-list_2_1">
<div class="field">
<input type="checkbox" name="input_exam-09-synchronized-list_2_1[]" id="input_exam-09-synchronized-list_2_1_choice_0" class="field-input input-checkbox" value="choice_0"/><label id="exam-09-synchronized-list_2_1-choice_0-label" for="input_exam-09-synchronized-list_2_1_choice_0" class="response-label field-label label-inline" aria-describedby="status_exam-09-synchronized-list_2_1"> call <code>isEmpty</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-synchronized-list_2_1[]" id="input_exam-09-synchronized-list_2_1_choice_1" class="field-input input-checkbox" value="choice_1"/><label id="exam-09-synchronized-list_2_1-choice_1-label" for="input_exam-09-synchronized-list_2_1_choice_1" class="response-label field-label label-inline" aria-describedby="status_exam-09-synchronized-list_2_1"> call <code>add</code>
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-synchronized-list_2_1[]" id="input_exam-09-synchronized-list_2_1_choice_2" class="field-input input-checkbox" value="choice_2"/><label id="exam-09-synchronized-list_2_1-choice_2-label" for="input_exam-09-synchronized-list_2_1_choice_2" class="response-label field-label label-inline" aria-describedby="status_exam-09-synchronized-list_2_1"> iterate over the list
</label>
</div>
<div class="field">
<input type="checkbox" name="input_exam-09-synchronized-list_2_1[]" id="input_exam-09-synchronized-list_2_1_choice_3" class="field-input input-checkbox" value="choice_3"/><label id="exam-09-synchronized-list_2_1-choice_3-label" for="input_exam-09-synchronized-list_2_1_choice_3" class="response-label field-label label-inline" aria-describedby="status_exam-09-synchronized-list_2_1"> call <code>isEmpty</code>, if it returns false, call <code>remove(0)</code>
</label>
</div>
<span id="answer_exam-09-synchronized-list_2_1"/>
</fieldset>
<div class="indicator-container">
<span class="status unanswered" id="status_exam-09-synchronized-list_2_1" data-tooltip="Not yet answered.">
<span class="sr">unanswered</span><span class="status-icon" aria-hidden="true"/>
</span>
</div>
</div></div>
<div class="solution-span">
<span id="solution_exam-09-synchronized-list_solution_1"/>
</div></div>
<div class="action">
<input type="hidden" name="problem_id" value="Synchronized lists" />
<div class="submit-attempt-container">
<button type="button" class="submit btn-brand" data-submitting="Submitting" data-value="Submit" data-should-enable-submit-button="True" aria-describedby="submission_feedback_exam-09-synchronized-list" >
<span class="submit-label">Submit</span>
</button>
<div class="submission-feedback" id="submission_feedback_exam-09-synchronized-list">
<span class="sr">Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.</span>
</div>
</div>
<div class="problem-action-buttons-wrapper">
</div>
</div>
<div class="notification warning notification-gentle-alert
is-hidden"
tabindex="-1">
<span class="icon fa fa-exclamation-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-09-synchronized-list-problem-title">
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification warning notification-save
is-hidden"
tabindex="-1">
<span class="icon fa fa-save" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-09-synchronized-list-problem-title">None
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
<div class="notification general notification-show-answer
is-hidden"
tabindex="-1">
<span class="icon fa fa-info-circle" aria-hidden="true"></span>
<span class="notification-message" aria-describedby="exam-09-synchronized-list-problem-title">Answers are displayed within the problem
</span>
<div class="notification-btn-wrapper">
<button type="button" class="btn btn-default btn-small notification-btn review-btn sr">Review</button>
</div>
</div>
</div>
"
data-graded="True">
<p class="loading-spinner">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
<span class="sr">Loading…</span>
</p>
</div>
</div>
</div>
</div>
</div>