Data Types MCQs

100 MCQs  (Page 10 of 10)

Does a Python dict preserve the order in which keys were inserted?
Only when OrderedDict is imported
Only for integer keys
No, order is random
Yes, guaranteed by the language since Python 3.7
Can a frozenset be an element of a set or a dictionary key?
Yes, because it is immutable and hashable
Only when it is empty
No, sets cannot be nested in any form
Only in Python 2
Which statement about a = 256; b = 256; a is b in CPython is most accurate?
It is usually True because of small-integer caching, but that is an implementation detail; use == to compare values
It is always False
It raises a TypeError
The language guarantees True for every integer
Which description of JavaScript's typing is correct?
Dynamically and strongly typed
Statically and weakly typed
Statically and strongly typed
Dynamically and weakly typed
In JavaScript, what are typeof null and typeof NaN?
"object" and "undefined"
"undefined" and "number"
"null" and "NaN"
"object" and "number"
Which pairing of abstract data type and access order is correct?
Both are FIFO
Stack: LIFO; Queue: FIFO
Both are LIFO
Stack: FIFO; Queue: LIFO
What is the average-case and worst-case lookup time of a hash table?
O(log n) in both cases
Average O(1); worst O(n)
O(1) in both cases
Average O(n); worst O(1)
Which statement best defines an Abstract Data Type (ADT)?
A data type built into the hardware
A class with only private members
A data type that cannot be instantiated
A type defined by its operations and behavior, independent of how it is implemented