These are quesions from IBM mock exam.
1)Based upon the code below, which of the answers apply?
public class TestFrame extends Frame {
public TestFrame(
String title) {
super(title);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
public void
processWindowEvent(WindowEvent we) {
System.out.println("Window event processed");
}
}
a) The window listener that has been added to TestFrame will be called on every window event.
b) This code will compile and run if a window listener is added to an instance of TestFrame.
c) An exception will be thrown if a window listener is added to TestFrame.
d) The window listener that has been added to TestFrame will never get called.
e) This code will not compile if a window listener is added to TestFrame.
Multiple Select - Please select all of the correct answers (this question has 2 correct choices).
2.The way to accumulate drawn objects on the screen is to: (choose only one)
a) Call update() from within repaint()
b) Call paint() from within update()
c) Call update() from within paint()
d) Call paint() directly
e) Call accumulate() from within paint()
My choice is c.
3.Methods for a Component are:
a) add()
b) setbounds()
c) setVisible()
d) setEnabled()
e) addComponent()
Multiple Select - Please select all of the correct answers (this question has 4 correct choices).
My choices are a,c,d and e.
4.To prevent code which follows a try block from being executed when an exception is caught, you can:
a) Code a return statement in the finally clause.
b) Code an end clause.
c) Call System.exit() in the catch clause.
d) Code a return statement in the catch clause
Multiple Select - Please select all of the correct answers (this question has 3 correct choices).