Perl Variables  «Prev  Next»

Perl Variables - Quiz

Each question is worth one point. Select the best answer for each question.
1. What is a scalar?
Please select the correct answer:
  A. A single variable
  B. A single value
  C. A numeric value

2. What is a list in Perl?
Please select the correct answer:
  A. An ordered series of scalars
  B. An unordered series of scalars
  C. A collection indexed by string keys

3. Why is the $ character used to access array members?
Please select the correct answer:
  A. Because an array is a scalar value
  B. Because array members are non-scalar values
  C. Because array members are scalar values

4. How do you get the number of elements in an array?
Please select the correct answer:
  A. Check the array in scalar context; for example, scalar @array
  B. Test for a null; for example, if (@array[$i] == 0)
  C. Use a special function or macro; for example, sizeof @array

5. Which one of the following would you use to get a single element from a hash?
Please select the correct answer:
  A. $hash{key}
  B. %hash{key}
  C. @hash[key]

6. What does the split function do?
Please select the correct answer:
  A. Removes a substring from a string, shortening it in place
  B. Creates a string by combining the elements of a list
  C. Creates a list from the parts of a string

7. What does the join function do?
Please select the correct answer:
  A. Appends one string to the end of another
  B. Creates a string from a list
  C. Merges two arrays into a single array

8. What is a stack?
Please select the correct answer:
  A. A first-in/first-out (FIFO) data structure
  B. A last-in/first-out (LIFO) data structure
  C. A structure that returns items in order of assigned priority

9. What does the push function do?
Please select the correct answer:
  A. Adds an item to the beginning of an array
  B. Removes and returns the last item of an array
  C. Adds an item to the end of an array