Intro to Java Programming Chapter 10

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which of the following statements about an inner class is true? A. An inner class is used for a utility class that should be visible elsewhere in the program. B. An inner class that is defined inside a method is publicly accessible. C. An inner class that is defined inside a method is not publicly accessible. D. An inner class that is defined inside an enclosing class but outside of its methods is not available to all methods of the enclosing class.

C. An inner class that is defined inside a method is not publicly accessible.

Which of the following statements about a Java interface is NOT true? A. A Java interface must contain more than one method. B. A Java interface defines a set of methods that are required. C. A Java interface specifies behavior that a class will implement. D. All methods in a Java interface must be public.

A. A Java interface must contain more than one method.

A method that has no implementation is called a/an ____ method. A. abstract B. overloaded C. interface D. implementation

A. abstract

When an event occurs, the event source notifies all ____. A. event listeners B. components C. panels D. interfaces

A. event listeners

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? A. LARGE_CHANGE and SMALL_CHANGE are instance variables. B. LARGE_CHANGE and SMALL_CHANGE are automatically public static final. C. LARGE_CHANGE and SMALL_CHANGE must be defined with the keywords private static final. D. LARGE_CHANGE and SMALL_CHANGE must be defined with the keywords public static final.

B. LARGE_CHANGE and SMALL_CHANGE are automatically public static final.

If you have multiple classes in your program that have implemented the same interface in different ways, how is the correct method executed? A. The method must be qualified with the class name to determine the correct method. B. The Java virtual machine must locate the correct method by looking at the class of the actual object. C. You cannot have multiple classes in the same program with different implementations of the same interface. D. The compiler must determine which method implementation to use.

B. The Java virtual machine must locate the correct method by looking at the class of the actual object.

Consider the definition of the Measurable interface and the code snippet defining the Inventory class: public interface Measurable { double getMeasure(); } public class Inventory implements Measurable { . . . double getMeasure() { return onHandCount; } } What is wrong with this code? A. The getMeasure() method must be declared as private. B. The getMeasure() method must be declared as public. C. The getMeasure() method must include the implements keyword. D. The getMeasure() method must not have any code within it.

B. The getMeasure() method must be declared as public.

What is the preferred way to implement event listeners? A. Use interfaces as event listeners. B. Use inner classes as event listeners. C. Use methods as event listeners. D. Use containers as event listeners.

B. Use inner classes as event listeners.

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? A. String aString B. Object aString C. Object anObject D. String anObject

C. Object anObject

To use an interface, a class header should include which of the following? A. The keyword extends and the name of the interface B. The keyword extends and the name of an abstract method in the interface C. The keyword implements and the name of an abstract method in the interface D. The keyword implements and the name of the interface

C. The keyword implements and the name of an abstract method in the interface

The ____ class in the javax.swing package generates a sequence of events, spaced apart at even time intervals. A. Clock B. TimeClock C. Timer D. StopWatch

C. Timer

Which of the following is true regarding a class and interface types? A. You can convert from a class type to any interface type that the class extends. B. You cannot convert from a class type to any interface type. C. You can convert from a class type to any interface type that the class implements. D. You can convert from a class type to any interface type that is in the same package as the class.

C. You can convert from a class type to any interface type that the class implements.

What type of edge does UML use to denote interface implementation? A. A dotted arrow from the interface to the class terminated with a triangular tip. B. A dotted arrow from the class to the interface terminated with an open arrow tip. C. A dotted arrow from the interface to the class terminated with an open arrow tip. D. A dotted arrow from the class to the interface terminated with a triangular tip.

D. A dotted arrow from the class to the interface terminated with a triangular tip.

To process mouse events, you need to define a class that implements the ____ interface. A. EventListener B. TimerListener C. ActionListener D. MouseListener

D. MouseListener

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. A. protected B. interface C. abstract D. inner

D. inner


संबंधित स्टडी सेट्स

Human Development Final Exam Review

View Set

Chapter 2-ENTR-202: Small Business Entrepreneurs: Characteristics and Competencies

View Set

UWorld Gastrointestinal/Nutrition

View Set

Recursive Formulas for Arithmetic Sequences

View Set

SUBJECT and OBJECT PRONOUNS: Replace the object and subject with the correct pronoun!

View Set

Chapter 5: Traffic-Control Devices

View Set