Exam 10: Polymorphism

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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.8/5
(33)

An interface name can be used to declare an object reference variable.

(True/False)
4.8/5
(35)

What kind of performance can you expect if you perform linear search on a sorted array?

(Multiple Choice)
4.8/5
(32)

A method's parameter can be polymorphic, giving the method flexible control of its arguments.

(True/False)
4.9/5
(38)

Both the Insertion Sort and the Selection Sort algorithms have efficiencies on the order of ________ where n is the number of values in the array being sorted.

(Multiple Choice)
4.9/5
(39)

Why would you not need to implement a ChangeListener for the JSlider?

(Essay)
4.9/5
(36)

Write an insertion sort method to sort an array of String values (instead of an array of int values). Assume the array is an instance data of the current class called list, and number is an int instance data that stores the number of elements currently stored in list.

(Essay)
4.8/5
(34)

Comparing the amount of memory required by selection sort and insertion sort, what can one say?

(Multiple Choice)
4.7/5
(35)

What are the main programming mechanisms that constitute object-oriented programming?

(Multiple Choice)
4.9/5
(45)

Choosers-like file choosers and color choosers-provide a mechanism for a user to make a selection among numerous alternatives, and these mechanisms are provided within the Java packages.

(True/False)
4.8/5
(41)

Which of the following statements is completely True?

(Multiple Choice)
4.8/5
(38)

How many passes will it take in all for Selection Sort to sort this array?

(Multiple Choice)
4.8/5
(40)

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.8/5
(39)

"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
(34)

Can a program exhibit polymorphism if it only implements early binding?

(Multiple Choice)
4.9/5
(42)

An int array stores the following values. Use the array to answer these next questions. An int array stores the following values. Use the array to answer these next questions.    -Which of the following lists of numbers would accurately show the array after the first pass through the Selection Sort algorithm? -Which of the following lists of numbers would accurately show the array after the first pass through the Selection Sort algorithm?

(Multiple Choice)
4.9/5
(29)

A polymorphic reference can refer to different types of objects over time.

(True/False)
4.8/5
(40)

Write the code needed to set up the GUI as a JFrame that includes the JComboBox, the JSlider, the JButton and a JLabel used to output the total cost. The JLabel should initially display "Compute Movie Cost." Use the names jcb, js, jb and jl for the JComboBox, JSlider, JButton and JLabel respectively.

(Essay)
4.9/5
(40)

A JSlider, xSlider, is used to change an icon displayed in the JLabel jlab. xSlider generates a value between 0 and 9, which is then used to index into String[ ] filename, where filename[i] is the ith image available. So xSlider allows the user to select which image appears. Write the stateChange method for a ChangeListener that would be used to implement the ability to change the image based on the JSlider setting.

(Essay)
4.9/5
(46)

What is printed? public class Inherit { class Figure { void display( ) { System.out.println("Figure"); } } class Rectangle extends Figure { void display( ) { System.out.println("Rectangle"); } } class Box extends Figure { void display( ) { System.out.println("Box"); } } Inherit( ) { Figure f = new Figure( ); Rectangle r = new Rectangle( ); Box b = new Box( ); f.display( ); f = r; f.display( ); f = b; f.display( ); } public static void main(String[ ] args) { new Inherit( ); } }

(Multiple Choice)
4.8/5
(32)
Showing 41 - 60 of 70
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)