Exam 10: Polymorphism

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

A JSlider provides a list of String choices that the user can select between.

Free
(True/False)
4.8/5
(40)
Correct Answer:
Verified

False

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

Free
(Multiple Choice)
4.9/5
(37)
Correct Answer:
Verified

A

Which of the following classes would you use to open a GUI dialog box, which is then used to select a file to open?

Free
(Multiple Choice)
4.9/5
(37)
Correct Answer:
Verified

D

Write a set of code to define a vertical JSlider that goes from 1 to 1000 with tick marks every 100 and default to be set in the middle (at 500), with a background color of 0, 0, 255.

(Essay)
4.8/5
(39)

Assume that x is a GUI component from the javax.swing library. The instruction x.getValue( ) returns the value selected by the user from component x where x would be of which specific swing class?

(Multiple Choice)
4.8/5
(26)

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 Rectangle { void display( ) { System.out.println("Box"); } } Inherit( ) { Figure f = new Figure( ); Rectangle r = new Rectangle( ); Box b = new Box( ); f.display( ); f = r; ((Figure) f).display( ); f = (Figure) b; f.display( ); } public static void main(String[ ] args) { new Inherit( ); } }

(Multiple Choice)
4.8/5
(34)

A class reference can refer to any object of any class that descends from the class.

(True/False)
4.8/5
(36)

What is printed by the following code? Consider the polymorphic invocation. 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
(34)

Binary search can be used on unsorted datait will just perform more slowly.

(True/False)
4.9/5
(42)

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

Considering the event processing classes, what is the advantage of extending an adaptor class compared to implementing an interface?

(Multiple Choice)
4.7/5
(40)

One of the advantages of linear search is that it does not require its data to be sorted.

(True/False)
4.9/5
(39)

Write a set of code that will create 4 JButtons and add each of these to a JPanel so that they appear in a 2x2 grid. The JButtons will not have any text appear in them (i.e. no commands or names) but instead, will each appear as a color set by the user by using JColorChooser.

(Essay)
4.7/5
(34)

Write a set of code that will allow a user to select a file through a JFileChooser, read each item of the file, outputting each item to the screen, and close the file at the end.

(Essay)
4.7/5
(43)

Explain how to alter the Selection Sort algorithm so that it sorts in descending order instead of ascending order.

(Essay)
4.9/5
(42)

Explain why an abstract method cannot be declared private.

(Essay)
4.7/5
(37)

Write a set of code that will allow a user to select a file through a JFileChooser and store all items in the String array list to the selected file, closing the file when done.

(Essay)
4.8/5
(36)

The showDialog method is part of which class?

(Multiple Choice)
4.8/5
(41)

Which of the following GUI components would you use to allow the user to move the view of the components within the container?

(Multiple Choice)
4.8/5
(33)

Regarding the Software Failure: There was a segment in the Ariana 5 software to convert a floating-point number to a signed 16-bit integer, but once the number was converted, it was out of range for 16 bits.

(True/False)
4.9/5
(31)
Showing 1 - 20 of 70
close modal

Filters

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