Exam 10: Polymorphism
Exam 1: Introduction65 Questions
Exam 2: Data and Expressions77 Questions
Exam 3: Using Classes and Objects58 Questions
Exam 4: Writing Classes56 Questions
Exam 5: Conditionals and Loops37 Questions
Exam 6: More Conditionals and Loops36 Questions
Exam 7: Object-Oriented Design76 Questions
Exam 8: Arrays70 Questions
Exam 9: Inheritance71 Questions
Exam 10: Polymorphism70 Questions
Exam 11: Exceptions68 Questions
Exam 12: Recursion68 Questions
Exam 13: Collections68 Questions
Select questions type
Which of the following GUI components would you use to allow the user to select between a range of numeric alternatives?
(Multiple Choice)
4.8/5
(27)
Why is it almost always a good idea to implement a toString( ) method when you define a class?
(Essay)
5.0/5
(37)
The fact that the System.out.println( ) method is able to handle such a wide variety of objects, and print them correctly, is an example of the polymorphic nature of the println( ) method.
(True/False)
4.8/5
(40)
The type of the reference, not the type of the object, is use to determine which version of a method is invoked in a polymorphic reference.
(True/False)
4.9/5
(42)
What does the following code do? Assume list is an array of int values, temp is some previously initialized int value, and c is an int initialized to 0.
For (j=0; j < list.length; j++)
If (list[j] < temp) c++;
(Multiple Choice)
4.9/5
(31)
Comparing the performance of selection sort and insertion sort, what can one say?
(Multiple Choice)
4.8/5
(43)
What is printed by the following code?
public class Inherit
{
abstract class Speaker
{
abstract public void speak( );
}
class Cat extends Speaker
{
public void speak( )
{
System.out.println("Woof!");
}
}
class Dog extends Speaker
{
public void speak( )
{
System.out.println("Meow!");
}
}
Inherit( )
{
Speaker d = new Dog( );
Speaker c = new Cat( );
d.speak( );
c.speak( );
}
public static void main(String[ ] args)
{
new Inherit( );
}
}
(Multiple Choice)
4.9/5
(40)
Although insertion sort and selection sort have generally the same O(n²) performance, selection sort has an advantage of insertion sort. What is this advantage?
(Multiple Choice)
4.8/5
(33)
Showing 61 - 70 of 70
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)