Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

enableEvents

 
josephine chen
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am i Correct
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic