|
|
|
javaprepare.com
your tool for Java Certification
|
home | tutorial | questions | test 1
Questions on Layout Managers
- In Java, which of these classes implement the LayoutManager
interface. Select all correct answers.
- RowLayout
- ColumnLayout
- GridBagLayout
- FlowLayoutManager
- BorderLayoutManager
- Which of the following layout manager is the default Layout Manager
for the Applet class in Java. Select the one correct answer.
- FlowLayout
- BorderLayout
- GridLayout
- CardLayout
- GridBagLayout
- Which of the following layout manager is the default Layout Manager
for the Frame class in Java. Select the one correct answer.
- FlowLayout
- BorderLayout
- GridLayout
- CardLayout
- GridBagLayout
- Which of the following layout manager is the default Layout Manager
for the Dialog class in Java. Select the one correct answer.
- FlowLayout
- BorderLayout
- GridLayout
- CardLayout
- GridBagLayout
- 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.
- FlowLayout
- BorderLayout
- CardLayout
- GridBagLayout
- 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);
}
}
- The program will not display any buttons.
- The program will display all buttons in a single row.
- The program will display all buttons in a single column.
- The program will display three rows - A B, C D, and E F.
- The program will display two rows - A B C, and D E F.
- The rows and columns displayed are compiler and platform
dependent.
- 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);
}
}
- The button A will appear on the top left corner of the window.
- The button A will appear on the center of first row.
- The button A will appear on the top right corner of the window.
- The button A will appear on the middle row and column, in the
center of the window.
- Select the one correct answer. The default alignment of buttons in
Flow Layout is ...
- LEFT
- CENTER
- RIGHT
- The alignment must be defined when using the FlowLayout Manager.
- The default horizontal and vertical gap in FlowLayout is -
- 0 pixel
- 1 pixel
- 5 pixels
- 10 pixels
- The alignment must be defined when using the FlowLayout Manager.
- The default horizontal and vertical gap in BorderLayout is -
- 0 pixel
- 1 pixel
- 5 pixels
- 10 pixels
- The horizontal and vertical gaps must be defined when using the
BorderLayout Manager.
- 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);
}
}
- The button A will appear on the top left corner of the window.
- The button A will appear on the center of first row.
- The button A will appear on the top right corner of the window.
- The button A will appear on the middle row and column, in the
center of the window.
- The button A will occupy the whole window.
- The button A will occupy the complete first row of the window.
- 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);
- NORTH
- SOUTH
- EAST
- WEST
- CENTER
- What is the default filling of GridBagConstraint.
- NONE
- BOTH
- HORIZONTAL
- VERTICAL
- Which GridBagLayout variable defines the external padding (border)
around the component in its display area. Select the one correct answer.
- gridwidth, gridheight
- gridx, gridy
- anchor
- fill
- ipadx, ipady
- insets
- Which GridBagLayout variable defines the padding that gets added to
each side of the component. Select the one correct answer.
- gridwidth, gridheight
- gridx, gridy
- anchor
- fill
- ipadx, ipady
- insets
- Which GridBagLayout variable specifies the number of cells occupied
by the component horizontally and vertically in the grid. Select the one
correct answer.
- gridwidth, gridheight
- gridx, gridy
- anchor
- fill
- ipadx, ipady
- Which GridBagLayout variable specifies where (in which direction) a
component should be placed in its display area. Select the one correct
answer.
- gridwidth, gridheight
- gridx, gridy
- anchor
- fill
- ipadx, ipady
- insets
- What is the default value of GridBagLayout constraint anchor. Select
the one correct answer.
- CENTER
- NORTH
- EAST
- SOUTH
- WEST
Answers to questions on Layout
Managers
- c
- a
- b
- b
- a
- b
- b
- b
- c
- a
- f
- e
- a
- f
- e
- a
- c
- a
Advertisement
home | tutorial | questions | test 1
|