Section 1 (Answer all questions in this section) 1. Why would a programmer use polymorphism rather than sticking to a standard array? Mark for Review (1) Points Because arrays only work using the same object type and polymorphism provides a way around this. (*) Because it is easier to add or remove objects using polymorphism even when all of the objects are of the same type. Because arrays are more complex and polymorphism simplifies them by restricting them to only contain the same type objects. A programmer wouldn't use polymorphism over a standard array. Correct 2. If Sandal extends Shoe, it is possible to declare an object such that Sandal s = new Shoe(); Mark for Review (1) Points True False (*) Correct 3. It is possible to override methods such as equals() and toString() in
Section 1 (Answer all questions in this section) 1. Why would a programmer use polymorphism rather than sticking to a standard array? Mark for Review (1) Points Because arrays only work using the same object type and polymorphism provides a way around this. (*) Because it is easier to add or remove objects using polymorphism even when all of the objects are of the same type. Because arrays are more complex and polymorphism simplifies them by restricting them to only contain the same type objects. A programmer wouldn't use polymorphism over a standard array. Correct 2. If Sandal extends Shoe, it is possible to declare an object such that Sandal s = new Shoe(); Mark for Review (1) Points True False (*) Correct 3. It is possible to override methods such as equals() and toString() in
Mark for
Review
(1) Points
Because arrays only work using the same object type and polymorphism
provides a way around this. (*)
Because it is easier to add or remove objects using polymorphism even
when all of the objects are of the same type.
Because arrays are more complex and polymorphism simplifies them by
restricting them to only contain the same type objects.
A programmer wouldn't use polymorphism over a standard array.
Correct
2. If Sandal extends Shoe, it is possible to declare an object such that
Mark for
Mark for
Review
(1) Points
True (*)
False
Correct
4. Is there a difference between overriding a method and overloading a method?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
Abstract classes
Polymorphism
Inheritance
Dynamic Method Dispatch (*)
Correct
6. Which of the following are true about an abstract class?
Mark for
Review
(1) Points
Mark for
Review
(1) Points
It would print the array one element at a time. The console screen would
display: 0 18 215 64 11 42
It would print the string returned from the method. The console screen
would display: [0,18,215,64,11,42,] (*)
It would print the array backwards. The console screen would display: 42
11 64 215 18 0
It would print the string returned from the method. The console screen
would display: {0, 18, 215, 64, 11, 42}
Correct
8. What is the Java keyword final used for in a program?
Mark for
Review
(1) Points
It restricts a class from being extendable and restricts methods from
being overridden. (*)
It permits access to the class variables and methods from anywhere.
It permits redefining methods of a parent class inside the child class, with
the same name, parameters, and return type.
It terminates the program.
There is no such keyword in Java.
Correct
9. Which of the following is a goal of the object model?
Mark for
Review
(1) Points
Mark for
Review
(1) Points