Answers to some True-False questions from the old final exams
T F
- T - When you override the
equals
method of a class, you should be sure to override thehashCode
method compatibly. - F - If
A
is a subtype ofB
, thenSet<A>
is a subtype ofSet<B>
. - T - When using the Java IO libraries, one should generally wrap a
FileReader
object inside aBufferedReader
to prevent significant performance problems. - F - It is possible to create an object of type
Set<int>
. - F - An object's
static
type is always a subtype of itsdynamic
type. - F - The value null can be assigned to a variable of any type.
- T - A method with the following declaration definitely will not throw an
IOException
to a calling context.
public void m() {...}
- T - The
@Override
annotation prevents accidental overloading of a method. - F - In some cases, dynamic dispatch of a method invocation requires the Java ASM to search the entire stack to find the appropriate code to run next.
- F - It is not possible to call a method declared as
static
from within a non-static
method.
- T - The type
MyPanel
is a subtype ofObject
. - F - The new object created on line 27 is an instance of
MyPanel
(SP15 - Appendix D). - T - The instance variables
x
andy
on lines 23 and 24 can only be modified by methods of theMyPanel
class or the methods of any inner classes ofMyPanel
. - T - The dynamic class of f (declared on line 13) is
JFrame
. - T - The
mouseMoved
method on line 28 is called by the Swing event loop in reaction to the user moving the mouse in the main window of the application. - F - The
paintComponent
method on line 42 is only invoked once, at the start of the application. - F - A
JPanel
cannot be added to anotherJPanel
using the add method. - F - If the user replaces the code on line 31 (the call to
repaint()
) withpaintComponent (new Graphics ())
, then the behavior of the application would not change. - T - The anonymous class defined on line 27 implements or inherits all members of the
MouseMotionListener
interface. - F - The method
createAndShowGUI
cannot be invoked without an instance of classGUI
.