These exercises work with the following two classes:
What does calling question1()
return?
Choices:
What does calling question2()
return?
Choices:
What does calling question4()
return?
Choices
What does calling question6()
return?
Choices
Don't go past here until Kathi says so
https://hackmd.io/@csci0200/rJCsizE6K
Don't go past here until Kathi says so
Consider the following simple interface for lists:
In your own words, what is the difference between a mutable list and an immutable list? Write no more than 2 sentences.
Assume you’re using a class MysteryList
that implements IList
, but you don’t know whether MysteryList
implements mutable or immutable lists. Finish the following test case so that it will pass only if MysteryList
implements immutable lists.
Now assume you are implementing an immutable list class from a chain of Node
objects, where the fields are as follows (constructors are omitted for conciseness.
Draw the memory diagram that should exist after running the following line of code (include both environment and heap):
Circle the diagram you have drawn so far (this will distinguish your diagram on the previous expression from the additions in the rest of the question).
Extend the diagram (outside the circle) to include the expected results of subsequently running the following line of code (we know you don’t have the implementation – the point of the question is for you to show what addLast
should do on an immutable list).