Filters
Question type

Study Flashcards

As described in the Software Failure, the cause of the 2004 LA Air Traffic Control incident was


A) human error
B) the fact that the system had not been rebooted within 50 days
C) the fact that it takes just under 50 days for the countdown timer to count down four billion milliseconds and the subsystem shuts down when it reaches zero
D) there was no software patch to automatically reset the countdown timer without human intervention
E) all of the above

Correct Answer

verifed

verified

In order to determine the type that a polymorphic variable refers to, the decision is made


A) by the programmer at the time the program is written
B) by the compiler at compile time
C) by the operating system when the program is loaded into memory
D) by the Java run-time environment at run time
E) by the user at run time

Correct Answer

verifed

verified

For the questions below, assume that Student, Employee and Retired are all extended classes of Person, and all four classes have different implementations of the method getMoney. Consider the following code where ... are the required parameters for the constructors: Person p = new Person(...) ; int m1 = p.getMoney( ) ; // assignment 1 p = new Student(...) ; int m2 = p.getMoney( ) ; // assignment 2 if (m2 < 100000) p = new Employee(...) ; else if (m1 > 50000) p = new Retired(...) ; int m3 = p.getMoney( ) ; // assignment 3 -The reference to getMoney( ) in assignment 3 is to the class


A) Person
B) Student
C) Employee
D) Retired
E) none of the above, this cannot be determined by examining the code

Correct Answer

verifed

verified

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

verifed

verified

If a class extends Applet and also implements MouseListener and MouseMotionListener, what methods must be declared in this class?

Correct Answer

verifed

verified

MouseListener requires mousePressed, mou...

View Answer

Write the init and paint methods of an Applet and the methods needed to implement MouseMotionListener so that the applet can draw a point on the applet for every mouse position as the mouse is being moved on the screen. Use a 2-D array of ints to represent the X and Y coordinates of the mouse as it is being moved. For instance, point[0][0] and point[0][1] represent the X and Y coordinates of the mouse at its first position. The paint method will need to be called every time the mouse is moved and all points redrawn on the applet.

Correct Answer

verifed

verified

public class MouseFollower extends Apple...

View Answer

Consider a class Name, which has four instance data (all Strings): first, middle, last and title. Even though Name inherits the equal method from Object, it would make more sense to override it. Why?

Correct Answer

verifed

verified

Object's version of equal compares two o...

View Answer

If you instantiate an Abstract class, the class or object you wind up with


A) is also an Abstract class
B) is a normal class
C) is an Interface
D) is a reference to an Object
E) can't existyou cannot instantiate an Abstract class

Correct Answer

verifed

verified

What is the advantage of extending an adapter class rather than implementing a listener interface?

Correct Answer

verifed

verified

If you extend an adapter class you no lo...

View Answer

Why is it a contradiction for an abstract method to be modified as final or static?

Correct Answer

verifed

verified

A final method cannot be overridden in d...

View Answer

Java does not support multiple inheritance, but some of the abilities of multiple inheritance are available by


A) importing classes
B) implementing interfaces
C) overriding parent class methods
D) creating aliases
E) using public rather than protected or private modifiers

Correct Answer

verifed

verified

If classes C1 and C2 both implement an interface Cint, which has a method whichIsIt, and if C1 c = new C1( ); is performed at one point of the program, then a later instruction c.whichIsIt( ); will invoke the whichIsIt method defined in C1.

Correct Answer

verifed

verified

For the questions below, use the following partial class definitions: public class A1 { public int x; private int y; protected int z; ... } public class A2 extends A1 { protected int a; private int b; ... } public class A3 extends A2 { private int q; ... } -Which of the following lists of instance data are accessible in A3?


A) x, y, z, a, b, q
B) a, b, q
C) a, q
D) x, z, a, q
E) x, a, q

Correct Answer

verifed

verified

For the next questions, consider the following class definition: public class Q { private int x; public Q(int newValue) { x = newValue; } } -If q1 and q2 are objects of Q26_27, then q1.equals(q2)


A) is a syntax error since equals is not defined in the Q26_27 class
B) is True if q1 and q2 both store the same value of x
C) is True if q1 and q2 reference the same Q26_27 object
D) is never True
E) throws a NullPointerException

Correct Answer

verifed

verified

Although classes can be inherited from one-another, even Abstract classes, interfaces cannot be inherited.

Correct Answer

verifed

verified

Assume the class Student implements the Speaker interface from the textbook. Recall that this interface includes two abstract methods, speak( ) and announce(String str). A Student contains one instance data, String classRank. Write the Student class so that it implements Speaker as follows. The speak method will output "I am a newbie here" if the Student is a "Freshman", "I hate school" if the Student is either a "Sophomore" or a "Junior", or "I can not wait to graduate" if the student is a "Senior". The announce method will output "I am a Student, here is what I have to say" followed by the String parameter on a separate line. Finally, the classRank is initialized in the constructor. Only implement the constructor and the methods to implement the Speaker interface.

Correct Answer

verifed

verified

public class Student implements Speaker
...

View Answer

Consider the following class hierarchy and answer these questions. Consider the following class hierarchy and answer these questions.    -Y is a derived class of Z. -Y is a derived class of Z.

Correct Answer

verifed

verified

For the questions below, consider the following class definition: public class AClass { protected int x; protected int y; public AClass(int a, int b) { x = a; y = b; } public int addEm( ) { return x + y; } public void changeEm( ) { x++; y--; } public String toString( ) { return "" + x + " " + y; } } -Which of the following is True regarding Java classes?


A) All classes must have 1 parent but may have any number of children (derived or extended) classes
B) All classes must have 1 child (derived or extended) class but may have any number of parent classes
C) All classes must have 1 parent class and may have a single child (derived or extended) class
D) All classes can have any number (0 or more) of parent classes and any number of children (derived or extended) classes
E) All classes can have either 0 or 1 parent class and any number of children (derived or extended) classes

Correct Answer

verifed

verified

The instruction super( ) ; does which of the following?


A) calls the method super as defined in the current class
B) calls the method super as defined in the current class'parent class
C) calls the method super as defined in java.lang
D) calls the constructor as defined in the current class
E) calls the constructor as defined in the current class'parent class

Correct Answer

verifed

verified

An Applet implements MouseMotionListener and is 600x600 in size. Write a mouseMoved method so that if the mouse is moved into the upper left hand quadrant of the Applet, the entire applet turns blue, if the mouse is moved into the upper right hand quadrant of the Applet, the entire applet turns yellow, if the mouse is moved into the lower left hand quadrant of the Applet, the entire applet turns green, and if the mouse is moved into the lower right hand quadrant of the Applet, the entire applet turns red.

Correct Answer

verifed

verified

public void mouseMoved(MouseEvent me)
{
...

View Answer

Showing 21 - 40 of 71

Related Exams

Show Answer