Mid Term Question
BCS204 E Object Orient Programming Midterm
Note: Choose the best answer among those provided. When you complete the test, Save the file as yourlastname_204midterm.doc. Submit the file to my email. The exam is due back to me no later than 11:59 PM on Sunday November 17, 2019.
1. There are two memory structures within the Java Virtual Machine that deal with objects and methods. There are the stack and the heap. The heap runs a process that removes unused or orphaned memory called:
A. Tree
B. Constructor
C. Garage Collector
D. Binary Sort
2. In Java the object can have a state and a behavior. Which element in Java is responsible for the object’s behavior:
A. Garbage Collector
B. Class
C. Method
D. Constructor
3. Given the list of items below, which data structure process the top data element by pushing the data element onto or popping the data element off the upper position of the data structure:
A. Stack
B. Queue
C. Array
D. Destructor
4. The best word that describes a class is which of the following:
A. Students
B. Template
C. Interface
D. package
5. Given the following class diagram, identify the class name, variables and methods:
Account
Double Balance
String AcctType
type
getBalance()
Deposit()
Withdraw()
MinimumBalace()
setBalance()
getType()
Settype()
Deposit()
Withdraw()
class
6. Examine the following code snippet. The is the main() method used to test another class by invoke the methods of that class. Insert the code statement that is missing. Assume that the class name being called is “MathOperations.” Insert the statement which create a new object for the class with the reference variable m1.
class mathTest
{
// Driver method
public static void main(String args[])
{
int arr[] = {1, 27, 39, 85, 42, 78, 94, 68};
// passing array to method m1
m1.sum(arr);
m1.avg(arr);
m1.lowest(arr);
m1.highest(arr);
}
}
7. Suppose that you write a new class. If you do not specifically write a constructor for the class, the compiler will provide one by default:
A. TRUE
B. FALSE
8. Suppose that you what to iterate through each data element of an array. What control statement would best accomplish this task:
A. If-then-else
B. For
C. Switch
D. Do-while
9. Which of the following is the best method to destroy an object that is currently on the heap:
A. Set the reference variable of the object to NULL
B. Disable the anti-virus software on the computer
C. Reboot the computer
D. Uninstall Java
10. An array is which type of data structure:
A. Nonlinear
B. Linear
C. Primitive
D. Dynamic
11. Suppose that you have an array which will contain 10 integers. Which of the following would set the 3rd element of the array:
A. Arr[0] = 3
B. Arr[3] = 65
C. Arr[10] = -1
D. Arr[2] = 10
12. Write a line of code that would initialize an array of integers containing 10 integers:
__________________________________________
13. Which of the following influences an objects state :
A. Instance Variables
B. Location in memory
C. Lines of code
D. Destructor
14. Suppose that there are child classes called Square, Circle, Rectangle and a parent class called Shape. What is the proper name of the Shape class in this context:
A. Superclass
B. Shape Manager
C. Overloading
D. Interface
15. All of the following are typical operations performed with data structures except for which operation listed:
A. Search
B. Insertion
C. Deletion
D. Garbage collection
16. If the following command is run from the command line:
Java myjava.java >2mylog.txt
What information is stored in the mylog.txt file?
A. A status of each line of code executed
B. Error messages encountered during execution
C. All output from the console.
D. Only the values System.out.println statements in the code.
17. The following data structure is best identified by the first data element beginning processed and any subsequent data elements would be placed in the end of the structure:
A. TREE
B. ARRAY
C. GRAPH
D. QUEUE
18. Which of the following are proper categories of data structures?
A. Linear/Non-linear
B. Tall/short
C. Primitive/Dynamic
D. Static/Non-static
19. Which of the following is a non-linear data type?
A. Array
B. Stack
C. Queue
D. Graph
20. Linked lists are data structures that can occupy non-contiguous space in memory. What mechanism in the data structure permits one node to locate its adjacent node?
A. Class
B. Object
C. Pointer
D. Heap