Which of the following is commonly used in programming languages to store and…
2024
Which of the following is commonly used in programming languages to store and represent a sequence of characters?
- A.
String
- B.
Stack
- C.
Queue
- D.
Tree
- E.
Graph
Attempted by 309 students.
Show answer & explanation
Correct answer: A
Concept
Programming languages need a dedicated data type to hold text — an ordered run of characters such as letters, digits, spaces and symbols kept together, in sequence, as a single value. The data type built for exactly this purpose is the string: it stores and represents a sequence of characters as one text value.
Applying it here
The question asks what is commonly used to hold a sequence of characters. When you need text like a word, a name or a sentence, you declare it as a string (for example "Hello" or "Roll No 72"). The characters sit one after another in the exact order written, and the language gives operations such as length, concatenation and indexing to work on that ordered sequence.
Why not the others
Stack, Queue, Tree and Graph are general-purpose data structures defined by how elements are organised and accessed, not by being a textual sequence of characters:
Stack: last-in-first-out access (undo history, call tracking).
Queue: first-in-first-out access (scheduling, buffering in arrival order).
Tree: a parent-child hierarchy (file systems, search trees).
Graph: nodes joined by arbitrary connections (networks, relationships).
Each of these can hold characters, but none of them is the standard built-in type meant to store and represent character text the way a string is.