CS 1331 Exam 3 with accurate |!! |!! |!! |!! |!! |!!
detailed solutions |!!
Static Type - correct answer✔✔another word for Declared Type
|!! |!! |!! |!! |!! |!! |!! |!!
Dynamic Type - correct answer✔✔another word for Object Type; the actual
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
class that follows the new operator when an Object is instantiated
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
True, fails is-a test (Dog is NOT a Poodle), produces a ClassCastException -
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
correct answer✔✔T/F: The following code produces a runtime error
|!! |!! |!! |!! |!! |!! |!! |!! |!!
Dog dg = new Dog("name", 1);
|!! |!! |!! |!! |!!
((Poodle)dg).enterDogShow();
False, you can legally (syntax) cast an object up or down its inheritance
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
tree as long as the target type has the variable or method being accessed
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
- correct answer✔✔T/F: The following code produces a compiler error
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
Dog dg = new Dog("name", 1);
|!! |!! |!! |!! |!!
((Poodle)dg).enterDogShow();
Runtime - correct answer✔✔Dynamic binding, process of matching a
|!! |!! |!! |!! |!! |!! |!! |!! |!!
method call in a statement to its actual definition, occurs at...
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
JVM - correct answer✔✔The _____ tries to find a method that can handle a
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
thrown exception |!!
Unchecked - correct answer✔✔Classes in the RuntimeException hierarchy
|!! |!! |!! |!! |!! |!! |!! |!!
(includes subclasses) are known as [checked/unchecked] exceptions
|!! |!! |!! |!! |!! |!!
, Checked - correct answer✔✔Classes outside the RuntimeException
|!! |!! |!! |!! |!! |!! |!!
hierarchy (includes subclasses) are known as [checked/unchecked]
|!! |!! |!! |!! |!! |!! |!!
exceptions
True (the code will not compile with the error: "FileNotFoundException;
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
must be caught or declared to be thrown") - correct answer✔✔T/F: You
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
cannot compile code to read a file without having a try/except catch for it.
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
Whitespace - correct answer✔✔By default, the Scanner uses ______
|!! |!! |!! |!! |!! |!! |!! |!! |!!
delimiter when tokenizing data. |!! |!! |!!
java.io - correct answer✔✔File is a class in the ______ package
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
Throwable - correct answer✔✔The Error and Exception classes are direct
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
subclasses of... |!!
False - correct answer✔✔T/F: The top of the call stack is always going to
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
be the main method.
|!! |!! |!!
First - correct answer✔✔If an exception is thrown, the JVM will execute the
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
______ catch block with a parameter type that matches the object's type.
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
True - correct answer✔✔T/F: The finally block is also executed if no
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
exceptions are thrown. |!! |!!
implementors - correct answer✔✔Classes being used by an interface are |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
called...
detailed solutions |!!
Static Type - correct answer✔✔another word for Declared Type
|!! |!! |!! |!! |!! |!! |!! |!!
Dynamic Type - correct answer✔✔another word for Object Type; the actual
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
class that follows the new operator when an Object is instantiated
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
True, fails is-a test (Dog is NOT a Poodle), produces a ClassCastException -
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
correct answer✔✔T/F: The following code produces a runtime error
|!! |!! |!! |!! |!! |!! |!! |!! |!!
Dog dg = new Dog("name", 1);
|!! |!! |!! |!! |!!
((Poodle)dg).enterDogShow();
False, you can legally (syntax) cast an object up or down its inheritance
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
tree as long as the target type has the variable or method being accessed
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
- correct answer✔✔T/F: The following code produces a compiler error
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
Dog dg = new Dog("name", 1);
|!! |!! |!! |!! |!!
((Poodle)dg).enterDogShow();
Runtime - correct answer✔✔Dynamic binding, process of matching a
|!! |!! |!! |!! |!! |!! |!! |!! |!!
method call in a statement to its actual definition, occurs at...
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
JVM - correct answer✔✔The _____ tries to find a method that can handle a
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
thrown exception |!!
Unchecked - correct answer✔✔Classes in the RuntimeException hierarchy
|!! |!! |!! |!! |!! |!! |!! |!!
(includes subclasses) are known as [checked/unchecked] exceptions
|!! |!! |!! |!! |!! |!!
, Checked - correct answer✔✔Classes outside the RuntimeException
|!! |!! |!! |!! |!! |!! |!!
hierarchy (includes subclasses) are known as [checked/unchecked]
|!! |!! |!! |!! |!! |!! |!!
exceptions
True (the code will not compile with the error: "FileNotFoundException;
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
must be caught or declared to be thrown") - correct answer✔✔T/F: You
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
cannot compile code to read a file without having a try/except catch for it.
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
Whitespace - correct answer✔✔By default, the Scanner uses ______
|!! |!! |!! |!! |!! |!! |!! |!! |!!
delimiter when tokenizing data. |!! |!! |!!
java.io - correct answer✔✔File is a class in the ______ package
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
Throwable - correct answer✔✔The Error and Exception classes are direct
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
subclasses of... |!!
False - correct answer✔✔T/F: The top of the call stack is always going to
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
be the main method.
|!! |!! |!!
First - correct answer✔✔If an exception is thrown, the JVM will execute the
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
______ catch block with a parameter type that matches the object's type.
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
True - correct answer✔✔T/F: The finally block is also executed if no
|!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
exceptions are thrown. |!! |!!
implementors - correct answer✔✔Classes being used by an interface are |!! |!! |!! |!! |!! |!! |!! |!! |!! |!!
called...