Final Exam
Final Exam
Java Object Oriented Programming
Instructions: Answer the questions with the best answer provided. This exam should be completed independently. Please do not seek answers from other students. The questions are multiple chose and fill in the blank. When you complete the exam save the file as LASTNAME_FinalExam.doc. Email the file to [email protected] when complete.
Submission Deadline: You have until 1159PM on 5/12/2020 to submit the exam for a full grade.
1. The following could be considered a category of objects. This entity defines all of the common properties of the object that belong to it:
a. Stack
b. Class
c. Pointer
d. Queue
2. A class consists of the following elements:
a. Graphs and Trees
b. Heap and stacks
c. Variables and methods
d. Integers and strings
3. A programming deliverable should contain what minimum number of classes:
a. 1
b. 2
c. 3
d. 4
4. 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
5. 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
6. 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
7. 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
8. Which of the following are proper categories of data structures?
A. Linear/Non-linear
B. Tall/short
C. Primitive/Dynamic
D. Static/Non-static
9. 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
10. Write a code that will iterate through an Array. The code should determine the length of the array and then display (println) each element of the array. Assume the array is integer array.
11. Suppose that a program is written and needs to be debugged. If the errors of the application need to be recorded for troubleshooting, which of the following is the best statement to execute:
a. Java Myproject.java > logifile.txt
b. Java Myproject.java 2>logfile.txt
c. Javac myproject >>logfile.txt
d. Javac myproject 3>logfile.txt
12. Which environment variable will point to the directory location when java is installed:
a. %SystemRoot%
b. %HomePath%
c. %JAVA_HOME%
d. %ONEDRIVE%
13. What are the two methods of implementing polymorphism?
a. Static cast or Dynamic cast
b. Run time or compile time
c. Execution time only
d. Only when computer is powered on
14. Which method or methods show below are valid implementations of inheritance in Java?
a. Single
b. Multi-level
c. Hierarchical
d. All of the above
e. None of the above
15. Given the following code snippet, which inheritance method is being used:
a. Single
b. Hierarchical
c. Hybrid
d. Multiple
16. If run time implementation is used for polymorphism, what is the other term used to describe this implementation type:
a. Static dispatch
b. Non-linear dispatch
c. Dynamic dispatch
d. Primitive dispatch
17. Suppose the encapsulation is implemented in a class. The instance variables are private and the variables require read/write capability. What methods are required to change the value or read the value of the private variables:
a. Add() and delete()
b. Select() and Insert()
c. Set() and get()
d. Right join() and left join()
18. The primary function of encapsulation is which of the following:
a. Method hiding
b. Data hiding
c. Variable hiding
d. Class Hiding
19. The primary function of abstraction is which of the following:
a. Variable hiding
b. Implementation hiding
c. Data hiding
d. Class hiding
20. Suppose an abstract class is created and the class contains an abstract method. If a subclass invokes a method with the same name as the parent abstract class, and a different behavior is required in the subclass, which key word is required in the subclass:
a. Public
b. Private
c. @override
d. Protected
21. Suppose that a new object needs to be created in the source code. Which of the following statements will create the new object:
a. MathOperations m1 = new MatchOperations()
b. Class NewObject extends BigObject{}
c. For ( i=0;I <array.lenght;i++)
d. O1.Method()
22. What is a main characteristic that differentiates an error from an exception?
a. Errors are generally caused by programmatic issues
b. Exceptions are cause by the problems in the Java Virtual Machine
c. Errors can be caused by problems in the Java Virtual Machine
d. None of the above
23. If a programmer uses a try-catch block it is ok to put null code or no code in the catch block. Doing so is a best practice of exception handling.
a. True
b. False
24. Suppose that you want to create a new object and want to use a non-default constructor. You also want the constructor to initialize the object based on different information. For example, in one case only an integer is used, but in another case a string and an integer are used to initialize the object. By using two or more constructors to initialize the object this is called:
A. Packaging
B. Overloading
C. Recursion
D. Stack Tracing
25. During program execution methods are executed from which of the following data structures:
a. Graph
b. Array
c. Stack
d. Tree