PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are creating an undo buffer that stores data modifications.
You need to ensure that the undo functionality undoes the most recent data modifications first.
You also need to ensure that the undo buffer permits the storage of strings only.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
Stack undoBuffer = new Stack();

B.
Stack undoBuffer = new Stack();

C.
Queue undoBuffer = new Queue();

D.
Queue undoBuffer = new Queue();

Explanation:
A Stack caters for a last in first out scenario similar to what is required in an undo buffer. By using Generics you can force a strongly typed collection that takes strings only.
B is not strongly typed for strings, it will take any type of object. C & D Queue is a First in First out collection, it is not appropriate in this instance.

2 Comments on “Which code segment should you use?


Leave a Reply