Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. (TCO 2) Which statement best describes the relationship between superclass an

ID: 3565403 • Letter: 1

Question

1. (TCO 2) Which statement best describes the relationship between superclass and subclass types? (Points : 4)        A subclass reference cannot be assigned to a superclass variable, and a superclass reference cannot be assigned to a subclass variable.
       A subclass reference can be assigned to a superclass variable, and a superclass reference can be assigned to a subclass variable.
       A superclass reference can be assigned to a subclass variable, but a subclass reference cannot be assigned to a superclass variable.
       A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.

Question 2. 2. (TCO 2) Assigning a subclass reference to a superclass variable is safe (Points : 4)        because the subclass object has an object of its superclass.
       because the subclass object is an object of its superclass.
       only when the superclass is abstract.
       only when the superclass is concrete.

Explanation / Answer

1)
d) A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.


2)
b) because the subclass object is an object of its superclass.


3)
a) execution

4)
a) getClass


5)
c) abstract.


6)
b) Exception handling can catch but not resolve exceptions.

7)
a) There is no difference; the terms can be used interchangeably.

8
c) The finally block and try block can appear in any order.


9)
b) The class Throwable provides the method getStackTrace that outputs the stack trace to the standard error stream.


10)
d) The new exception class should extend RuntimeException if the program should be required to handle the exception.


11)
c) Menu bar


12)
d) Swing components allow the user to change the look-and-feel while the program is running.

13)
c) setLayoutManager


14)
b) getResource( "file.txt" )

15)
c) EXIT_ON_CLOSE


16)
c) getText


17)
d) eventListenerList


18)
b) normally several JRadioButtons are grouped together and are mutually exclusive.

19)
b) causes all the JRadioButtons in the group to have their event handlers registered.


20)
b) JComboBox.

21)
d) an array of Objects representing the selected items.


22)
d) LayoutManager2