Array Data Structure: Trivia Quiz!

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Alyssa Daniel
A
Alyssa Daniel
Community Contributor
Quizzes Created: 1 | Total Attempts: 1,950
Questions: 19 | Attempts: 1,950

SettingsSettingsSettings
Array Data Structure: Trivia Quiz! - Quiz

.


Questions and Answers
  • 1. 

    For how many integers does the following statement reserve room? int[] value = new int[12];

    • A.

      33

    • B.

      12

    • C.

      0

    • D.

      34

    Correct Answer
    B. 12
    Explanation
    The statement "int[] value = new int[12];" reserves room for 12 integers. This is because the statement creates an array called "value" with a length of 12, which means it can hold 12 elements. Each element in the array is of type int, so the statement reserves room for 12 integers.

    Rate this question:

  • 2. 

    When you declare an array __________.

    • A.

      You might reserve the memory for it in the statement.

    • B.

      You can't reserve memory

    • C.

      Reserving memory depends on the type of array

    • D.

      You always reserve memory

    Correct Answer
    A. You might reserve the memory for it in the statement.
    Explanation
    When you declare an array, you have the option to reserve the memory for it in the statement. This means that you can specify the size or length of the array at the time of declaration, which allocates the necessary memory for storing the elements of the array. However, it is not mandatory to reserve memory at the time of declaration, as you can also dynamically allocate memory for the array later in the program. Therefore, the correct answer is "You might reserve the memory for it in the statement."

    Rate this question:

  • 3. 

    An array is a list of data items that ________.

    • A.

      All have different names

    • B.

      Are all integers

    • C.

      All have the same type

    • D.

      Are all null

    Correct Answer
    C. All have the same type
    Explanation
    An array is a data structure that can store multiple elements of the same type. This means that all the data items within an array must have the same type, whether it is integers, strings, or any other data type. By having the same type, it allows for efficient memory allocation and easy access to the elements within the array.

    Rate this question:

  • 4. 

    You reserve memory locations for an array when you ______.

    • A.

      Use the keyword new

    • B.

      Use the keyword memory

    • C.

      Store values within the array explicitly

    • D.

      Declare the name of the array

    Correct Answer
    A. Use the keyword new
    Explanation
    When you use the keyword "new" in programming, it dynamically allocates memory for an array. This means that you are reserving memory locations for the array at runtime, allowing you to store and access data within the array. By using the keyword "new", you can create an array of a specific size and ensure that the necessary memory is allocated for it.

    Rate this question:

  • 5. 

    Assume an array is declared as follows. Which of the following statements correctly assigns the value 80 to each of the array elements? int[] num = new int [3];

    • A.

      For (x = 0; x < 3; ++[x] = 100;

    • B.

      For (x = 0; x < 4; ++[x] = 100;

    • C.

      For (x = 1; x < 3; ++[x] = 100;

    • D.

      For (x = 1; x < 5; ++[x] = 100;

    Correct Answer
    A. For (x = 0; x < 3; ++[x] = 100;
    Explanation
    The correct answer is the for loop "for (x = 0; x < 3; ++[x] = 100;". This loop iterates through each index of the array (x = 0, 1, 2) and assigns the value 100 to each element using the syntax ++[x] = 100. This will correctly assign the value 100 to each element of the array.

    Rate this question:

  • 6. 

    In Java you can declare an array of 12 elements and initialize _____.

    • A.

      All of them

    • B.

      The first one only

    • C.

      Both of these

    • D.

      Neither of these

    Correct Answer
    A. All of them
    Explanation
    In Java, when declaring an array of 12 elements, you have the option to initialize all of them. This means that you can assign values to each element of the array during its declaration. By doing so, you ensure that all 12 elements have specific values assigned to them from the beginning.

    Rate this question:

  • 7. 

    When you initialize an array by giving it values upon creation, you ________.

    • A.

      Also must give the array an explicit size

    • B.

      Must make all the values 0, or false

    • C.

      Don't explicitly give the array a size

    • D.

      Make certain each value is different

    Correct Answer
    C. Don't explicitly give the array a size
    Explanation
    When you initialize an array by giving it values upon creation, you don't explicitly give the array a size. This means that the size of the array is automatically determined based on the number of values provided during initialization.

    Rate this question:

  • 8. 

    Suppose you have declared an array as follows; int[] creditScores = {670, 840, 576, 740, 820}

    • A.

      0

    • B.

      4

    • C.

      2

    • D.

      5

    Correct Answer
    D. 5
    Explanation
    The given answer, 5, is the index of the last element in the array. In Java, array indices start from 0, so the first element is at index 0 and the last element is at index 4. Therefore, the correct answer is 4.

    Rate this question:

  • 9. 

    Unicode value '\u0000' is also know as _____.

    • A.

      Nada

    • B.

      Nope

    • C.

      Null

    • D.

      Void

    Correct Answer
    C. Null
    Explanation
    The Unicode value '\u0000' is also known as "null".

    Rate this question:

  • 10. 

    Array names represent

    • A.

      Allusions

    • B.

      Functions

    • C.

      Values

    • D.

      Refrences

    Correct Answer
    D. Refrences
    Explanation
    Array names represent references because when an array is declared, it is actually a pointer to the first element of the array. This means that the array name holds the memory address of the first element, allowing us to access and manipulate the elements of the array using the array name. Therefore, array names act as references to the array elements.

    Rate this question:

  • 11. 

    Which of the following can be used as an array subscript?

    • A.

      Int

    • B.

      Double

    • C.

      String

    • D.

      Character

    Correct Answer
    A. Int
    Explanation
    An array subscript is used to access elements within an array. In most programming languages, including C++, the array subscript must be an integer value. Therefore, only "int" can be used as an array subscript among the given options. "double" is a floating-point data type, "string" is a sequence of characters, and "character" is a single character data type, none of which can be used as an array subscript.

    Rate this question:

  • 12. 

    If you declare an array as follows, how do you indicate the final element of the array? int[] num = new int[5];

    • A.

      Num[4]

    • B.

      Num[6]

    • C.

      Num[0]

    • D.

      I don't know

    Correct Answer
    A. Num[4]
    Explanation
    To indicate the final element of the array, you use the index value of the last element, which in this case is num[4]. The index values start from 0, so num[4] refers to the fifth element in the array.

    Rate this question:

  • 13. 

    You declare an integer array as follows, what is the value of num[4]? int[] num = { 204, 348, 795, 111, 45, 86}

    • A.

      86

    • B.

      111

    • C.

      204

    • D.

      45

    Correct Answer
    D. 45
    Explanation
    The value of num[4] is 45. In the given code, an integer array named "num" is declared and initialized with 6 elements. The index of an array starts from 0, so num[4] refers to the fifth element in the array, which is 45.

    Rate this question:

  • 14. 

    If a class named Student contains a method setID() that takes an int argument and you write an application in which you create an array of 20 Student objects named scholar, which of the following statements correctly assigns an ID number to the first Student scholar?

    • A.

      Student.setID[0](1234)

    • B.

      Student[0].setID(1234)

    • C.

      Scholar[0].setID(1234)

    • D.

      Scholar.setID[0] (1234)

    Correct Answer
    C. Scholar[0].setID(1234)
    Explanation
    The correct statement that assigns an ID number to the first Student scholar is scholar[0].setID(1234). This is because scholar is an array of Student objects, and to access the first element of the array, we use the index [0]. Then, we call the setID() method on the first element to assign the ID number 1234.

    Rate this question:

  • 15. 

    A parallel array is one that _____?

    • A.

      Holds an even number of values

    • B.

      Holds values that correspond to those in another array

    • C.

      Is placed adjacent to another array in code

    • D.

      Is placed adjacent to another array in memory

    Correct Answer
    B. Holds values that correspond to those in another array
    Explanation
    A parallel array is an array that holds values that correspond to those in another array. This means that the elements in the parallel array have a relationship or connection with the elements in the other array. The values in the parallel array are typically associated or linked to the values in the corresponding positions of the other array. This allows for easier access and manipulation of related data in the program.

    Rate this question:

  • 16. 

    When you pass an array element to a method, the method receives ________?

    • A.

      The array address

    • B.

      A copy of the value in the element

    • C.

      A copy of the array

    • D.

      The address of the element

    Correct Answer
    B. A copy of the value in the element
    Explanation
    When you pass an array element to a method, the method receives a copy of the value in the element. This means that any changes made to the element within the method will not affect the original array. The method operates on a separate copy of the value, allowing for independent manipulation without altering the original data.

    Rate this question:

  • 17. 

    If a method should return an array to its calling method ______>

    • A.

      The method's return type must match the parameter

    • B.

      The return type in the method header is followed by square brackets

    • C.

      The Java method can't return an array

    • D.

      The method's return type has an ampersand

    Correct Answer
    B. The return type in the method header is followed by square brackets
    Explanation
    When a method should return an array to its calling method, the return type in the method header is followed by square brackets. This indicates that the method will return an array of a specific type. For example, if the return type is "int[]", it means that the method will return an array of integers. This is necessary because it allows the calling method to correctly receive and handle the returned array.

    Rate this question:

  • 18. 

    A single array element of a primitive type is passed to a method by _____.

    • A.

      Value

    • B.

      Reference

    • C.

      Address

    • D.

      Osmosis

    Correct Answer
    A. Value
    Explanation
    When a single array element of a primitive type is passed to a method by value, it means that a copy of the value of the element is passed to the method. Any changes made to the value within the method will not affect the original value in the array.

    Rate this question:

  • 19. 

    When you pass an array to a method, the method receives _____.

    • A.

      Nothing

    • B.

      The array address

    • C.

      A copy of the first element in the array

    • D.

      A copy of the array

    Correct Answer
    B. The array address
    Explanation
    When you pass an array to a method, the method receives the memory address of the array. This means that the method can access and modify the elements of the array directly, as it has the location of the array in memory. The method does not receive a copy of the array or its elements, but rather a reference to the original array. Therefore, any changes made to the array within the method will be reflected in the original array outside of the method as well.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 16, 2018
    Quiz Created by
    Alyssa Daniel
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.