Exam 10: Polymorphism

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

What is printed by this code? public class Inherit { class Figure { void display( ) { System.out.println("Figure"); } } class Rectangle extends Figure { void display( ) { System.out.println("Rectangle"); } void display(String s) { System.out.println(s); } } class Box extends Figure { void display( ) { System.out.println("Box"); } void display(String s) { System.out.println("This is printed: " + s); } } Inherit( ) { Figure f = new Figure( ); Rectangle r = new Rectangle( ); Box b = new Box( ); f.display( ); f = r; f.display("one"); f = b; f.display("two"); } public static void main(String[ ] args) { new Inherit( ); } }

(Multiple Choice)
4.9/5
(38)

Which statement is completely True?

(Multiple Choice)
4.8/5
(38)

Consider the code shown below. It contains a syntax error, preventing successful compilation and execution. What is the error? public class Inherit { class Figure { void display( ) { System.out.println("Figure"); } } class Rectangle extends Figure { final void display( ) { System.out.println("Rectangle"); } } class Box extends Rectangle { void display( ) { System.out.println("Box"); } } Inherit( ) { Figure f = new Figure( ); Rectangle r = new Rectangle( ); Box b = new Box( ); f.display( ); r.display( ); b.display( ); } public static void main(String[ ] args) { new Inherit( ); } }

(Essay)
4.8/5
(34)

Java allows one to create polymorphic references using inheritance and using interfaces.

(True/False)
4.8/5
(31)

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 second pass of the Selection Sort algorithm? -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
(35)

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

(Multiple Choice)
4.9/5
(40)

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 fourth pass of the Selection Sort algorithm? -Which of the following lists of numbers would accurately show the array after the fourth pass of the Selection Sort algorithm?

(Multiple Choice)
4.7/5
(32)

We compare sorting algorithms by examining

(Multiple Choice)
4.9/5
(43)

Which of the following GUI components would you use to display a list of options when the component is first clicked so that the user could select between the entries?

(Multiple Choice)
4.8/5
(32)

An interface reference can refer to any object of any class that implements the interface.

(True/False)
4.8/5
(36)

Which of these methods will sort an array of floats into ascending order?

(Multiple Choice)
4.8/5
(32)

Demonstrate how the following array is sorted using Selection Sort. Show the array after each pass of the outer loop. [16, 3, 12, 13, 8, 1, 18, 9]

(Essay)
4.8/5
(33)

As explained in the Software Failure, the destruction of the Ariane 5 expendable launch system was caused by

(Multiple Choice)
4.8/5
(44)

To swap the 3ʳᵈ and 4ᵗʰ elements in the int array values, you would do: values[3] = values[4]; values[4] = values[3];

(True/False)
4.8/5
(34)

Is it possible to use both overloading and overriding in the same method?

(Essay)
4.7/5
(35)

What is early binding? What is late binding?

(Essay)
4.7/5
(35)

What is the efficiency of binary search?

(Multiple Choice)
4.9/5
(42)

The GUI should react whenever the JButton is clicked, so the JFrame will need an ActionListener. Write the actionPerformed method to implement the ActionListener so that the GUI will compute the cost of the movie when the JButton is clicked. This method will have to obtain the values specified in the JComboBox and the JSlider and output the computed cost in the JLabel. Assume that a Matinee costs $5.00 per ticket, a Rush Hour show $3.50 per ticket and Normal show costs $7.50 per ticket.

(Essay)
4.9/5
(34)

A reference variable can refer to any object created from any class related to it by inheritance.

(True/False)
4.8/5
(40)

Which of the following GUI components would you use to display a list of options so that the user could select between the entries in the list?

(Multiple Choice)
4.8/5
(33)
Showing 21 - 40 of 70
close modal

Filters

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