FAQ
  Java Tutorial
  Questions by Topic
  Sample test
  Other Certification sites
  Certification Tips
  Exam Objectives
  Java jobs
  Java News
  About Java Prepare
   Books
  Certification Books
  SCEA Books
  Online Books
   Tutorial Topics
  Language Fundamentals
  Operator and Assignments
  Declaration and Access Control
  Classes in Java
  AWT
  Event classes
  Threads
  Layout Managers
  Collections
  Files
   Advertisements

In Association with Amazon.com


   Feedback
  Please let us know your feedback
 
PowWeb Hosting - only $7.77/ month
javaprepare.com
your tool for Java Certification
home | tutorial | questions | test 1

Questions on Layout Managers

  1. In Java, which of these classes implement the LayoutManager interface. Select all correct answers.
    1. RowLayout
    2. ColumnLayout
    3. GridBagLayout
    4. FlowLayoutManager
    5. BorderLayoutManager
  2. Which of the following layout manager is the default Layout Manager for the Applet class in Java. Select the one correct answer.
    1. FlowLayout
    2. BorderLayout
    3. GridLayout
    4. CardLayout
    5. GridBagLayout
  3. Which of the following layout manager is the default Layout Manager for the Frame class in Java. Select the one correct answer.
    1. FlowLayout
    2. BorderLayout
    3. GridLayout
    4. CardLayout
    5. GridBagLayout
  4. Which of the following layout manager is the default Layout Manager for the Dialog class in Java. Select the one correct answer.
    1. FlowLayout
    2. BorderLayout
    3. GridLayout
    4. CardLayout
    5. GridBagLayout
  5. Which Layout Manager follows the following placement policy - "Lays out the components in row-major order in rows growing from left to right, and rows from top to bottom in the container." Select the one correct answer.
    1. FlowLayout
    2. BorderLayout
    3. CardLayout
    4. GridBagLayout
  6. How will the following program lay out its buttons. Select the one correct answer.
    
    import java.awt.*;
    public class MyClass {
       public static void main(String args[]) {
          String[] labels = {"A","B","C","D","E","F"};
          Window win =   new Frame();
          win.setLayout(new GridLayout(1,0,2,3));
          for(int i=0;i < labels.length;i++)
             win.add(new Button(labels[i]));
          win.pack();	
          win.setVisible(true);
       }
    }
    
    
    1. The program will not display any buttons.
    2. The program will display all buttons in a single row.
    3. The program will display all buttons in a single column.
    4. The program will display three rows - A B, C D, and E F.
    5. The program will display two rows - A B C, and D E F.
    6. The rows and columns displayed are compiler and platform dependent.
  7. How will the following program lay out its buttons. Select the one correct answer.
    
    import java.awt.*;
    public class MyClass {
       public static void main(String args[]) {
          String[] labels = {"A"};
          Window win =   new Frame();
          win.setLayout(new FlowLayout());
          for(int i=0;i < labels.length;i++)
             win.add(new Button(labels[i]));
          win.pack();
          win.setVisible(true);
       }
    }
    
    
    1. The button A will appear on the top left corner of the window.
    2. The button A will appear on the center of first row.
    3. The button A will appear on the top right corner of the window.
    4. The button A will appear on the middle row and column, in the center of the window.
  8. Select the one correct answer. The default alignment of buttons in Flow Layout is ...
    1. LEFT
    2. CENTER
    3. RIGHT
    4. The alignment must be defined when using the FlowLayout Manager.
  9. The default horizontal and vertical gap in FlowLayout is -
    1. 0 pixel
    2. 1 pixel
    3. 5 pixels
    4. 10 pixels
    5. The alignment must be defined when using the FlowLayout Manager.
  10. The default horizontal and vertical gap in BorderLayout is -
    1. 0 pixel
    2. 1 pixel
    3. 5 pixels
    4. 10 pixels
    5. The horizontal and vertical gaps must be defined when using the BorderLayout Manager.
  11. How will the following program lay out its buttons. Select the one correct answer.
    
    import java.awt.*;
    public class MyClass {
        public static void main(String args[]) {
            String[] labels = {"A"};
    	Window win = new(Frame());
    	win.set.layout(new BorderLayout());
    	for(i=0;i<labels.length;i++)
    	    win.add(new Button(labels[i]), "North");
    	win.pack();
    	win.setVisible(true);
        }
    }
    
    
    1. The button A will appear on the top left corner of the window.
    2. The button A will appear on the center of first row.
    3. The button A will appear on the top right corner of the window.
    4. The button A will appear on the middle row and column, in the center of the window.
    5. The button A will occupy the whole window.
    6. The button A will occupy the complete first row of the window.
  12. If the following method is used to add an object to a window using BorderLayout, what would be the placement constraint. Select one correct answer.
    Component add(Component comp);
    1. NORTH
    2. SOUTH
    3. EAST
    4. WEST
    5. CENTER
  13. What is the default filling of GridBagConstraint.
    1. NONE
    2. BOTH
    3. HORIZONTAL
    4. VERTICAL
  14. Which GridBagLayout variable defines the external padding (border) around the component in its display area. Select the one correct answer.
    1. gridwidth, gridheight
    2. gridx, gridy
    3. anchor
    4. fill
    5. ipadx, ipady
    6. insets
  15. Which GridBagLayout variable defines the padding that gets added to each side of the component. Select the one correct answer.
    1. gridwidth, gridheight
    2. gridx, gridy
    3. anchor
    4. fill
    5. ipadx, ipady
    6. insets
  16. Which GridBagLayout variable specifies the number of cells occupied by the component horizontally and vertically in the grid. Select the one correct answer.
    1. gridwidth, gridheight
    2. gridx, gridy
    3. anchor
    4. fill
    5. ipadx, ipady
  17. Which GridBagLayout variable specifies where (in which direction) a component should be placed in its display area. Select the one correct answer.
    1. gridwidth, gridheight
    2. gridx, gridy
    3. anchor
    4. fill
    5. ipadx, ipady
    6. insets
  18. What is the default value of GridBagLayout constraint anchor. Select the one correct answer.
    1. CENTER
    2. NORTH
    3. EAST
    4. SOUTH
    5. WEST
Answers to questions on Layout Managers
  1. c
  2. a
  3. b
  4. b
  5. a
  6. b
  7. b
  8. b
  9. c
  10. a
  11. f
  12. e
  13. a
  14. f
  15. e
  16. a
  17. c
  18. a

Advertisement
Discount Coupons For Online Stores
home | tutorial | questions | test 1