aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Mock exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Mock exam" Watch "Mock exam" New topic
Author

Mock exam

Hans Li
Greenhorn

Joined: Oct 13, 2000
Posts: 10
1)Which of the following statements are true?
1) The x,y coordinates of an instance of MouseEvent can be obtained using the getX() and getY() methods
2) The x,y coordinates of an instance of MouseEvent can be obtained using the X and Y integer fields
3) The time of a MouseEvent can be extracted using the getTime() method
4) The time of a MouseEvent can be extracted using the when parameter of the MouseEvent constructor
Answer is 1,4.I think 1,3.Why 4 is ok.But 3 is wrong.
2)Which statements are true about GridBagLayout ?
A) Weight x and weight y should be 0.0 and 1.0
B) If fill is both, anchor does not make sense.
C) It divides its territory in to an array of cells.
D) While constructing GridBagLayout , you won't tell how many rows and columns the underlying grid has.
Answer is a,b,d. I think only d is ok.Who can expalin why a,b are ok?
satishind Reddy
Ranch Hand

Joined: Oct 17, 2000
Posts: 33
Hi Hans,
weightx, weighty default value is : 0.0
weightx and weighty determine how space gets distributed to
each component in GridBag.
A value of 1.0 says that the component wants to have more space than his neighbors of lower weights.
Based on this(weightx,weighty) value it ocupies space in Gridbag while placing components, and resizing layout based on weightx/weighty value component expand in GridBag.
anchor default value is: CENTER
If the component does not take up all of the space given to it, you can specify where it will end up. If you have 'fill' set to BOTH, then anchor has no effect.
Anchor is most useful when you want to pair off a label with a TextField,etc...
fill BOTH means it occupies component dispalyarea harizantoly and vertically...
if you are not clear go 'www.javaranch.com/maha' in this site discussions select 'java.awt.*' you can find very good qestions on GridBag and maha explained also nicely.
if you can send a mail to my mail id 'satishind@123india.com' i can some code regarding GridBagLayout' which will explain all constraints and you can visualy feel what is hapening when constrants change. offcourse i got this code from internet but i don't know exact site address.
Hope this clears your doubt.
regards
Satish
Harpal Singh
Ranch Hand

Joined: Oct 10, 2000
Posts: 229
Originally posted by Hans Li:
1)Which of the following statements are true?
1) The x,y coordinates of an instance of MouseEvent can be obtained using the getX() and getY() methods
2) The x,y coordinates of an instance of MouseEvent can be obtained using the X and Y integer fields
3) The time of a MouseEvent can be extracted using the getTime() method
4) The time of a MouseEvent can be extracted using the when parameter of the MouseEvent constructor
Answer is 1,4.I think 1,3.Why 4 is ok.But 3 is wrong.

Hans,
I can clear your first doubt....The method to get the time is getWhen() and not getTime().
Hence,3 is wrong and 4 is right....
Hope that helps,
Harpal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock exam