COMP 401
Midterm
I have not received nor given any unauthorized assistance in completing this exam. Signature:
Name:
PID:
Please be
... [Show More] sure to put your PID at the top of each page. There are 70 points on this exam.
Part I contains 35 questions worth 1 point each and should be answered on your Scantron form. Part II is worth 15 points.
Part III is worth 20 points.
Please try to limit your answers to the pages provided. The back of the exam is blank and available as extra space if necessary. If you do put part of any answer on the back of the exam, put a note indicating this where the answer was expected.
Part I: Scantron Questions.
Scantron questions 1-20
True/False: Select A for true and B for false.
1. A class can only be part of one package. (T)
2. Any static method can be the starting point for a Java program. (F)
3. The index of the 4th item in an array is 4. (F)
4. The length of an array is specified when it is created and may be altered after it is created. (F)
5. A single statement can be used wherever a block of statements delimited by curly braces is normally expected. (T)
6. Local variables declared within a while loop are in scope (i.e., defined and available) only within the body of the loop. (T)
7. Calling a void method can never be part of an expression. (T)
8. A class that implements an interface has an is-a relationship with any other class that also implements that interface. (F)
9. A class can implement any number of interfaces. (T)
10. An interface can be implemented by any number of classes. (T)
11. An overridden method defined in a subclass will have the same method declaration as it appears in its parent’s class. (T)
12. A class marked as abstract will generally not need to have its constructor be public. (T)
13. Every class has an “is a” relationship with the class Object. (T)
14. Only public methods are virtual by default. (F)
15. A class that is designed as a composition will generally have its components specified as parameters to its constructor. (F)
16. Encapsulated objects within an aggregation are generally useful outside of the aggregation and/or shared with other abstractions. (T)
17. An exception that is a direct subclass of Exception is not subject to the "catch or specify" rule. (F)
18. If a thrown exception has an is-a relationship to the exception types declared in two different catch blocks, both catch blocks will be executed. (F)
19. Code within a catch block may cause a different exception to be thrown. (T)
20. Code within a finally block is only executed if an exception is not thrown. (F)
Scantron questions 21-25
For each given type declaration, mark A if the type is a valid value type, B if the type is a valid reference type, or C if the declaration is no [Show Less]