CMSC 131 Study Guide - Midterm Guide: Duplicate Code, Static Variable, Instance Variable

202 views8 pages

Document Summary

I pledge on my honor that i have not given or received any unauthorized assistance on this examination. Problem #1 (general questions: (3 pts) if the garbage collector stops working which of the following can eventually be exhausted if we continue creating objects. Circle all that apply: stack, heap, area where static variable resides, none of the above. Circle all that apply: 0, null, false, none of the above. Answer: 0: (3 pts) when is the code associated with a finally block executed, only when the exception occurs, always, only if no exception occurs, none of the above. 2: (3 pts) what is the actual task a constructor method performs, creating the object in the stack, initializing the object, moving the object from the stack to the heap, none of the above. Fruit other = param; other. increasesize(20); param = null; String p = "orange"; int k = 10, m = 5;