• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marcus #38

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 38)
Which of the following statements are true?
1) Code must be written to cause a frame to close on selecting the system close menu
2) The default layout for a Frame is the BorderLayout Manager
3) The layout manager for a Frame cannot be changed once it has been assigned
4) The GridBagLayout manager makes extensive use of the the GridBagConstraints class.
ans)1,2,4
how 1 is correct also??
Thanks!
 
Bob Kerfoot
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AVN,
I believe that the question refers to the "Close Alt+F4" menu item in the Control Menu in the upper left corner of a frame as is displayed on a Windows NT system. Since this menu item serves the same purpose as the "X Close" button in the top right corner of the frame, a corresponing call to the windowClosing method will be issued to the frame's WindowListener if one is present. Further, the Java 2 API Specification states that "If the program does not explicitly hide or dispose the window while processing this event, the window close operation will be cancelled."
Therefore, I believe that answer 1 is correct because the window close operation will be cancelled automatically unless you explicitly use a setVisible, dispose, or System.exit method to either remove the frame from the display or exit the application.
Regards,
Bob Kerfoot SCJP - 92%
 
pete hesse
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also didn't choose 1), and although I agree it is a practical necessity to do so, it doesn't cause a compiler or runtime error if you don't.
I suggest the wording be changed in this question, because "must" implies a Java compiler or runtime error will result if not done, which is not the case.
Does Sun's exam word questions this way?
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pete hesse:
[B]I also didn't choose 1), and although I agree it is a practical necessity to do so, it doesn't cause a compiler or runtime error if you don't.
I suggest the wording be changed in this question, because "must" implies a Java compiler or runtime error will result if not done, which is not the case.
I'm not sure I can see the implication that an error will occur. It specifically says
"must be to cause a frame to close"
Anyone like to suggest a form of words that expresses the intent more clearly? do the words
"needs to be written if you want"
or should it be "must be written if you want to cause"
Anyone got a more compact version of that meaning?
Make it clearer?
Marcus

 
pete hesse
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest: "Code must be written if you want to cause a frame to close on selecting the system close menu." I took the original wording to mean that if you have a frame, you must code a closing process, regardless.
Your tests are very challenging and useful.
Thanks.
 
Bob Kerfoot
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks,
I think it makes sense as written.
Bob Kerfoot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic