ITSC 1213 TEST 3 REVIEW QUESTIONS AND
CORRECT ANSWERS
When applied to variables, methods, or objects, polymorphism enables these entities to
- Answers - have multiple forms
Polymorphism treats objects that inherit from the same superclass as if they were
actually objects of that superclass - Answers - True
Given that the Leg class extends the BodyPart class, would the following code compile?
BodyPart bp = new Leg(); - Answers - Yes
The test that helps us determine whether or not an object can be assigned to a
reference variable is known as a ______ test - Answers - IS-A
If you declare the parameter of a method to be of a superclass type, you can class that
method with a subclass argument - Answers - True
What would be the result of compiling the following code
public final class Body Part {}
public class Arm extends BodyPart {} - Answers - A compiler error because final classes
cannot be extended
public final class BodyPart { public void tattoo() { } } The class definition above
guarantees that - Answers - the tattoo method cannot be overridden
What would be the effect of the following code:
public class BodyPart { }
public class Leg extends BodyPart { }
Leg l = new BodyPart(); - Answers - A compiler error because a subclass reference
variable cannot be assigned a superclass object
Given the following definitions:
abstract public class Manager extends Employee { ... }
public class Executive extends Manager { ... }
What, if anything, is wrong with the following code?
CORRECT ANSWERS
When applied to variables, methods, or objects, polymorphism enables these entities to
- Answers - have multiple forms
Polymorphism treats objects that inherit from the same superclass as if they were
actually objects of that superclass - Answers - True
Given that the Leg class extends the BodyPart class, would the following code compile?
BodyPart bp = new Leg(); - Answers - Yes
The test that helps us determine whether or not an object can be assigned to a
reference variable is known as a ______ test - Answers - IS-A
If you declare the parameter of a method to be of a superclass type, you can class that
method with a subclass argument - Answers - True
What would be the result of compiling the following code
public final class Body Part {}
public class Arm extends BodyPart {} - Answers - A compiler error because final classes
cannot be extended
public final class BodyPart { public void tattoo() { } } The class definition above
guarantees that - Answers - the tattoo method cannot be overridden
What would be the effect of the following code:
public class BodyPart { }
public class Leg extends BodyPart { }
Leg l = new BodyPart(); - Answers - A compiler error because a subclass reference
variable cannot be assigned a superclass object
Given the following definitions:
abstract public class Manager extends Employee { ... }
public class Executive extends Manager { ... }
What, if anything, is wrong with the following code?