MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

COMPUTER GRAPHICS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of the following is true about the ‘paint’ method?
A
can be called directly from your Java program
B
automatically called in response to certain messages
C
not the central drawing method for the application window
D
none of these options are true
Explanation: 

Detailed explanation-1: -The paint method is called every time the system tells it that it’s state has changed and it needs to repaint. This is done by you in code by calling the method repaint() .

Detailed explanation-2: -paint(): This method holds instructions to paint this component. In Java Swing, we can change the paintComponent() method instead of paint() method as paint calls paintBorder(), paintComponent() and paintChildren() methods. We cannot call this method directly instead we can call repaint().

Detailed explanation-3: -The method paint() gives us access to an object of type Graphics class. Using the object of the Graphics class, we can call the drawString() method of the Graphics class to write a text message in the applet window.

Detailed explanation-4: -Answer: The repaint() method of a component is called to notify the system that the component needs to be redrawn. It does not itself do any drawing (neither directly nor by calling the paintComponent() routine).

There is 1 question to complete.