wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes About WindowListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "About WindowListener" Watch "About WindowListener" New topic
Author

About WindowListener

Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
This is another Mock Question
26)
Based upon the code below, which of the answers apply?

1. public class TestFrame extends Frame {
2. public TestFrame(String title) {
3. super(title);
4. enableEvents(AWTEvent.WINDOW_EVENT_MASK);
5. }
6.
7. public void
processWindowEvent(WindowEvent we) {
8. System.out.println("Window event processed");
9. }
10. }
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.
According to me correct answer is b I need your expert comments

SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
sankar
Greenhorn

Joined: Oct 02, 2000
Posts: 17
Mr.gaurav
you need to call super.processWindowListener() so that the listeners will be notified.
Any doubts refer to RHE it is clear in that.
sankar
Herbert Maosa
Ranch Hand

Joined: May 03, 2000
Posts: 289
Hie,
D is also correct.Any listeners added to this window will never be notified because we have overriden the event delegation method and have not taken care of notifying our listeners.As stated above, a call to super() inside the processWindowEvent() would take care of this.

Herbert.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About WindowListener