Exam 10: Interfaces

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

Which of the following statements about a callback is NOT true?

(Multiple Choice)
4.9/5
(37)

A/an ____ is used to capture mouse events.

(Multiple Choice)
4.7/5
(43)

What role does an interface play when using a mock class?

(Multiple Choice)
4.9/5
(33)

Which of the following is an event source?

(Multiple Choice)
4.9/5
(36)

Which of the following statements about a mock class is true?

(Multiple Choice)
4.9/5
(32)

Consider the following code snippet: public class MyMouseListener { Public void mousePressed(MouseEvent event) { Double x; Double y; _______ System.out.println("x: " + x + ", y: " + y); } } Which of the following statements should be in the indicated position to print out where the mouse was pressed?

(Multiple Choice)
4.8/5
(34)

Consider the following declarations: public interface Encryptable { Void encrypt(String key); } Public class SecretText implements Encryptable { Private String text; _____________________________ { // code to encrypt the text using encryption key goes here } } Which of the following method headers should be used to complete the SecretText class?

(Multiple Choice)
4.9/5
(42)

Which of the following statements about an interface is true?

(Multiple Choice)
4.9/5
(33)

Consider the following code snippet: public class ClickListener implements ActionListener { Public void actionPerformed(ActionEvent event) { System.out.println("I was clicked."); } } Public class ButtonTester { Public static void main(String[] args) { JFrame frame = new JFrame(); JButton button = new JButton("Click me!"); Frame.add(button); ActionListener listener = new ClickListener(); Button.addActionListener(listener); ).. } } Which of the following statements is correct?

(Multiple Choice)
4.9/5
(38)

A method that has no implementation is called a/an ____ method.

(Multiple Choice)
4.9/5
(37)

Which of the following is a good use for an anonymous class?

(Multiple Choice)
4.9/5
(36)

Suppose you are writing an interface called Resizable, which includes one void method called resize. public interface Resizable { _________________________ } Which of the following can be used to complete the interface declaration correctly?

(Multiple Choice)
4.8/5
(39)

The methods of a/an ____ describe the actions to be taken when an event occurs.

(Multiple Choice)
4.9/5
(36)

Consider the following code snippet: class MouseClickedListener implements ActionListener { Public void mouseClicked(MouseEvent event) { Int x = event.getX(); Int y = event.getY(); Component.moveTo(x,y); } } What is wrong with this code?

(Multiple Choice)
4.9/5
(39)

Which of the following statements about converting between types is true?

(Multiple Choice)
4.8/5
(30)

Assume that the TimerListener class implements the ActionListener interface. If the actionPerformed method in TimerListener needs to be executed every second, what statement should be used to complete the following code segment? ActionListener listener = new TimerListener(); _________________________________ // missing statement Timer.start();

(Multiple Choice)
4.7/5
(33)

____ are generated when the user presses a key, clicks a button, or selects a menu item.

(Multiple Choice)
4.8/5
(44)

Consider the following class: public class ClickListener implements ActionListener { __________________________________________ { System.out.println("mouse event ..."); } } Which of the following method headers should be used to complete the ClickListener class?

(Multiple Choice)
4.8/5
(37)

Which container is used to group multiple user-interface components together?

(Multiple Choice)
4.8/5
(39)

Consider the following code snippet which is supposed to show the total order amount when the button is clicked: public static void main(String[] args) { Final Order myOrder = new Order(); JButton button = new JButton("Calculate"); Final JLabel label = new JLabel("Total amount due"); ) . . Class MyListener implements ActionListener { Public void actionPerformed(ActionEvent event) { Label.setText("Total amount due " + myOrder.getAmountDue()); } } ActionListener listener = new MyListener(); } What is wrong with this code?

(Multiple Choice)
4.9/5
(42)
Showing 41 - 60 of 85
close modal

Filters

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