Filters
Question type

Study Flashcards

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?


A) JComboBox
B) JList
C) JSlider
D) JButton
E) all of the above

F) D) and E)
G) None of the above

Correct Answer

verifed

verified

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.

Correct Answer

verifed

verified

JSlider js = new JSlider(JSlid...

View Answer

The showDialog method is part of which class?


A) JOptionPane
B) JColorChooser
C) JTextArea
D) Keyboard
E) all of the above

F) B) and C)
G) C) and E)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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( ) ; } }


A) Line
B) Figure
C) Shape
D) Syntax error; the code won't even compile
E) none of the above

F) B) and E)
G) A) and E)

Correct Answer

verifed

verified

A

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

Correct Answer

verifed

verified

The inner loop of the Selection Sort sea...

View Answer

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.

Correct Answer

verifed

verified

JFileChooser jfc = new JFileChooser( );
...

View Answer

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

A) True
B) False

Correct Answer

verifed

verified

False

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( ) ; } }


A) Figure
Rectangle
Box
B) Figure
Figure
Figure
C) Figure
Rectangle
Figure
D) Rectangle
Figure
E) none of the above

F) D) and E)
G) A) and E)

Correct Answer

verifed

verified

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


A) JComboBox
B) JList
C) JSlider
D) JScrollPane
E) JOptionPane

F) A) and D)
G) C) and D)

Correct Answer

verifed

verified

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( ) ; } }


A) Figure
Rectangle
Box
B) Rectangle
Box
C) Figure
Figure
Figure
D) Syntax error. This code won't compile or execute
E) none of the above

F) C) and D)
G) C) and E)

Correct Answer

verifed

verified

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


A) JOptionPane
B) JTextArea
C) showOpenDialog
D) JFileChooser
E) JFileReader

F) B) and C)
G) A) and E)

Correct Answer

verifed

verified

D

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.

A) True
B) False

Correct Answer

verifed

verified

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.

Correct Answer

verifed

verified

JButton b1 = new JButton( );
JButton b2 ...

View Answer

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

A) True
B) False

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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.

A) True
B) False

Correct Answer

verifed

verified

Explain why an abstract method cannot be declared private.

Correct Answer

verifed

verified

Abstract methods are "place holders" for...

View Answer

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


A) Adaptors save the programmer from having to create a collection of empty-bodied methods
B) Adaptors save the programmer from having to create inner classes
C) Adaptors can be used even when interfaces cannot
D) Adaptors are more efficient at run time
E) none of the above

F) A) and C)
G) A) and D)

Correct Answer

verifed

verified

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.

Correct Answer

verifed

verified

JFileChooser jfc = new JFileChooser( );
...

View Answer

Showing 1 - 20 of 70

Related Exams

Show Answer