CSCI 1302 Computer Science Exam Quiz!

29 Questions | Attempts: 1173
Share

SettingsSettingsSettings
CSCI 1302 Computer Science Exam Quiz! - Quiz

Did you know the capacity of an ArrayList grows automatically and is used in the Java language? Computer science allows you to solve complicated and challenging problems. This science involves computer language that employs the ArrayList. These listings are important because they help with the flow of the programs such as Java, Python, and Swift. So, go with the flow and try the quiz; you will learn about the importance of the Array!


Questions and Answers
  • 1. 
    A constructor for an array-based list takes an integer parameter, to be used as the capacity of the internal array of the list. Which exception should the constructor throw if its parameter is zero or negative?
    • A. 

      IllegalStateException

    • B. 

      NullPointerException

    • C. 

      IllegalArgumentException

    • D. 

      RuntimeException

  • 2. 
    An ArrayList is so called because:
    • A. 

      You can use array subscript notation to work with the ArrayList

    • B. 

      You can pass it as a parameter to any method that expects an array

    • C. 

      It is implemented as a class that uses an internal array to hold the elements of the list

    • D. 

      All of these

  • 3. 
    A new element is added to an ArrayList object at index k. Assuming the list has size s and does not have to be resized.
    • A. 

      The elements at current positions k..s must be moved toward the end of the array

    • B. 

      The element at position k is overwritten

    • C. 

      The elements at current positions 0..k must be moved toward the beginning of the list

    • D. 

      The elements at current positions k..s-1 must be moved toward the end of the array

  • 4. 
    The boolean contains(E element) method searches an ArrayList for a given element. Correct and efficient implementation of this method.
    • A. 

      Uses sequential search to locate the element

    • B. 

      Returns 0 if the element is not found in the list

    • C. 

      Uses binary search to locate the element

    • D. 

      Throws an exception if the element is not found in the list

  • 5. 
    The int indexOf(Object o) method of the List interface.
    • A. 

      Adds an object to a list and returns the index of the newly added object

    • B. 

      Uses binary search to locate the given object, and then returns its index

    • C. 

      Searches a list for the occurrence of an object and returns its index

    • D. 

      None of these

  • 6. 
    The size of an array-based list such as ArrayList.
    • A. 

      None of these

    • B. 

      Is the length of its internal array

    • C. 

      Is the number of elements that are currently stored in the list

    • D. 

      Is the number of bytes of memory that the list can hold

  • 7. 
    The capacity of an array-based list such as ArrayList.
    • A. 

      Is the number of bytes of memory that the list can hold

    • B. 

      is the size of its internal array

    • C. 

      Is the number of elements that are currently stored in the list

    • D. 

      None of these

  • 8. 
    Scientists in a certain laboratory are working with a linked list class that uses recursion to compute its size. The scientists know that an empty list has size 0, so they never ask a linked list to compute its size when the list is empty. Under these circumstances:
    • A. 

      the recursive method should still handle the base case of an empty list, because it will still occur even though the scientists never ask for the size of an empty list and the recursive method can be modified to use a list of size 1 as the base case are both correct

    • B. 

      The recursive method can become more efficient by eliminating the test for a base case

    • C. 

      The recursive method should still handle the base case of an empty list, because it will still occur even though the scientists never ask for the size of an empty list

    • D. 

      the recursive method can be modified to use a list of size 1 as the base case

  • 9. 
    A collection that is accessed in first in first out fashion is called?
    • A. 

      A stack

    • B. 

      A queue

    • C. 

      A linked list

    • D. 

      An array based collection

  • 10. 
    The stack method that returns an element from the stack without removing it is:
    • A. 

      Peek

    • B. 

      Pop

    • C. 

      Push

    • D. 

      Spy

  • 11. 
    If the stack method push is called on an empty stack.
    • A. 

      None of the above

    • B. 

      It calls the stack empty

    • C. 

      It throws an emptystackexception

    • D. 

      It adds it argument to the stack

  • 12. 
    When using an array to implement a stack, the push method will wrap around to the beginning of the stack when it reaches the end.
    • A. 

      True

    • B. 

      False

  • 13. 
    In a linked list implementation using a reference first to point to the first node of the list, a method isEmpty() can test to see if the list is empty by executing the statement(s)
    • A. 

      If (isEmpty()) return true; else return false;

    • B. 

      Return first == null;

    • C. 

      Return null;

    • D. 

      First = null; return first;

  • 14. 
    To allocate storage for its elements, an array-based list such as ArrayList uses:
    • A. 

      Linked allocation

    • B. 

      Contiguous allocation

    • C. 

      Capacity allocation

    • D. 

      Fixed size allocation

  • 15. 
    The objects that form the units of memory allocation in a linked list are called?
    • A. 

      Elements

    • B. 

      Memory modules

    • C. 

      Nodes

    • D. 

      Memory modules

  • 16. 
    A list can be considered a recursive data structure because:
    • A. 

      Linked allocation

    • B. 

      If you remove the head of the list, what remains is also a list

    • C. 

      Contiguous allocation

    • D. 

      A list can be considered a recursive data structure because

  • 17. 
    In a typical circular doubly linked list, a node has:
    • A. 

      A field to store the element, and two references to keep track of two predecessor nodes, and a reference to keep track of the end of the list

    • B. 

      Either one of a field to store the element, and two references to keep track of two successor nodes, and a reference to keep track of the start of the list or a field to store the element, and two references to keep track of two predecessor nodes, and a reference to keep track of the end of the list

    • C. 

      a field to store the element, and two references to keep track of successor and predecessor nodes

    • D. 

      a field to store the element, and two references to keep track of two successor nodes, and a reference to keep track of the start of the list

  • 18. 
    A list can be considered a recursive data structure because:
    • A. 

      A list can be considered a recursive data structure because

    • B. 

      None of these: only methods can be considered recursive.

    • C. 

      List objects are instances of list classes

    • D. 

      if you remove the head of the list, what remains is also a list

  • 19. 
    In order to use recursion on linked lists:
    • A. 

      It is necessary to modify the class that represents nodes, by adding a reference needed to support recursion

    • B. 

      the class that represents nodes must implement the Repeatable interface

    • C. 

      No changes to the node class are necessary

    • D. 

      it is necessary to modify the class that represents nodes, by adding a reference needed to support recursion and the class that represents nodes must implement the Repeatable interface are both true

  • 20. 
    To remove a node with a positive index k from a linked list,
    • A. 

      assign the successor reference in the node with index k to the successor reference in the node with index k-1

    • B. 

      Start a reference r at the head of the list, walk r forward k steps, and then set r to null

    • C. 

      Decrement k by 1, and then use recursion

    • D. 

      Decrement k by 1, and set the reference to the node to be removed to null

  • 21. 
    A list is a collection that:
    • A. 

      Associates keys with elements

    • B. 

      None of the above

    • C. 

      Assigns an index to each of its elements

    • D. 

      Is implemented by the JList class

  • 22. 
    To add an element e just after a node referenced by ref, you should use the statement.
    • A. 

      Ref.next = new node (e, ref.next);

    • B. 

      Ref = new node(e, ref.next);

    • C. 

      Add(ref);

    • D. 

      Ref.next = new node(e);

  • 23. 
    A systematic method that starts at the beginning of the list and processes every node is called?
    • A. 

      A travesty of list processing

    • B. 

      A traversal

    • C. 

      A walk down the list

    • D. 

      A list processing function

  • 24. 
    A binary tree is a collection of items in which each item?
    • A. 

      Has no successor

    • B. 

      Has exactly two successors

    • C. 

      Has at most two successors

    • D. 

      Has one successor

  • 25. 
    The head of a linked list is also a linked list.
    • A. 

      True

    • B. 

      False

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.