Are there any questions based on Painting in the real
SCJP exam? (on drawString, drawXXX)
Is there a possibility that I could get a question like this in the exam? Has anybody got
a similar question in the exam?
Q48 Marcus Green Mock 1 You have created a simple Frame and overridden the paint method as follows
What will be the result when you attempt to compile and run the program?
1) The
string "Dolly" will be displayed at the centre of the frame
2) An error at compilation complaining at the signature of the paint method
3) The lower part of the
word Dolly will be seen at the top of the frame, with the top hidden.
4) The string "Dolly" will be shown at the bottom of the frame.
Answer and Explanation - 3) The lower part of the word Dolly will be seen at the top of the form
The Second parameter to the drawstring method indicates where the baseline of the string will be placed. Thus the 3rd parameter of 10 indicates the Y coordinate to be 10 pixels from the top of the Frame. This will result in just the bottom of the string Dolly showing up or possibly only the descending part of the letter y.
TIA,
- Manish