Components I Self Test With Answers


1) Which of following features was not only a swing feature but also available in AWT.

a) add icons
b) set tooltips
c) change layout managers
d) layer pop-up menus            ( c )

2) Like Icon, the Border interface has three methods. Which of the following is not a
    Border interface method.

a) getBorderInsets( )
b) isBorderOpaque( )
c) setBorderInsets( )
d) paintBorder ( )                   ( c )


3) Pick the incorrect statement?

a ) Borders can be customized by extending AbtractBorder
b) JComponent provides the setBorder method
c) Swing defines six preset border classes.
d) JComponent implements the Border interface              ( c )          

// 8 border classes provide presets while one offers customization


4 ) Select the incorrect statement regarding JLabel.
a) An icon can be set in a JLabel using setIcon( ).
b) The background of a label by default is transparent
c) Set methods can be used to position text relative to icon in 6 different ways.
d) horizontal and vertical alignment methods can set the relative position of the
    text and icon as a group.               ( c )

// Comment: There are 9 different ways text can be set relative to icons
 

5) Which of the following statements is not true regarding JPanel?
a) JPanel's default layout manager is flow layout.
b) Like JFrame,  JPanel can be made visible to screen without
    being added to another container.
c) JPanel descends directly from  JComponent.
d) JPanel supports double buffering?                                          ( b )

// Comment: JPanel's default layout is flow layout.

6 )  Only one of the following components is considered heavyweight? Which is it?

a) JPanel
b) JComponent
c) JDialog
d) JLabel                                                                                     ( c )

7) True or False.

If AWT and Swing Components are mixed  in the same GUI a compiler error results. 
_____ (False )

// they just may not paint properly

8) True or False

Peer-based means a corresponding component is built on the underlying system
     ____( True)