Arrays and Strings Fundamentals Quiz Quiz

Test your foundational knowledge of arrays and strings, covering essential concepts, basic operations, and key terminology with these beginner-friendly questions.

  1. Indexing in Arrays

    What is the correct index for the first element in an array with five elements?

    1. First
    2. 1
    3. 5
    4. -1
    5. 0
  2. String Length Function

    Given the string 'hello', what will the length function return?

    1. 4
    2. 0
    3. 6
    4. 5
    5. h
  3. Accessing Array Elements

    Which syntax correctly accesses the third element of an array named 'items'? Assume 0-based indexing.

    1. items:3
    2. items[3]
    3. items[2]
    4. items(3)
    5. items.3
  4. Immutable Data Types

    Which data type is considered immutable, meaning it cannot be changed after creation?

    1. Vector
    2. Array
    3. String
    4. List
    5. Stack
  5. Concatenation Operation

    What does the operation 'apple' + 'pie' produce in most programming languages?

    1. applepie
    2. apple+pie
    3. appleu0026pie
    4. apple pie
    5. pieapple
  6. Finding an Element

    Which method would you typically use to find the position of an element 'x' in an array?

    1. remove
    2. split
    3. merge
    4. add
    5. indexOf
  7. Reversing Strings

    If you reverse the string 'race', what is the resulting output?

    1. race
    2. acer
    3. ecar
    4. acer
    5. era c
  8. Array Size Consistency

    After creating an array of size 10, what happens if you try to insert an 11th element?

    1. It automatically resizes
    2. An error occurs
    3. The array is sorted
    4. The first element is overwritten
    5. It returns null
  9. Iterating Over Arrays

    What is the primary reason for using a for loop with arrays?

    1. To reverse the order
    2. To convert to a string
    3. To process each element
    4. To make a copy
    5. To remove duplicates
  10. Substring Extraction

    Given the string 'sunshine', which operation extracts 'sun'?

    1. substring(0,3)
    2. cut(0,2)
    3. slice(3,6)
    4. substr(3)
    5. substring(3,6)