DP Computer Science · HL / SL · B2 Programming

B2.2 Data structures

Get started
Notes Quiz
Free preview 2/15
  1. Question 1

    Which of the following best describes a static data structure?
    No clue? Show me the answer
    Correct answerCorrect!Incorrect
    AA structure whose size is determined at compile time and cannot change during program execution

    Step-by-step walkthrough

    Choose a solution method

    Method #1Direct approach

    Step 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 Elimination

    Step 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.

  2. 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 answerCorrect!Incorrect
    BIt is a static structure because its size of 365 is fixed and cannot change at runtime

    Step-by-step walkthrough

    Choose a solution method

    Method #1Direct approach

    Step 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 Elimination

    Step 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.

Free preview

13 more questions in this topic

Next topic →B2.3 Programming constructs
Koncepts

Learn it properly. Then practise like it's the real paper.

Start free

Features

  • Lessons
  • Past papers
  • Library
  • Homework Help
  • Duels

More

  • For parents
  • Compare
  • Plans & pricing
  • DP for students

Legal

  • Privacy
  • Terms
  • Account deletion

© 2026 Koncepts (product of PrepAiro, Inc). All rights reserved.
DP, IB, EE and TOK are terms of the International Baccalaureate Organization.

Made for IB DP students.