• 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

Mock exam

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic