Exam 10: Polymorphism
Exam 1: Introduction64 Questions
Exam 2: Data and Expressions67 Questions
Exam 3: Using Classes and Objects49 Questions
Exam 4: Writing Classes53 Questions
Exam 5: Conditionals and Loops38 Questions
Exam 6: More Conditionals and Loops35 Questions
Exam 7: Object-Oriented Design44 Questions
Exam 8: Arrays45 Questions
Exam 9: Inheritance49 Questions
Exam 10: Polymorphism40 Questions
Exam 11: Exceptions39 Questions
Exam 12: Recursion55 Questions
Exam 13: Collections60 Questions
Select questions type
A polymorphic reference can refer to different types of objects over time.
(True/False)
4.9/5
(36)
Consider this statement: If you declare a (polymorphic) reference variable, v, to be of type Object, by saying: Object v; then v can refer to any kind of object without restriction. If "object" means an instance of the Object class, is this statement true? Why or why not? If "object" means any kind of Java data, is this statement true? Why or why not?
(Essay)
4.7/5
(29)
What are the main programming mechanisms that constitute object-oriented programming?
(Multiple Choice)
4.9/5
(37)
Which of the following is true about a comparison between the selection sort and the insertion sort?
(Multiple Choice)
4.9/5
(36)
Code Example Ch 10-1
An int array stores the following values:
9 4 12 2 6 8 18
-Refer to Code Example Ch 10-1: Which of the following lists of numbers would accurately show the array after the fourth pass of the selection sort algorithm?
(Multiple Choice)
4.8/5
(35)
Explain how to alter the selection sort algorithm so that it sorts in descending order instead of ascending order.
(Essay)
4.8/5
(38)
Demonstrate how the following array is sorted using insertion sort. Show the array after each pass of the outer loop.
[16, 3, 12, 13, 8, 1, 18, 9]
(Essay)
4.9/5
(31)
The binary search can be used on unsorted data. It will just perform more slowly.
(True/False)
5.0/5
(38)
An class reference can refer to any object of any class that descends from the class.
(True/False)
4.8/5
(41)
Although insertion sort and selection sort have generally the same performance, the selection sort has an advantage over the insertion sort. What is this advantage?
(Multiple Choice)
4.8/5
(38)
An interface reference can refer to any object of any class that implements the interface.
(True/False)
4.8/5
(33)
Code Example Ch 10-1
An int array stores the following values:
9 4 12 2 6 8 18
-Refer to Code Example Ch 10-1: How many passes will it take in total for the selection sort to sort this array?
(Multiple Choice)
4.8/5
(39)
Given the following code, class Aggregate is incorrect. Choose the correct line so that this program prints: Granite: weight=25.0 value=4 numKind=7 public class Inherit
{
Abstract class Stone
{
Protected float weight = 13;
Protected int value = 4;
Abstract public String toString( );
}
Class Aggregate
{
Protected int numKind;
}
Class Granite extends Aggregate
{
Granite()
{
Weight = 25; numKind = 7;
}
Public String toString()
{
Return "Granite: weight="
+ weight + " value="
+ value + " numKind="
+ numKind;
}
}
Inherit()
{
Granite g = new Granite( );
System.out.println(g);
}
Public static void main(String[] args)
{
New Inherit();
}
}
(Multiple Choice)
4.8/5
(29)
A method's parameter can be polymorphic, giving the method flexible control of its arguments.
(True/False)
4.8/5
(35)
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.7/5
(39)
It is possible to sort an array of int, float, double or String, but not an array of an Object class such as a CD class.
(True/False)
4.9/5
(35)
In order to determine the type that a polymorphic variable refers to, the decision is made
(Multiple Choice)
4.8/5
(32)
To swap the 3rd and 4th elements in the int array values, you would do:
values[3] = values[4];
values[4] = values[3];
(True/False)
4.8/5
(31)
Which of the following methods will sort an array of floats in ascending order?
(Multiple Choice)
4.9/5
(48)
Code Example Ch 10-1
An int array stores the following values:
9 4 12 2 6 8 18
-Refer to Code Example Ch 10-1: Which of the following lists of numbers would accurately show the array after the second pass of the selection sort algorithm?
(Multiple Choice)
4.8/5
(40)
Showing 21 - 40 of 40
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)