Multiple Choice
Consider an applet that implements MouseListener. Assume that the applet has five instance data, int x1, x2, y1, y2, and boolean inside. The four int values represent the two end-points of a box (x1, y1 is the upper left hand point and x2, y2 is the lower right hand point) . Which of the following properly defines code that will determine whenever the mouse button is clicked if the mouse is currently inside this box or not. If the mouse is inside the box, inside is set to True, otherwise it is set to false.
A) public void mouseMoved(MouseEvent me) {
If (me.getX( ) >= x1 && me.getX( ) <= x2 && me.getY( ) >= y1 && me.getY( ) <= y2)
Inside = True;
Else
Inside = false;
}
B) public void mousePressed(MouseEvent me) {
If (me.getX( ) >= x1 && me.getX( ) <= x2 && me.getY( ) >= y1 && me.getY( ) <= y2)
Inside = True;
Else
Inside = false;
}
C) public void mouseReleased(MouseEvent me) {
If (me.getX( ) >= x1 && me.getX( ) <= x2 && me.getY( ) >= y1 && me.getY( ) <= y2)
Inside = True;
Else
Inside = false;
}
D) public void mouseEntered(MouseEvent me) {
If (me.getX( ) >= x1 && me.getX( ) <= x2 && me.getY( ) >= y1 && me.getY( ) <= y2)
Inside = True;
Else
Inside = false;
}
E) Requires both of the following methods: public void mouseEntered(MouseEvent me)
{
Inside = True;
}
Public void mouseExited(MouseEvent me)
{
Inside = false;
}
Correct Answer:

Verified
Correct Answer:
Verified
Q1: Abstract methods are used when defining<br>A) interface
Q6: Java does not support multiple inheritance but
Q32: If a class extends Applet and also
Q33: The instruction super( ); does which of
Q34: Assume the class Student implements the Speaker
Q35: Consider a class Name, which has four
Q36: What is the advantage of extending an
Q39: An Applet implements MouseMotionListener and is 600x600
Q40: If you instantiate an Abstract class, the
Q41: For the questions below, assume that Student,