Stacks

15 Questions | Total Attempts: 1423

SettingsSettingsSettings
Stacks - Quiz

Questions and Answers
  • 1. 
    A stack is a data structure that implements movement of data in which format?
    • A. 

      First in first out

    • B. 

      Last in first out

    • C. 

      Random access

  • 2. 
    What are the basic operations performed on a stack?
    • A. 

      Push, pop, and peek

    • B. 

      InsertAt, removeAt, peekAt

    • C. 

      None of the above

  • 3. 
    The initializeStack() operation can only be performed when?
    • A. 

      Before the stack is used, and never after

    • B. 

      Before the stack is used, and any time the stack is empty

    • C. 

      Any time

  • 4. 
    The initializeStack() operation will always preserve any data stored in the stack before initializing it?
    • A. 

      True

    • B. 

      False

  • 5. 
    Stacks can only be implemented using a linked list?
    • A. 

      True

    • B. 

      False

  • 6. 
    What approaches are generally used for implementing a stack data structure?
    • A. 

      Stacks can only be implemented with a generic class

    • B. 

      Stacks are implemented using either an array or a linked list

    • C. 

      Stacks can only be implemented using the operating system resources for a stack

  • 7. 
    What generally happens when the pop operation is performed on an empty stack?
    • A. 

      The null reference is returned

    • B. 

      The StackUnderflowException is thrown

    • C. 

      None of the above

  • 8. 
    What is the basic tasks performed by the constructor of an array based stack?
    • A. 

      Initialize the stack size; set the stack to empty; create the array

    • B. 

      Nothing since the push operation will initialize the array if needed

    • C. 

      Create a default node for the head of the stack

  • 9. 
    What generally happens when the push operation is performed on an array based stack that is full?
    • A. 

      Deletes the first item in the stack to make room for the new item

    • B. 

      Throws the StackOverflowException

    • C. 

      None of the above

  • 10. 
    The benefit of a linked list based stack over an array based one is what?
    • A. 

      There are no benefits, just coded differently

    • B. 

      The linked list stack must use generic classes to work

    • C. 

      The linked list stack does not have a fixed size

  • 11. 
    The stackTop instance variable is used in both array and linked list stacks. What is the difference in each?
    • A. 

      Both uses point to the head node

    • B. 

      The array uses it as an index and the linked list uses it as a node pointer

    • C. 

      None of the above

  • 12. 
    Stacks are used to store what type of data?
    • A. 

      Homogeneous data

    • B. 

      Heterogeneous data

    • C. 

      A very limited set of data types such as integers, strings

  • 13. 
    The followng code is most likely found in which method of the linked list stack? return (stackTop == null);
    • A. 

      In the pop() method

    • B. 

      In the isEmptyStack() method

    • C. 

      In the isFullStack() method

  • 14. 
    The peek() method of the linked list stack must first check for what condition?
    • A. 

      A full stack

    • B. 

      An empty stack

    • C. 

      None of the above

  • 15. 
    The following code is most likely found in which method of a linked list stack? first = first.link;
    • A. 

      The peek() method

    • B. 

      The push() method

    • C. 

      The pop() method

Back to Top Back to top