QUESTIONS AND CORRECT DETAILED ANSWERS WITH RATIONALES (VERIFIED
ANSWERS) |AGRADE
Question 1
Which statement best describes a queue data structure?
A) It is a sequence of elements in which insertion and deletion take place at one end.
B) It is a sequence of elements in which insertion and deletion take place at both ends.
C) It is a sequence of elements where insertion can take place anywhere but deletion is at the
front.
D) It is a sequence of elements where insertions take place at the back and deletions at the front.
E) It is a hierarchical structure where each element points to two other elements.
Correct Answer: D) It is a sequence of elements where insertions take place at the back and
deletions at the front.
Rationale: A queue follows the First-In, First-Out (FIFO) principle. This means the first
element added to the structure (at the back/rear) is the first one to be removed (from the
front).
Question 2
Which data structure allows for the insertion and deletion of data elements at both the front and
the rear ends?
A) Binary Tree
B) Deque
C) Stack
D) Queue
E) Singly Linked List
Correct Answer: B) Deques
Rationale: A Deque, or double-ended queue, is a generalized data structure that supports
adding and removing elements from both ends (front and back) with O(1) efficiency.
Question 3
Which data structure allows elements to be inserted and deleted from only one end and provides
no direct access to the other end?
A) Doubly Linked List
B) Deque
C) Stack
D) Circular Queue
E) Hash Table
Correct Answer: C) Stack
Rationale: A stack follows the Last-In, First-Out (LIFO) principle. All operations (push and
pop) occur at the "top" of the stack, meaning the last item placed on the stack is the first
one retrieved.
, 2
Question 4
Given the declaration int[] list01 = {0, 2, 4, 6, 8, 10};, what are the official indexes for this
array?
A) 0, 1, 2, 3, 4, 5
B) 0, 2, 4, 6, 8, 10
C) 1, 2, 3, 4, 5, 6
D) -1, 0, 1, 2, 3, 4
E) 0, 1, 2, 4, 8, 10
Correct Answer: A) 0, 1, 2, 3, 4, 5
Rationale: In almost all modern programming languages (Java, Python, C++), arrays and
lists use zero-based indexing. Since there are six elements in the list, the indexes range from
0 to 5.
Question 5
Which Abstract Data Type (ADT) consists of elements of the same type that can be retrieved
specifically based on their index or position?
A) List
B) Bag
C) Stack
D) Set
E) Queue
Correct Answer: A) List
Rationale: A list is an ordered collection of elements where each item has a specific position
(index). This distinguishes it from a "Bag" (unordered) or a "Set" (no duplicates and often
unordered).
Question 6
Which data type would be returned by the following function?
return_type mystery (int R) { int NumUnits = R; return NumUnits * 3.14; }
A) Byte
B) String
C) Double
D) Boolean
E) Integer
Correct Answer: C) Double
Rationale: The function returns the result of NumUnits * 3.14. Since 3.14 is a floating-point
literal (a double in Java/C++), the resulting product will be a floating-point value,
requiring a Double or Float return type.
Question 7
In the Python snippet mid_value, date = middle(("FB", 75.00, 75.03, 74.90), datetime.date(2014,
, 3
10, 31)), what data structure is represented by ("FB", 75.00, 75.03, 74.90)?
A) List
B) Float
C) Tuple
D) Set
E) Dictionary
Correct Answer: C) Tuple
Rationale: In Python, parentheses () are used to define a tuple. Tuples are immutable
ordered sequences, whereas square brackets [] define lists and curly braces {} define
dictionaries or sets.
Question 8
Which value is appropriate for the variable Test1 given the expression char Test1;?
A) 'L'
B) 77
C) 6.5
D) "value"
E) True
Correct Answer: A) 'L'
Rationale: The char data type stores a single character, which is represented using single
quotes (e.g., 'L'). Double quotes signify a string, and numbers without quotes represent
integers or floats.
Question 9
What type of operation is represented in the pseudocode: int x,y,z; x=y=z=100;?
A) Ternary
B) Assignment
C) Comparison
D) Equality
E) Declaration only
Correct Answer: B) Assignment
Rationale: The = operator is the assignment operator. In this specific case, it is a "chained
assignment" where the value 100 is being assigned to variables z, y, and x.
Question 10
What is the most efficient data structure to use for a data set of a fixed size where elements need
to be accessed frequently by index?
A) Linked List
B) Tuple
C) Array
D) Dictionary
, 4
E) Stack
Correct Answer: C) Array
Rationale: Arrays provide O(1) time complexity for accessing elements by index. Because
they occupy contiguous memory blocks, they are more efficient for fixed-size data sets
compared to linked lists, which require traversal.
Question 11
Which data type is most appropriate for the following array? a = ["AF", "71", "BC", "157"]
A) Byte
B) Char
C) Short
D) String
E) Float
Correct Answer: D) String
Rationale: The elements are enclosed in double quotes and consist of multiple characters
(alphanumeric). This identifies the data as strings. A char would only hold a single
character.
Question 12
Which data type should be used for the variable phoneNum = "212-555-1212"?
A) Long
B) Short
C) String
D) Integer
E) Double
Correct Answer: C) String
Rationale: While a phone number consists of digits, it also contains non-numeric characters
like hyphens. Additionally, phone numbers are not used for mathematical calculations, so
they are stored as strings.
Question 13
What is true about automatic garbage collection in programming languages like Java?
A) It is the same as manual memory management.
B) It is no longer necessary in modern computing.
C) It prevents all memory leaks automatically.
D) It reclaims memory from objects that are no longer reachable or referenced.
E) It only reclaims memory from the stack, not the heap.
Correct Answer: D) It reclaims memory from objects that are no longer reachable or
referenced.
Rationale: Garbage collection is a background process that identifies objects on the heap