• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bill's Mock Exam(Java2 Exam Prep CD)

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following statements about information you get from MouseEvent events that come to these listeners are correct?
1.The getX() and getY() methods return the position of the event relative to the Panel.
2.The getX() and getY() methods return the position of the event relative to the Frame.
Correct Ans:1
b'coz positions are relative to the component that generates the event.
My Doubt:
Why can't the same logic be applied to the 2. option that is Frame.Afterall even Frame is a component.According to me both the answers are correct.
Please clarify.
Regards,
Kavita.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kavita,
I think the answer relates to what source the MouseEvent is coming from. If we have set the Panel to be the MouseEvent listener then 1 would be correct. If we set the Frame to be the MouseEvent listener then 2 would be correct.
The layout here is also important. If we place a Panel into a Frame, the panel will end up in the BorderLayout.CENTER position of the frame which will in effect take up the entire Frame. Therefore, the frame as a mouse listener will never get any events because the Panel is in front of it! This is probably the logic being used by the tester.
Regards,
Manfred.
 
Kavita Ghia
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Manfread,
YES.U are right here the layout and on what component the event takes place is important.But how can we make assumptions?How can u assume that Panel is the source of event and not Frame.And again if such questions appear in the exam then what will be the correct answer.
Thanks for your prompt reply.
Regards,
Kavita.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kavita,
The exam questions won't be ambiguous and you won't need to assume anything! Don't equate mock exams with the real thing. Most mock exams are just created in spare time. The real exam has been created and developed making sure that all questions are straight forward and correctly worded to avoid any problems.
If you continue down this path you will work yourself into a failing grade without even taking the exam!
If you understand the concepts thoroughly then you will have no problems with the real exam.
Regards,
Manfred.
 
Kavita Ghia
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the clarifcation.
 
reply
    Bookmark Topic Watch Topic
  • New Topic