• 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

AWT question from Khalid

 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the last one from me today from Khalid:
10. Which statements concerning the effect of the statement gfx.drawRect(5, 5, 10, 10) are true, given that gfx is a reference to a valid Graphics object?
Select all valid answers:
A. The rectangle drawn will have a total width of 5 pixels
B. The rectangle drawn will have a total height of 6 pixels
C. The rectangle drawn will have a total width of 10 pixels
D. The rectangle drawn will have a total height of 11 pixels

Bill
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the answer C
rajani
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am about to take off for the day, so I am going to give the answer. I don't think you will get this detailed of an AWT question from the exam, but here it is anyways.
Taken from Graphic Java Mastering the JFC Volume 1:AWT by David Geary


Drawing a rectangle by invoking Graphics.drawRect() results in an extra row of pixels on the right and bottom sides of the rectangle.


So, the drawRect() method adds an extra row of pixels, but the fillRect() method does not. You can see this by doing the drawRect(5,5,10,10) method and then do the fillRect(5,5,10,10) method, but change the color first. You will see that drawRect() acts like a border to the fillRect().
So the answer is D.
Have a good one and I will throw some more out tomorrow.
Bill
reply
    Bookmark Topic Watch Topic
  • New Topic