The University of Western Ontario
Department of Computer Science
Computer Science 1027b Midterm Exam
Print your name:______________________________________________
Student number: ______________________________________________
•Fill in your name and student number above immediately.
•Answer all the questions in the exam in the spaces provided.
•You have 2 hours to complete the exam.
•The exam has 8 questions on 14 pages, and is out of a possible 80 marks.
•The marks for each individual question are given. Allow approximately 1.5 minute
per mark on average.
•There is a page for rough work at the end of the exam paper.
•Read the questions carefully!
DO NOT TURN THIS PAGE UNTIL DIRECTED TO DO SO.
1 (max 15)
2 (max 5)
3 (max 10)
4 (max 15)
5 (max 10)
6 (max 10)
7 (max 10)
8 (max 5)
1. (15 marks) True/False (Circle your answers) (Answers are italicized)
a) (1 mark) A static method within a class can be invoked without having to instantiate an
object of that class.
b) (1 mark) A Java interface should never contain a constructor.
c) (1 mark) A Java interface never contains an attribute (instance variable) declaration.
d) (1 mark) A new class X derived from a class Y establishes an is-a relationship from
class X to class Y.
e) (1 mark) All Java classes are derived, directly or indirectly from the Object class
f) (1 mark) Any method in a Java class X can call public and private methods from X.
g) (1 mark) In the Java statement
LinkedBag<BingoBall> b = new LinkedBag<BingoBall>( );
BingoBall is a generic type.
h) (1 mark) The reserved word super can be used in a class to refer to its parent class.
i) (1 mark) The objects in a Java program are created when the program is being
executed, as opposed to when it is compiled.
j) (1 mark) The terms parent class, superclass, and base class all mean the same thing.
k) (1 mark) The code in ArrayBag.java is an implementation of the BagADT interface.
l) (1 mark) A child class cannot override a parent method that is declared as final.
m) (1 mark) Executable code is generally found in interfaces.
n) (1 mark) The file BagADT.java contains both an interface and an implementation
o) (1 mark) The methods enqueue(), dequeue(), first(), size(), and isEmpty() from
the class LinkedQueue have time complexity O(1).