• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

java.awt.Graphics class method to draw the rectangle

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following methods from the java.awt.Graphics class would be used to draw the outline of a rectangle with a single method call?
a) fillRect()
b) drawRect()
c) fillPolygon()
d) drawPolygon()
e) drawLine()
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API provide the answer to that kind of question, but b is the correct answer.
Please use the API as much as you can...
 
sun ram
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I selected the b option, But mock exam says Its wrong. Why???
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API


public void drawRect(int x, int y, int width, int height)
Draws the outline of the specified rectangle.


There must something wrong with your mock test I guess... b is the correct answer.
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is b) and d)
drawPoligon will also draw rectangle if you'll give an array of ccordanates of rectangle as an argument.
I answered this question I got right.
Jamal
 
sun ram
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jamal. I guessed so
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does drawPolygon() still count as a single call though? You have to do a lot of prep-work first, by creating an array, and populating with data, THEN calling drawPolygon() and passing the data. With drawRect() you don't need any other prepatory work, you can make a single call with the data you need in that call.
Or am I splitting hairs here? (being too picky??)
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic