Subscribe Us

Core Java - Interview Questions and Answers

461. Can I create a non-resizable windows? If so, how?

Ans: Yes. By using setResizable() method in class Frame.

462. What is the default Layout Manager for the Window and Window subclasses (Frame,Dialog)?

Ans : BorderLayout().

463. How are the elements of different layouts organized?

Ans :
FlowLayout : The elements of a FlowLayout are organized in a top to bottom, left to right fashion.
BorderLayout : The elements of a BorderLayout are organized at the borders (North, South, East and West) and the center of a container.
CardLayout : The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.
GridLayout : The elements of a GridLayout are of equal size and are laid out using the square of a grid.
GridBagLayout : The elements of a GridBagLayout are organized according to a grid.However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.

464. Which containers use a BorderLayout as their default layout?

Ans : The Window, Frame and Dialog classes use a BorderLayout as their default layout.

465. What is the preferred size of a component?

Ans : The preferred size of a component size that will allow the component to display normally.

466. Which method is method to set the layout of a container?
a) startLayout( )
b) initLayout( )
c) layoutContainer( )
d) setLayout( )

Ans : d.

467. Which method returns the preferred size of a component?
a) getPreferredSize( )
b) getPreferred( )
c) getRequiredSize( )
d) getLayout( )

Ans : a.

468. Which layout should you use to organize the components of a container in a
tabular form?
a) CardLayout
b) BorederLayout
c) FlowLayout
d) GridLayout

Ans : d.

469. An application has a frame that uses a Border layout manager. Why is it probably not a good idea to put a vertical scroll bar at North in the frame?
a) The scroll bar’s height would be its preferred height, which is not likely to be enough.
b) The scroll bar’s width would be the entire width of the frame, which would be much wider than necessary.
c) Both a and b.
d) Neither a nor b. There is no problem with the layout as described.

Ans : c.

470. What is the default layouts for a applet, a frame and a panel?

Ans : For an applet and a panel, Flow layout is the default layout, whereas Border layout is default layout for a frame.

Post a Comment

0 Comments