TextComponents and Layouts Self Test  With Answers




1)  Which of the following is able to display RTF files?

a) JPasswordField
b) JTextField
c) JTextArea
d) JEditorPane                                                            ( d )

2) What is the name in Java, of the component that is used to represent sub-sections
     of a document?

a) Blocks
b) Paragraphs
c) Elements                                         
d) Lines                                                                         ( c )     


3) Which of the following layout managers is effectively replaced by JTabbedPane

a) BoxLayout
b) FlowLayout
c) GridLayout
d) CardLayout                                                              ( d )


4) True or False. Absolute x-y coordinate based layouts are possible using the
      NullLayout manager.                                    ( False )

// The layout is set to null as in setLayout( null )


5) Which of the following statements regarding BorderLayout is least correct?

a) Any region that is left out will be filled by the CENTER region if the CENTER
    region is added.
b) Using the getContentPane( ).add( ) with a component and not specifying a region
    will by default add to the center.
c) If a second components is added to a region where another component is already
    resident, the second component added is ignored.
d) BorderLayout has the constants, NORTH, SOUTH and CENTER.      ( c )

// The last component added will be visible


6) Which of the following layouts is a swing layout rather than an awt layout?

a) GridBagLayout
b) CardLayout
c) BoxLayout
d) CardLayout


7) Which of the following statements is not correct?

a) GridLayout will adjust the number of columns depending on the number of
    components added to the grid.
b) GridLayout allows components to retain their preferred size and shape.
c) GridLayout is used to create rows and columns in uniform grid
d) GridLayout is one of the awt layout managers.                                            ( b )

// Grid makes components fill the rectangle defined by the grid


8) Regarding BoxLayout which statement is not correct?

a) Box Layout allows the creation of a set of components along a horizontal
    or vertical access.
b) BoxLayout allows the creation of rigid areas.
c) BoxLayout allows the creation of flexible area.
d) BoxLayout allows the creation of rows and columns.                               ( d )