File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes enableEvents 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 "enableEvents" Watch "enableEvents" New topic
Author

enableEvents

josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
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) This code will not compile if a window listener is added to TestFrame. //f

b) The window listener that has been added to TestFrame will never get called. //t becoz there is no call to
super.processWindowEvent(WindowEvent)

c) An exception will be thrown if a window listener is added to TestFrame. //f

d) The window listener that has been added to TestFrame will be called on every window event //true

josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216
Am i Correct
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
This is a poorly-worded question - it's impossible to tell what they really meant. There is no WindowListener in the code given, but there is a method for handling WindowEvents, which is like a WindowListener. (A) and (C) talk about what would happen if a real WindowListener were added - fine. But (B) and (D) act as if the WindowListener is already there. Do they mean, like (A) and (C) seem to, what if a real WindowListener were added? Or are they talking about the processWindowEvent(), which is like a listener? The answer depends on figuring out what they mean, and when it's this badly written I really don't think it matters.
Note that your answers to B and D contradict each other. I don't konw which way you're interpreting the problem, but you probably shouldn't change your interpretation halfway through the problem.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: enableEvents
 
Similar Threads
About WindowListener
A few doubts
Events
IBM questions
Event Handling