Exam 10: Interfaces

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

Consider the following declarations: public interface Measurer { Int measure(Object anObject); } Public class StringLengthMeasurer implements Measurer { Public int measure(_________________) { String str = (String) anObject; Return str.length(); } } What parameter declaration can be used to complete the callback measure method?

(Multiple Choice)
4.9/5
(40)

A/an ____ belongs to a class whose methods describe the actions to be taken when a user clicks a user-interface graphical object.

(Multiple Choice)
4.9/5
(37)

You wish to implement a callback method for an object created from a system class that you cannot change. What approach does the textbook recommend to accomplish this?

(Multiple Choice)
4.8/5
(29)

Consider the following code snippet: final RectangleComponent component = new RectangleComponent(); MouseListener listener = new MousePressListener(); Component.addMouseListener(listener); ______________ Frame.add(component); Frame.setSize(FRAME_WIDTH, FRAME_HEIGHT); Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Frame.setVisible(true); Which of the following statements completes this code?

(Multiple Choice)
4.9/5
(30)

Which of the following statements about an inner class is true?

(Multiple Choice)
4.8/5
(41)

An inner class can access local variables from the enclosing scope only if they are declared as ____.

(Multiple Choice)
4.8/5
(34)

A/an ____ class defined in a method signals to the reader of your program that the class is not interesting beyond the scope of the method.

(Multiple Choice)
4.8/5
(42)

When you use a timer, you need to define a class that implements the ____ interface.

(Multiple Choice)
4.9/5
(35)

Suppose listener is an instance of a class that implements the MouseListener interface. How many methods does listener have?

(Multiple Choice)
4.8/5
(41)

Which of the following statements about abstract methods is true?

(Multiple Choice)
4.7/5
(42)

A(n) ____ has an instance method addActionListener() for specifying which object is responsible for implementing the action associated with the object.

(Multiple Choice)
4.8/5
(31)

____ methods must be implemented when using an interface.

(Multiple Choice)
4.7/5
(40)

Consider the following code snippet: class MyListener implements ActionListener { Public void actionPerformed(ActionEvent event) { System.out.println(event); } } Timer t = new Timer(interval, listener); t.start(); What is wrong with this code?

(Multiple Choice)
4.8/5
(32)

Which of the following statements about an inner class is true?

(Multiple Choice)
4.8/5
(38)

Assuming that interface Resizable is declared elsewhere, consider the following class declaration: public class InnerClassExample { Public static void main(String[] args) { Class SizeModifier implements Resizable { // class methods } __________________________ // missing statement } } Which of the following declarations can be used to complete the main method?

(Multiple Choice)
4.8/5
(36)

When an event occurs, the event source notifies all ____.

(Multiple Choice)
4.8/5
(39)

Consider the following code snippet: public interface Sizable { Int LARGE_CHANGE = 100; Int SMALL_CHANGE = 20; Void changeSize(); } Which of the following statements is true?

(Multiple Choice)
4.7/5
(36)

Event listeners are often installed as ____ classes so that they can have access to the surrounding fields, methods, and final variables.

(Multiple Choice)
4.8/5
(34)

The Timer class is found in the ____ package.

(Multiple Choice)
4.7/5
(31)

The method below is designed to print the smaller of two values received as arguments. Select the correct expression to complete the method. public void showSmaller(Comparable value1, Comparable value2) { If ( _________________________ ) System.out.println(value1 + " is smaller."); Else System.out.println(value2 + " is smaller."); }

(Multiple Choice)
4.9/5
(35)
Showing 21 - 40 of 85
close modal

Filters

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