Subscribe Us

Core Java - Interview Questions and Answers

411. What is the difference between the paint( ) and repaint( ) method?

Ans : The paint( ) method supports painting via a Graphics object. The repaint( ) method is used
to cause paint( ) to be invoked by the AWT painting method.

412. What is the difference between the Font and FontMetrics classes?

Ans : The FontMetrics class is used to define implementation-specific properties, such as ascent
and descent, of a Font object.

413. Which of the following are passed as an argument to the paint( ) method?
a) A Canvas object
b) A Graphics object
c) An Image object
d) A paint object

Ans : b.

414. Which of the following methods are invoked by the AWT to support paint and repaint operations?
a) paint( )
b) repaint( )
c) draw( )
d) redraw( )

Ans : a.

415. Which of the following classes have a paint( ) method?
a) Canvas
b) Image
c) Frame
d) Graphics

Ans : a and c.

416. Which of the following are methods of the Graphics class?
a) drawRect( )
b) drawImage( )
c) drawPoint( )
d) drawString( )

Ans : a, b and d.

417. Which Font attributes are available through the FontMetrics class?
a) ascent
b) leading
c) case
d) height

Ans : a, b and d.

418. Which of the following are true?
a) The AWT automatically causes a window to be repainted when a portion of a window has been minimized and then maximized.
b) The AWT automatically causes a window to be repainted when a portion of a window has been covered and then uncovered.
c) The AWT automatically causes a window to be repainted when application data is changed.
d) The AWT does not support repainting operations.

Ans : a and b.

419. Which method is used to size a graphics object to fit the current size of the window?

Ans : getSize( ) method.

420. What are the methods to be used to set foreground and background colors?

Ans : setForeground( ) and setBackground( ) methods.

Post a Comment

0 Comments