logo

AQA A-Level Computer Science practice

A stack contains, from bottom to top, A, B, and C. What value is returned by peek, and what happens to the stack?

Try the question first, then check the answer and practise the same topic again.

At a glance

MCQ

Type

practice

Style

Topic

Stacks

Exam-style question

Try this first

A stack contains, from bottom to top, A, B, and C. What value is returned by peek, and what happens to the stack?.

  1. A.A is returned and removed
  2. B.B is returned and removed
  3. C.C is returned and remains in the stack
  4. D.C is returned and removed

Answer and explanation

Concise answer

C is returned and remains in the stack

Why this is correct

C is the top element. Peek, also called top, returns the top value without removing it.

Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.

Common mistake

No common mistake is linked to this question yet.

Related flashcards

No flashcards are published for this page yet.

Related practice questions