Get 2 days of unlimited access
Study Guides (350,000)
US (190,000)
UMD (10,000)
CMSC (700)
Final

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


Department
Computer Science
Course Code
CMSC 131
Professor
Fawzi Emad
Study Guide
Final

This preview shows pages 1-3. to view the full 11 pages of the document.
1
University of Maryland College Park
Dept of Computer Science
CMSC131 Fall 2017
Midterm II
Last Name (PRINT): _____________________________________________________
First Name (PRINT): _____________________________________________________
University Directory ID (e.g., umcpturtle)_____________________________________
I pledge on my honor that I have not given or received any unauthorized assistance on this examination.
Your signature: _____________________________________________________________
Instructions
This exam is a closed-book and closed-notes exam.
Total point value is 200 points.
The exam is a 50 minutes exam.
Please use a pencil to complete the exam.
WRITE NEATLY.
There are four problems in the exam.
You do not need any import statements for coding questions.
Your code must be efficient.
You don’t need to use meaningful variable names; however, we expect good indentation.
You must stop writing when time is up; make sure you write your name now.
Grader Use Only
#1
Problem #1 (General Questions)
(20)
#2
Problem #2 (Memory Map)
(30)
#3
Problem #3 (Class Definition)
(95)
#4
Problem #4 (String Manipulation)
(55)
Total
Total
(200)

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

2

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

3
Problem #1 (General Questions)
1. (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.
a. Stack
b. Heap
c. Area where static variable resides.
d. None of the above.
2. (3 pts) A method should be defined as static if (circle all that apply):
a. Makes no reference to instance variables.
b. Makes a reference to at least one instance variable.
c. Makes a reference to static method.
d. None of the above.
3. (3 pts) Which of the following represents “no address”? Circle all that apply.
a. 0
b. null
c. false
d. None of the above.
4. (3 pts) How many objects are present in the following code fragment?
StringBuffer b;
int x = 10;
Number of Objects: ____
5. (3 pts) When is the code associated with a finally block executed?
a. Only when the exception occurs.
b. Always
c. Only if no exception occurs.
d. None of the above.
6. (3 pts) What is the actual task a constructor method performs?
a. Creating the object in the stack.
b. Initializing the object.
c. Moving the object from the stack to the heap.
d. None of the above.
7. (2 pts) Which of the following applies to the “this” reference?
a. It is a reference to the current object.
b. Can be used by both static and non-static methods.
c. It is initialized for you.
d. None of the above.
You're Reading a Preview

Unlock to view full version