Exam 10: Interfaces

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

The ____ class in the javax.swing package generates a sequence of events, spaced apart at even time intervals.

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

B

You have a class which extends the JComponent class. In this class you have created a painted graphical object. Your code will change the data in the graphical object. What additional code is needed to ensure that the graphical object will be updated with the changed data?

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

B

Use the ____ method to specify the height and width of a graphical component when you add it to a panel.

Free
(Multiple Choice)
4.7/5
(36)
Correct Answer:
Verified

C

You have created a class named Motor that implements an interface named Measurable. You have declared a variable of type Measureable named motorTemperature. Which of the following statements is true?

(Multiple Choice)
4.8/5
(32)

Consider the code snippet below: public class RectangleComponent extends JComponent { Private Rectangle box; Private static final int BOX_X = 100; Private static final int BOX_Y = 100; Private static final int BOX_WIDTH = 20; Private static final int BOX_HEIGHT = 30; Public RectangleComponent() { // The rectangle that the paint method draws Box = new Rectangle(BOX_X, BOX_Y, BOX_WIDTH, BOX_HEIGHT); } Public void paintComponent(GraphicsG) { Super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; G2)draw(box); } Public void moveTo(int x, int y) { box.setLocation(x, y); Repaint(); } } Which statement causes the rectangle to appear at an updated location?

(Multiple Choice)
4.8/5
(32)

To respond to a button event, a listener must supply instructions for the ____ method of the ActionListener interface.

(Multiple Choice)
4.9/5
(39)

Use the ____ method to add a mouse listener to a component.

(Multiple Choice)
4.9/5
(37)

Which of the following statements about events and graphical user interface programs is true?

(Multiple Choice)
5.0/5
(31)

Consider the following declarations: public interface Displayable { Void display(); } Public class Picture implements Displayable { Private int size; Public void increaseSize() { Size++; } Public void decreaseSize() { Size--; } Public void display() { System.out.println(size); } Public void display(int value) { System.out.println(value * size); } } What method invocation can be used to complete the code segment below? Displayable picture = new Picture(); Picture._________________;

(Multiple Choice)
4.8/5
(38)

Consider the following code snippet. public interface Measurable { Double getMeasure(); } Public class Coin implements Measurable { Public double getMeasure() { Return value; } ).. } Public class DataSet { ).. Public void add() { ).. } } Public class BankAccount { ).. Public void add() { ).. } } Which of the following statements is correct?

(Multiple Choice)
4.8/5
(40)

If you have multiple classes in your program that have implemented the same interface in different ways, how is the correct method executed?

(Multiple Choice)
4.7/5
(36)

Consider the following class: public class Player implements Comparable { Private String name; Private int goalsScored; // other methods go here Public int compareTo(Object otherObject) { __________________________________ Return (goalsScored - otherPlayer.goalsScored); } } What statement can be used to complete the compareTo() method?

(Multiple Choice)
4.8/5
(31)

Which of the following code statements creates a graphical button which has "Calculate" as its label ?

(Multiple Choice)
4.9/5
(39)

Consider the following code snippet: Import ____________________ Import java.awt.event.ActionListener; /** An action listener that prints. */ Public class ClickListener implements ActionListener { Public void actionPerformed(ActionEvent event) { System.out.println("I was clicked."); } } Which of the following statements will complete this code?

(Multiple Choice)
4.9/5
(43)

If the user presses and releases a mouse button in quick succession, which methods of the MouseListener interface are called?

(Multiple Choice)
4.7/5
(33)

Which of the following statements about listener classes is true?

(Multiple Choice)
4.9/5
(48)

Assuming that the ClickListener class implements the ActionListener interface, what statement should be used to complete the following code segment? ClickListener listener = new ClickListener(); JButton myButton = new JButton("Submit"); JPanel myPanel = new JPanel(); MyPanel.add(myButton); ______________________ // missing statement

(Multiple Choice)
4.8/5
(36)

Which of the following statements about helper classes is true?

(Multiple Choice)
4.9/5
(38)

Which of the following can potentially be changed when implementing an interface?

(Multiple Choice)
4.9/5
(39)

Consider the following code snippet: JFrame frame = new JFrame(); JPanel panel = new JPanel Which statement would add the panel to the frame?

(Multiple Choice)
4.9/5
(44)
Showing 1 - 20 of 85
close modal

Filters

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