Question 1
Which of the following best describes a static data structure?No clue? Show me the answer
Correct answer
Correct!
IncorrectStep-by-step walkthrough
Choose a solution method
Method #1Direct approachStep 1: Identify the key concept
The question asks for the defining characteristic of a static data structure. The core property of static structures is their fixed size set before the program runs.
Step 2: Apply the definition
A static data structure has its size fixed at compile time, meaning the memory is allocated before the program executes. It cannot grow or shrink during runtime.
Step 3: Select the correct option
The option 'A structure whose size is determined at compile time and cannot change during program execution' precisely matches the definition of a static data structure.
Method #2Process of EliminationStep 1: Identify what is being asked
We need the option that correctly defines a static data structure — focusing on memory allocation timing and size flexibility.
Step 2: Eliminate 'automatically resizes'
The option 'automatically resizes itself whenever new elements are added' describes a dynamic data structure such as an ArrayList, not a static one.
Step 3: Eliminate 'pointers and non-contiguous memory'
The option about pointers and non-contiguous memory describes a linked list or other dynamic structure. Static structures use contiguous memory, not pointers.
Step 4: Eliminate 'only same data type at runtime'
Restricting elements to the same type is a feature of typed arrays in general, not the defining property of static structures. This is a distractor.
Step 5: Select the correct answer
The remaining option — 'size is determined at compile time and cannot change during program execution' — is the precise definition of a static data structure.
Question 2
A programmer declares the following in Java: ```java int[] temperatures = new int[365]; ``` Which statement best describes this data structure?No clue? Show me the answer
Correct answer
Correct!
IncorrectStep-by-step walkthrough
Choose a solution method
Method #1Direct approachStep 1: Identify the structure type
In Java,
int[] temperatures = new int[365];declares an array with a fixed size of 365. Once declared, this array cannot grow or shrink.Step 2: Apply static structure definition
A static data structure has a size fixed at compile/declaration time that does not change during execution. An array in Java with a declared size perfectly matches this definition.
Step 3: Select the correct answer
The option 'static structure because its size of 365 is fixed and cannot change at runtime' is correct. The size 365 is set at declaration and cannot be modified.
Method #2Process of EliminationStep 1: Identify what is being tested
We need to classify a Java array as static or dynamic, and identify the correct reason for that classification.
Step 2: Eliminate 'dynamic because Java manages memory'
Java's automatic garbage collection does not make an array dynamic. The array size is still fixed — memory management and structure type are separate concepts.
Step 3: Eliminate 'dynamic because it stores primitives'
Whether a structure stores primitives or objects has no bearing on whether it is static or dynamic. This option conflates unrelated concepts.
Step 4: Eliminate 'static because integer indices'
Integer indexing is a feature of arrays in general, not the reason they are static. The defining characteristic is fixed size at declaration, not indexing method.
Step 5: Select the correct answer
The option 'static structure because its size of 365 is fixed and cannot change at runtime' correctly identifies both the classification and the reason.