Deck 10: Interfaces
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/85
Play
Full screen (f)
Deck 10: Interfaces
1
____ methods must be implemented when using an interface.
A) Abstract.
B) Private.
C) Public.
D) Static
A) Abstract.
B) Private.
C) Public.
D) Static
A
2
Consider the following code snippet: public class Inventory implements Measurable
{
) . .
Double getMeasure();
{
Return onHandCount;
}
}
The compiler complains that the getMeasure method has a weaker access level than the Measurable interface. Why?
A) All of the methods in a class have a default access level of package access, while the methods of an interface have a default access level of private.
B) All of the methods in a class have a default access level of package access, while the methods of an interface have a default access level of public.
C) The variable onHandCount was not declared with public access.
D) The getMeasure method was declared as private in the Measurable interface.
{
) . .
Double getMeasure();
{
Return onHandCount;
}
}
The compiler complains that the getMeasure method has a weaker access level than the Measurable interface. Why?
A) All of the methods in a class have a default access level of package access, while the methods of an interface have a default access level of private.
B) All of the methods in a class have a default access level of package access, while the methods of an interface have a default access level of public.
C) The variable onHandCount was not declared with public access.
D) The getMeasure method was declared as private in the Measurable interface.
B
3
Which of the following statements about interfaces is NOT true?
A) Interfaces can make code more reusable.
B) An interface provides no implementation.
C) A class can implement only one interface type.
D) Interfaces can reduce the coupling between classes.
A) Interfaces can make code more reusable.
B) An interface provides no implementation.
C) A class can implement only one interface type.
D) Interfaces can reduce the coupling between classes.
C
4
Which of the following statements about a Java interface is NOT true?
A) A Java interface defines a set of methods that are required.
B) A Java interface must contain more than one method.
C) A Java interface specifies behavior that a class will implement.
D) All methods in a Java interface must be abstract.
A) A Java interface defines a set of methods that are required.
B) A Java interface must contain more than one method.
C) A Java interface specifies behavior that a class will implement.
D) All methods in a Java interface must be abstract.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following statements about an interface is true?
A) An interface has methods and instance variables.
B) An interface has methods but no instance variables.
C) An interface has neither methods nor instance variables.
D) An interface has both public and private methods.
A) An interface has methods and instance variables.
B) An interface has methods but no instance variables.
C) An interface has neither methods nor instance variables.
D) An interface has both public and private methods.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
6
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?
A) Coin dime = new Coin(0.1, "dime");
Measurable x = dime;
B) Coin dime = new Coin(0.1, "dime");
Dataset x = dime;
C) Coin dime = new Coin(0.1, "dime");
DataSet x == (Measureable)dime;
D) Coin dime = new Coin(0.1, "dime");
BankAccount x = dime;
{
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?
A) Coin dime = new Coin(0.1, "dime");
Measurable x = dime;
B) Coin dime = new Coin(0.1, "dime");
Dataset x = dime;
C) Coin dime = new Coin(0.1, "dime");
DataSet x == (Measureable)dime;
D) Coin dime = new Coin(0.1, "dime");
BankAccount x = dime;
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
7
Consider the following code snippet: 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 include the implements keyword.
C) The getMeasure() method must be declared as public.
D) The getMeasure() method must not have any code within it.
{
) . .
Double getMeasure();
{
Return onHandCount;
}
}
What is wrong with this code?
A) The getMeasure() method must be declared as private.
B) The getMeasure() method must include the implements keyword.
C) The getMeasure() method must be declared as public.
D) The getMeasure() method must not have any code within it.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
8
Consider the following code snippet: public class Inventory implements Measurable
{
) . .
Public double getMeasure();
{
Return onHandCount;
}
}
Why is it necessary to declare getMeasure as public ?
A) All methods in a class are not public by default.
B) All methods in an interface are private by default.
C) It is necessary only to allow other classes to use this method.
D) It is not necessary to declare this method as public.
{
) . .
Public double getMeasure();
{
Return onHandCount;
}
}
Why is it necessary to declare getMeasure as public ?
A) All methods in a class are not public by default.
B) All methods in an interface are private by default.
C) It is necessary only to allow other classes to use this method.
D) It is not necessary to declare this method as public.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following statements about abstract methods is true?
A) An abstract method has a name, parameters, and a return type, but no code in the body of the method.
B) An abstract method has parameters, a return type, and code in its body, but has no defined name.
C) An abstract method has a name, a return type, and code in its body, but has no parameters.
D) An abstract method has only a name and a return type, but no parameters or code in its body.
A) An abstract method has a name, parameters, and a return type, but no code in the body of the method.
B) An abstract method has parameters, a return type, and code in its body, but has no defined name.
C) An abstract method has a name, a return type, and code in its body, but has no parameters.
D) An abstract method has only a name and a return type, but no parameters or code in its body.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
10
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?
A) public void encrypt()
B) public void encrypt(String aKey)
C) public String encrypt(String aKey)
D) void encrypt(String aKey)
{
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?
A) public void encrypt()
B) public void encrypt(String aKey)
C) public String encrypt(String aKey)
D) void encrypt(String aKey)
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
11
To use an interface, a class header should include which of the following?
A) The keyword extends and the name of an abstract method in the interface
B) The keyword extends and the name of 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
A) The keyword extends and the name of an abstract method in the interface
B) The keyword extends and the name of 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
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
12
____ can reduce the coupling between classes.
A) Static methods
B) Abstract methods
C) Interfaces
D) Objects
A) Static methods
B) Abstract methods
C) Interfaces
D) Objects
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
13
Which statement about methods in an interface is true?
A) All methods in an interface are automatically private.
B) All methods in an interface are automatically public.
C) All methods in an interface are automatically static.
D) All methods in an interface must be explicitly declared as private or public.
A) All methods in an interface are automatically private.
B) All methods in an interface are automatically public.
C) All methods in an interface are automatically static.
D) All methods in an interface must be explicitly declared as private or public.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
14
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?
A) private void resize();
B) protected void resize();
C) void resize();
D) public void resize() { System.out.println("resizing ..."); }
{
_________________________
}
Which of the following can be used to complete the interface declaration correctly?
A) private void resize();
B) protected void resize();
C) void resize();
D) public void resize() { System.out.println("resizing ..."); }
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following statements about converting between types is true?
A) When you cast number types, you take a risk that an exception will occur.
B) When you cast number types, you will not lose information.
C) When you cast object types, you take a risk of losing information.
D) When you cast object types, you take a risk that an exception will occur.
A) When you cast number types, you take a risk that an exception will occur.
B) When you cast number types, you will not lose information.
C) When you cast object types, you take a risk of losing information.
D) When you cast object types, you take a risk that an exception will occur.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following statements about interfaces is true?
A) You can define an interface variable that refers to an object of any class in the same package.
B) You cannot define a variable whose type is an interface.
C) You can instantiate an object from an interface class.
D) You can define an interface variable that refers to an object only if the object belongs to a class that implements the interface.
A) You can define an interface variable that refers to an object of any class in the same package.
B) You cannot define a variable whose type is an interface.
C) You can instantiate an object from an interface class.
D) You can define an interface variable that refers to an object only if the object belongs to a class that implements the interface.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
17
A method that has no implementation is called a/an ____ method.
A) interface
B) implementation
C) overloaded
D) abstract
A) interface
B) implementation
C) overloaded
D) abstract
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following statements about interfaces is NOT true?
A) Interfaces can make code more reusable.
B) Interface types can be used to define a new reference data type.
C) Interface types can be used to express common operations required by a service.
D) Interfaces have both private and public methods.
A) Interfaces can make code more reusable.
B) Interface types can be used to define a new reference data type.
C) Interface types can be used to express common operations required by a service.
D) Interfaces have both private and public methods.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
19
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 automatically public static final.
B) LARGE_CHANGE and SMALL_CHANGE are instance variables
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.
{
Int LARGE_CHANGE = 100;
Int SMALL_CHANGE = 20;
Void changeSize();
}
Which of the following statements is true?
A) LARGE_CHANGE and SMALL_CHANGE are automatically public static final.
B) LARGE_CHANGE and SMALL_CHANGE are instance variables
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.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
20
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 is in the same package as the class.
B) You can convert from a class type to any interface type that the class implements.
C) You can convert from a class type to any interface type that the class defines.
D) You cannot convert from a class type to any interface type.
A) You can convert from a class type to any interface type that is in the same package as the class.
B) You can convert from a class type to any interface type that the class implements.
C) You can convert from a class type to any interface type that the class defines.
D) You cannot convert from a class type to any interface type.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
21
In Java, ____ can be used for callbacks.
A) Objects
B) Interfaces
C) Classes
D) Operators
A) Objects
B) Interfaces
C) Classes
D) Operators
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
22
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 Java virtual machine must locate the correct method by looking at the class of the actual object.
B) The compiler must determine which method implementation to use.
C) The method must be qualified with the class name to determine the correct method.
D) You cannot have multiple classes in the same program with different implementations of the same interface.
A) The Java virtual machine must locate the correct method by looking at the class of the actual object.
B) The compiler must determine which method implementation to use.
C) The method must be qualified with the class name to determine the correct method.
D) You cannot have multiple classes in the same program with different implementations of the same interface.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following statements about an inner class is true?
A) An inner class that is defined inside a method is publicly accessible.
B) An inner class that is defined inside a method is not publicly accessible.
C) 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.
D) An inner class is used for a utility class that should be visible elsewhere in the program.
A) An inner class that is defined inside a method is publicly accessible.
B) An inner class that is defined inside a method is not publicly accessible.
C) 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.
D) An inner class is used for a utility class that should be visible elsewhere in the program.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
24
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.");
}
A) value1 < value2
B) value1.compareTo(value2) > 0
C) value1.compareTo(value2) == 0
D) value1.compareTo(value2) < 0
{
If ( _________________________ )
System.out.println(value1 + " is smaller.");
Else
System.out.println(value2 + " is smaller.");
}
A) value1 < value2
B) value1.compareTo(value2) > 0
C) value1.compareTo(value2) == 0
D) value1.compareTo(value2) < 0
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
25
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?
A) Resizable something = new Resizable();
B) Resizable something = new SizeModifier();
C) Resizable something = new InnerClassExample();
D) SizeModifier something = new Resizable();
{
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?
A) Resizable something = new Resizable();
B) Resizable something = new SizeModifier();
C) Resizable something = new InnerClassExample();
D) SizeModifier something = new Resizable();
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
26
Which of the following statements about a callback is NOT true?
A) A callback can allow you to implement a new method for a class that is not under your control.
B) A callback can be implemented using an interface.
C) A callback is a mechanism for specifying code to be executed later.
D) A callback method declared in an interface must specify the class of objects that it will manipulate.
A) A callback can allow you to implement a new method for a class that is not under your control.
B) A callback can be implemented using an interface.
C) A callback is a mechanism for specifying code to be executed later.
D) A callback method declared in an interface must specify the class of objects that it will manipulate.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following is a good use for an anonymous class?
A) Use an anonymous class to implement polymorphism.
B) Use an anonymous class to implement a callback.
C) Use an anonymous class when all methods of the class will be static methods.
D) Use an anonymous class when the program will only need one object of the class.
A) Use an anonymous class to implement polymorphism.
B) Use an anonymous class to implement a callback.
C) Use an anonymous class when all methods of the class will be static methods.
D) Use an anonymous class when the program will only need one object of the class.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
28
Which of the following statements about an inner class is true?
A) An inner class can only be defined within a specific method of its enclosing class.
B) An inner class can only be defined outside of any method within its enclosing class.
C) An inner class must implement an interface.
D) An inner class may be anonymous.
A) An inner class can only be defined within a specific method of its enclosing class.
B) An inner class can only be defined outside of any method within its enclosing class.
C) An inner class must implement an interface.
D) An inner class may be anonymous.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
29
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?
A) Create a new class that mimics the system class.
B) Extend the system class.
C) Use an inner class in the interface.
D) Use a helper class that implements the callback method.
A) Create a new class that mimics the system class.
B) Extend the system class.
C) Use an inner class in the interface.
D) Use a helper class that implements the callback method.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
30
____ occurs when a single class has several methods with the same name but different parameter types.
A) Casting
B) Polymorphism
C) Overloading
D) Instantiation
A) Casting
B) Polymorphism
C) Overloading
D) Instantiation
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
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._________________;
A) increaseSize()
B) decreaseSize()
C) display()
D) display(5)
{
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._________________;
A) increaseSize()
B) decreaseSize()
C) display()
D) display(5)
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
32
Consider the following code snippet: myImage.add(new Rectangle(10,10,10,10));
This code is an example of using ____.
A) An anonymous class.
B) An anonymous object.
C) An abstract object.
D) An abstract class.
This code is an example of using ____.
A) An anonymous class.
B) An anonymous object.
C) An abstract object.
D) An abstract class.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
33
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?
A) The object to which motorTemperature refers has type Measurable.
B) The object to which motorTemperature refers has type Motor.
C) This declaration is illegal.
D) You must construct a motorTemperature object from the Measurable interface.
A) The object to which motorTemperature refers has type Measurable.
B) The object to which motorTemperature refers has type Motor.
C) This declaration is illegal.
D) You must construct a motorTemperature object from the Measurable interface.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
34
Which of the following can potentially be changed when implementing an interface?
A) The parameters of a method in the interface.
B) The name of a method in the interface.
C) The return type of a method in the interface.
D) You cannot change the name, return type, or parameters of a method in the interface.
A) The parameters of a method in the interface.
B) The name of a method in the interface.
C) The return type of a method in the interface.
D) You cannot change the name, return type, or parameters of a method in the interface.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
35
Which of the following statements about a mock class is true?
A) A mock class does not provide an implementation of the services of the actual class.
B) A mock class provides a complete implementation of the services of the actual class.
C) A mock class provides a simplified implementation of the services of the actual class.
D) A mock class must be an interface.
A) A mock class does not provide an implementation of the services of the actual class.
B) A mock class provides a complete implementation of the services of the actual class.
C) A mock class provides a simplified implementation of the services of the actual class.
D) A mock class must be an interface.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
36
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) A class cannot be defined within a method
B) abstract
C) interface
D) inner
A) A class cannot be defined within a method
B) abstract
C) interface
D) inner
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
37
Consider the following code snippet: public class Demo
{
Public static void main(String[] args)
{
Point[] p = new Point[4];
P[0] = new Colored3DPoint(4, 4, 4, Color.BLACK);
P[1] = new ThreeDimensionalPoint(2, 2, 2);
P[2] = new ColoredPoint(3, 3, Color.RED);
P[3] = new Point(4, 4);
For (int i = 0; i < p.length; i++)
{
String s = p[i].toString();
System.out.println("p[" + i + "] : " + s);
}
Return;
}
}
This code is an example of ____.
A) overloading
B) callback
C) early binding
D) polymorphism
{
Public static void main(String[] args)
{
Point[] p = new Point[4];
P[0] = new Colored3DPoint(4, 4, 4, Color.BLACK);
P[1] = new ThreeDimensionalPoint(2, 2, 2);
P[2] = new ColoredPoint(3, 3, Color.RED);
P[3] = new Point(4, 4);
For (int i = 0; i < p.length; i++)
{
String s = p[i].toString();
System.out.println("p[" + i + "] : " + s);
}
Return;
}
}
This code is an example of ____.
A) overloading
B) callback
C) early binding
D) polymorphism
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
38
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) Object anObject
B) String anObject
C) Object aString
D) String aString
{
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) Object anObject
B) String anObject
C) Object aString
D) String aString
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
39
Which of the following statements about helper classes is true?
A) Helper classes must be inner classes.
B) Helper classes must implement interfaces.
C) Helper classes help reduce coupling.
D) Helper classes cannot contain instance variables.
A) Helper classes must be inner classes.
B) Helper classes must implement interfaces.
C) Helper classes help reduce coupling.
D) Helper classes cannot contain instance variables.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
40
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?
A) Player otherPlayer = otherObject;
B) Object otherPlayer = otherObject;
C) Player otherPlayer = (Player) otherObject;
D) Object otherPlayer = (Player) otherObject;
{
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?
A) Player otherPlayer = otherObject;
B) Object otherPlayer = otherObject;
C) Player otherPlayer = (Player) otherObject;
D) Object otherPlayer = (Player) otherObject;
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
41
What role does an interface play when using a mock class?
A) The mock class should be an interface that will be implemented by the real class.
B) The real class should be an interface that will be implemented by the mock class.
C) Interfaces are not involved when using mock classes.
D) An interface should be implemented by both the real class and the mock class to guarantee that the mock class accurately simulates the real class when used in a program.
A) The mock class should be an interface that will be implemented by the real class.
B) The real class should be an interface that will be implemented by the mock class.
C) Interfaces are not involved when using mock classes.
D) An interface should be implemented by both the real class and the mock class to guarantee that the mock class accurately simulates the real class when used in a program.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
42
Which container is used to group multiple user-interface components together?
A) text area
B) table
C) panel
D) rectangle
A) text area
B) table
C) panel
D) rectangle
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
43
Which of the following code statements creates a graphical button which has "Calculate" as its label ?
A) Button JButton = new Button("Calculate").
B) button = new Button(JButton, "Calculate").
C) button = new JButton("Calculate").
D) JButton button = new JButton("Calculate").
A) Button JButton = new Button("Calculate").
B) button = new Button(JButton, "Calculate").
C) button = new JButton("Calculate").
D) JButton button = new JButton("Calculate").
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
44
To respond to a button event, a listener must supply instructions for the ____ method of the ActionListener interface.
A) actionEvent.
B) actionPerformed
C) eventAction
D) eventResponse
A) actionEvent.
B) actionPerformed
C) eventAction
D) eventResponse
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
45
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?
A) public void actionPerformed(ActionEvent event)
B) public void actionPerformed(ClickListener event)
C) public void actionPerformed()
D) public void actionPerformed(ActionListener event)
{
__________________________________________
{
System.out.println("mouse event ...");
}
}
Which of the following method headers should be used to complete the ClickListener class?
A) public void actionPerformed(ActionEvent event)
B) public void actionPerformed(ClickListener event)
C) public void actionPerformed()
D) public void actionPerformed(ActionListener event)
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
46
To associate an event listener with a JButton component, you must use the ___ method of the JButton class.
A) addEventListener.
B) addActionListener.
C) addButtonListener.
D) addListener
A) addEventListener.
B) addActionListener.
C) addButtonListener.
D) addListener
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
47
Event listeners are often installed as ____ classes so that they can have access to the surrounding fields, methods, and final variables.
A) Inner
B) Interface
C) Abstract
D) Helper
A) Inner
B) Interface
C) Abstract
D) Helper
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
48
____ are generated when the user presses a key, clicks a button, or selects a menu item.
A) Listeners
B) Interfaces.
C) Events.
D) Errors.
A) Listeners
B) Interfaces.
C) Events.
D) Errors.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
49
Which of the following statements about listener classes is true?
A) A listener class cannot be declared as an anonymous inner class.
B) A listener class cannot be declared as an inner class.
C) A listener class must be declared as an inner class.
D) A listener class must be declared as an anonymous inner class.
A) A listener class cannot be declared as an anonymous inner class.
B) A listener class cannot be declared as an inner class.
C) A listener class must be declared as an inner class.
D) A listener class must be declared as an anonymous inner class.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
50
The methods of a/an ____ describe the actions to be taken when an event occurs.
A) event source
B) event listener
C) event interface
D) action source
A) event source
B) event listener
C) event interface
D) action source
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
51
An inner class can access local variables from the enclosing scope only if they are declared as ____.
A) private
B) public
C) static
D) final
A) private
B) public
C) static
D) final
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
52
A/an ____ belongs to a class whose methods describe the actions to be taken when a user clicks a user-interface graphical object.
A) Event listener
B) Event source
C) Action listener
D) Action method
A) Event listener
B) Event source
C) Action listener
D) Action method
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
53
Which of the following statements will compile without error?
A) public interface AccountListener()
{
Void actionPerformed(AccountEvent event);
}
B) public interface AccountListener()
{
Void actionPerformed(AccountEvent);
}
C) public interface AccountListener
{
Void actionPerformed(AccountEvent event);
}
D) public abstract AccountListener
{
Void actionPerformed(AccountEvent event);
}
A) public interface AccountListener()
{
Void actionPerformed(AccountEvent event);
}
B) public interface AccountListener()
{
Void actionPerformed(AccountEvent);
}
C) public interface AccountListener
{
Void actionPerformed(AccountEvent event);
}
D) public abstract AccountListener
{
Void actionPerformed(AccountEvent event);
}
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
54
Which of the following statements about an inner class is true?
A) An inner class may not be declared within a method of the enclosing scope.
B) An inner class may only be declared within a method of the enclosing scope.
C) An inner class can access variables from the enclosing scope only if they are passed as constructor or method parameters.
D) The methods of an inner class can access variables declared in the enclosing scope.
A) An inner class may not be declared within a method of the enclosing scope.
B) An inner class may only be declared within a method of the enclosing scope.
C) An inner class can access variables from the enclosing scope only if they are passed as constructor or method parameters.
D) The methods of an inner class can access variables declared in the enclosing scope.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
55
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?
A) Class ButtonTester is an interface type.
B) A ClickListener object can be added as a listener for the action events that buttons generate.
C) Class ClickListener is an interface type.
D) Class ButtonTester implements an interface type.
{
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?
A) Class ButtonTester is an interface type.
B) A ClickListener object can be added as a listener for the action events that buttons generate.
C) Class ClickListener is an interface type.
D) Class ButtonTester implements an interface type.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
56
When an event occurs, the event source notifies all ____.
A) components
B) panels
C) interfaces
D) event listeners
A) components
B) panels
C) interfaces
D) event listeners
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
57
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?
A) java.swing.event.ActionEvent;.
B) javax.swing.event.ActionEvent;
C) javax.awt.event.ActionEvent;
D) java.awt.event.ActionEvent;
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?
A) java.swing.event.ActionEvent;.
B) javax.swing.event.ActionEvent;
C) javax.awt.event.ActionEvent;
D) java.awt.event.ActionEvent;
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
58
Which of the following is an event source?
A) A JButton object.
B) An event listener.
C) An inner class.
D) An event adapter.
A) A JButton object.
B) An event listener.
C) An inner class.
D) An event adapter.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
59
Which of the following statements about events and graphical user interface programs is true?
D) Your program must override the default methods to handle events.
A) Your program must instruct the Java window manager to send it notifications about specific types of events to which the program wishes to respond.
B) The Java window manager will automatically send your program notifications about all events that have occurred.
C) Your program must respond to notifications of all types of events that are sent to it by the Java window manager.
D) Your program must override the default methods to handle events.
A) Your program must instruct the Java window manager to send it notifications about specific types of events to which the program wishes to respond.
B) The Java window manager will automatically send your program notifications about all events that have occurred.
C) Your program must respond to notifications of all types of events that are sent to it by the Java window manager.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
60
Consider the following code snippet: JFrame frame = new JFrame();
JPanel panel = new JPanel
Which statement would add the panel to the frame?
A) frame.add(panel);
B) frame.add(JPanel panel);
C) frame.addComponent(panel);
D) frame.addComponent(JPanel panel);
JPanel panel = new JPanel
Which statement would add the panel to the frame?
A) frame.add(panel);
B) frame.add(JPanel panel);
C) frame.addComponent(panel);
D) frame.addComponent(JPanel panel);
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
61
When you use a timer, you need to define a class that implements the ____ interface.
A) TimerListener
B) TimerActionListener
C) ActionListener
D) StartTimerListener
A) TimerListener
B) TimerActionListener
C) ActionListener
D) StartTimerListener
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
62
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?
A) button should be declared as final
B) The listener has not been attached to the button.
C) The listener cannot access the methods of the myOrder object.
D) This code will display the total order amount.
{
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?
A) button should be declared as final
B) The listener has not been attached to the button.
C) The listener cannot access the methods of the myOrder object.
D) This code will display the total order amount.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
63
To build a user interface that contains graphical components, the components ____.
A) Must be added directly to a frame component.
B) Must each be added to a separate panel.
C) Must be added to a panel that is contained within a frame.
D) Must be added to a frame that is contained within a panel.
A) Must be added directly to a frame component.
B) Must each be added to a separate panel.
C) Must be added to a panel that is contained within a frame.
D) Must be added to a frame that is contained within a panel.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
64
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?
A) The Timer object should be declared before the MyListener class.
B) The listener has not been attached to the Timer object.
C) The Timer object must be declared as final.
D) There is nothing wrong with the code.
{
Public void actionPerformed(ActionEvent event)
{
System.out.println(event);
}
}
Timer t = new Timer(interval, listener);
T)start();
What is wrong with this code?
A) The Timer object should be declared before the MyListener class.
B) The listener has not been attached to the Timer object.
C) The Timer object must be declared as final.
D) There is nothing wrong with the code.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
65
The ____ class in the javax.swing package generates a sequence of events, spaced apart at even time intervals.
A) TimeClock
B) Timer
C) Clock
D) StopWatch
A) TimeClock
B) Timer
C) Clock
D) StopWatch
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
66
The Timer class is found in the ____ package.
A) java.awt.
B) javax.awt.
C) java.swing.
D) javax.swing.
A) java.awt.
B) javax.awt.
C) java.swing.
D) javax.swing.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
67
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?
A) private static final int FRAME_WIDTH = 300;
B) private static final int FRAME_HEIGHT = 400;
C) Frame frame = new Frame();
D) JFrame frame = new JFrame();
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?
A) private static final int FRAME_WIDTH = 300;
B) private static final int FRAME_HEIGHT = 400;
C) Frame frame = new Frame();
D) JFrame frame = new JFrame();
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
68
The ____ method should be called whenever you modify the shapes that the paintComponent method draws.
A) draw
B) paint
C) paintComponent
D) repaint
A) draw
B) paint
C) paintComponent
D) repaint
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
69
Consider the following code snippet: 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)
{
) . .
}
}
}
Which of the local variables can be accessed within the actionPerformed method?
A) Only button can be accessed..
B) All of the local variables can be accessed.
C) label and myOrder can be accessed.
D) Only myOrder can be accessed.
{
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)
{
) . .
}
}
}
Which of the local variables can be accessed within the actionPerformed method?
A) Only button can be accessed..
B) All of the local variables can be accessed.
C) label and myOrder can be accessed.
D) Only myOrder can be accessed.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
70
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();
A) Timer timer = new Timer(listener);
B) Timer timer = new Timer(1, listener);
C) Timer timer = new Timer(100, listener);
D) Timer timer = new Timer(1000, listener);
_________________________________ // missing statement
Timer.start();
A) Timer timer = new Timer(listener);
B) Timer timer = new Timer(1, listener);
C) Timer timer = new Timer(100, listener);
D) Timer timer = new Timer(1000, listener);
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
71
Use the ____ method to specify the height and width of a graphical component when you add it to a panel.
A) setPreferredDimensions.
B) setInitialDimensions.
C) setPreferredSize.
D) setInitialSize.
A) setPreferredDimensions.
B) setInitialDimensions.
C) setPreferredSize.
D) setInitialSize.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
72
Suppose listener is an instance of a class that implements the MouseListener interface. How many methods does listener have?
A) 0
B) 1
C) 3
D) at least 5
A) 0
B) 1
C) 3
D) at least 5
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
73
Consider the following code snippet: public static void main(String[] args)
{
Order myOrder = new Order();
JButton button = new JButton("Calculate");
JLabel label = new JLabel("Total amount due");
) . .
Class MyListener implements ActionListener
{
Public void actionPerformed(ActionEvent event)
{
Label.setText("Total amount due " + myOrder.getAmountDue());
}
}
}
What is wrong with this code?
A) label must be declared as final.
B) myOrder must be declared as final
C) label and myOrder must be declared as final
D) label and button must be declared as final.
{
Order myOrder = new Order();
JButton button = new JButton("Calculate");
JLabel label = new JLabel("Total amount due");
) . .
Class MyListener implements ActionListener
{
Public void actionPerformed(ActionEvent event)
{
Label.setText("Total amount due " + myOrder.getAmountDue());
}
}
}
What is wrong with this code?
A) label must be declared as final.
B) myOrder must be declared as final
C) label and myOrder must be declared as final
D) label and button must be declared as final.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
74
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(Graphics
A) repaint();
B) g2.draw(box);
C) box.setLocation(x, y);
D) private Rectangle box;
G) {
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?
{
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(Graphics
A) repaint();
B) g2.draw(box);
C) box.setLocation(x, y);
D) private Rectangle box;
G) {
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?
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
75
A(n) ____ has an instance method addActionListener() for specifying which object is responsible for implementing the action associated with the object.
A) JFrame
B) JSlider
C) JButton
D) JLabel
A) JFrame
B) JSlider
C) JButton
D) JLabel
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
76
How do you specify what the program should do when the user clicks a button?
A) Specify the actions to take in a class that implements the ButtonListener interface.
B) Specify the actions to take in a class that implements the ButtonEvent interface .
C) Specify the actions to take in a class that implements the ActionListener interface.
D) Specify the actions to take in a class that implements the EventListener interface.
A) Specify the actions to take in a class that implements the ButtonListener interface.
B) Specify the actions to take in a class that implements the ButtonEvent interface .
C) Specify the actions to take in a class that implements the ActionListener interface.
D) Specify the actions to take in a class that implements the EventListener interface.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
77
Use the ____ method to add a mouse listener to a component.
A) addListener
B) addMouseListener
C) addActionListener
D) addMouseActionListener
A) addListener
B) addMouseListener
C) addActionListener
D) addMouseActionListener
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
78
If the user presses and releases a mouse button in quick succession, which methods of the MouseListener interface are called?
A) mousePressed, mouseReleased, and mouseClicked.
B) mousePressed, mouseReleased, and mouseDblClicked
C) Only the mouseClicked method.
D) Only the mouseDblClicked method.
A) mousePressed, mouseReleased, and mouseClicked.
B) mousePressed, mouseReleased, and mouseDblClicked
C) Only the mouseClicked method.
D) Only the mouseDblClicked method.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
79
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?
A) You must call the component object's paintComponent() method.
B) You must call the component object's repaint() method.
C) You do not have to do anything - the component object will be automatically repainted when its data changes.
D) You must use a Timer object to cause the component object to be updated.
A) You must call the component object's paintComponent() method.
B) You must call the component object's repaint() method.
C) You do not have to do anything - the component object will be automatically repainted when its data changes.
D) You must use a Timer object to cause the component object to be updated.
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck
80
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
A) myPanel.addActionListener(listener);
B) myButton.addActionListener(listener);
C) myPanel.addActionListener(myButton);
D) myButton.addActionListener(ClickListener);
JButton myButton = new JButton("Submit");
JPanel myPanel = new JPanel();
MyPanel.add(myButton);
______________________ // missing statement
A) myPanel.addActionListener(listener);
B) myButton.addActionListener(listener);
C) myPanel.addActionListener(myButton);
D) myButton.addActionListener(ClickListener);
Unlock Deck
Unlock for access to all 85 flashcards in this deck.
Unlock Deck
k this deck