Stack Memory

8 Questions | Total Attempts: 234

SettingsSettingsSettings
Please wait...
Memory Quizzes & Trivia

Questions and Answers
  • 1. 
    Stack memory is used to store
    • A. 

      Machine language instructions for the program itself

    • B. 

      Temporary data needed only for the duration of a method call

    • C. 

      Objects

  • 2. 
    Assuming that the assignment statement below is valid, what is the return type of doit()?                                                                                                                          Widget w = doit();                                                                            
    • A. 

      It's the value returned by doit(), either null or a heap address

    • B. 

      Widget

    • C. 

      You can't tell from the code supplied, you need to see the method header of doit().

  • 3. 
    A stack overflow occurs when
    • A. 

      The program runs out of space because so many objects have been created

    • B. 

      A method is called which calls itself

    • C. 

      The program runs out of space because a method was called but there is not enough memory to store its "stack frame"

  • 4. 
    Assume the statement "x = 10;" occurs within a method whose enclosing class has an instance variable called x. Under what circumstances will 10 be assigned to the instance variable?
    • A. 

      If the method doesn't have a parameter called x.

    • B. 

      If the method doesn't have a local variable called x within scope of the assignment statement.

    • C. 

      If both A and B are true

  • 5. 
    Assuming that within a method foo(), a local Widget variable is declared and assigned a value like so: Widget w = new Widget().  Check ALL the statements that are true after foo() is exited  
    • A. 

      The Widget is orphaned.

    • B. 

      The variable w is out of scope.

    • C. 

      The Widget may or may not be orphaned (if it is returned it may not be orphaned).

  • 6. 
    Software developers often use the names "foo" and "bar" when writing sample code. Which statement is true?
    • A. 

      Although it's a tradition, the names have no special meaning.

    • B. 

      "fubar" is an old miitary term whose meaning rhymes with "mucked up beyond all repair"

    • C. 

      This convention is only true at Penn.

  • 7. 
    Please give us some feedback about the "Scratch Debugems" that we used a lab earlier in the semester. Recall that we supplied Scratch projects (TimerCat, EweAndMe, Dance, HelloList) that were broken and your task was to fix them. Choose the answer the best applies. (In the next question we ask you to explain your answer.)
    • A. 

      Solving Debugems was helpful in learning programming concepts.

    • B. 

      Solving Debugems was not helpful in learning programming concepts.

    • C. 

      I did not work on the Debugems (or can not answer yes or no for some other reason).

  • 8. 
    Please explain your answer about Scratch Debugems.