Which of the following would NOT be considered an "event"?
Pressing the up arrow key to move text on a GUI |
||
Compiling the code for a GUI |
||
Dragging the mouse across the GUI |
||
Clicking a button on a GUI |
QUESTION 2
Which which Event class does MouseEvent extend?
InputEvent |
||
ActionEvent |
||
KeyEvent |
||
WindowEvent |
QUESTION 3
There are three parts of an event. Which of the following is NOT part of an event?
The source - the source is where the event originated from, such as the mouse or keyboard |
||
The type - the type is the specific type of event that occurred such as mouse pressed, key released, and window closed |
||
The target - the target is the node on which the event occurred |
||
The click - the click tells you where the mouse was clicked |
QUESTION 4
What is the name of the method that you must override when create an EventHandler?
handle |
||
start |
||
run |
||
invalidated |
QUESTION 5
An anonymous class is ____.
a class that nobody knows about. |
||
a class that isn't named. |
||
an abstract class. |
||
a class that is marked as private. |
QUESTION 6
What exactly is EventHandler?
an object |
||
a method |
||
a class |
||
an interface |
QUESTION 7
View the code below and choose the answer that best describes what is going on.
When anywhere in the window is clicked, the inside of a circle will change to a different color as determined by a random number generator. |
||
When the mouse is dragged across the screen, the inside of a circle will change to a different color as determined by a random number generator. |
||
When the circle is clicked by the mouse, the inside of it will change to a different color as determined by a random number generator. |
||
When a button is pushed, the inside of a circle will change to a different color as determined by a random number generator. |
QUESTION 8
Which of the following is NOT a feature of lambda expressions?
It simplifies code for event handling. |
||
It cuts down on the number of lines of code needed when creating event handlers. |
||
It is an anonymous class with concise syntax. |
||
It puts little lambs in your code. Duh. |
QUESTION 9
What line of code must be present in your program in order to use a KeyEvent and where should this line be placed in the code? (Assume that the name of the node we are using the KeyEvent on is called "text.")
text.focus() It should be placed outside of the start method. |
||
text.keyEventFocus() It should be placed before you create the scene. |
||
text.requestKeyFocus() It should be placed in the main method. |
||
text.requestFocus() It should be placed after we show the stage. |
QUESTION 10
When viewing Lambda expressions, what is e -> ?
e is the name of the Exception object being thrown and -> is pointing to the catch code |
||
e means "lambda expression" and nothing more while the -> is to show where the lambda code goes |
||
e is the name of the Event object that must be created and -> is the lambda operator |
||
e is a placeholder for a mouse pressed event and the -> is pointing to the mouse code |
ANSWER 1) Here - Pressing the up arrow key to move text on a GUI, Dragging the mouse across the GUI, Clicking a button on a GUI are physically done by mouse and keyboard but the Compiling the code for a GUI is not physically done. Hence Compiling the code for a GUI is not a event.
ANSWER 2) The MouseEvent class defined in java.awt.event. MouseEvent class extends the InputEvent class -
public class MouseEvent extends InputEvent
The ActionEvent class defined in java.awt.event. ActionEvent class extends the AWTEvent class -
public class ActionEvent extends AWTEvent
The KeyEvent class defined in java.awt.event. KeyEvent class extends the InputEvent class -
public class KeyEvent extends InputEvent
The WindowEvent class defined in java.awt.event. WindowEvent class extends the ComponentEvent class -
public class WindowEvent extends ComponentEvent
ANSWER 3) The click - the click tells you where the mouse was clicked is not the part of event because an event can be pressing a key but in pressing a key there is no click of a button. So it is not the part of an event.
The source, target and type are the part of event.
ANSWER 4) run is the name of the method that you must override when create an EventHandler.
ANSWER 5) An anonymous class is a class that isn't named.
a class that nobody knows about is never defined.
a class which have method but not the implementation of method is an abstract class.
a class that is marked as private is not accessible from anywhere.
ANSWER 6) EventHandler is a class.
ANSWER 7) When the mouse is dragged across the screen, the inside of a circle will change to a different color as determined by a random number generator is best describes what is going on.
ANSWER 8) It puts little lambs in your code. Duh. is not the feature of the lambda expressions.
ANSWER 10) e -> is the name of the Event object that must be created and -> is the lambda operator.
Get Answers For Free
Most questions answered within 1 hours.