Saturday, 31 January 2015

Java Swing Part9 Interview Questions and Answers

81. What advantage do Java's layout managers provide over traditional windowing systems?
Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accommodate platform-specific differences among windowing systems.

82. When should the method invokeLater() be used?
This method is used to ensure that Swing components are updated through the event-dispatching thread.

83. What is the diff b/w choice and the List ?
Many diff are there :
> A Choice is displayed in a compact from that requires we to pull ot down to see the list of available choice, Oly one item may be selected from a Choice.
> A List may be dsplyaed in such a way that several List items are visible. A List supports the selection of the one or more List items .

84. Which component subclass is used for the drawing and painting ?

85. Which containers may have a menu bar?

86. Which class is the immediate supar class of the menuComponent class?

87. What is the relationship b/w the Canvas class and the Graphics Class?
A Canvas object provides access to a graphics object via its paint() method.

88. How are the elements of a borderLayout organized?
The Elements of a BorderLayout are organized at the borders(North, South, East and West) and the center of a container.

89. How are the elements of a GridBagLayout organized?
The Elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than row or column of the grid. In addition, the rows and columns may have diff sizes.

90. Difference b/w paint() and paintComponent()?
The Key point is that the paint() method invokes three methods in the following order :
> PaintComponent()
> paintBorder()
> paintChildren()
As a general rule, in Swing, we should be overriding the paintComponent method unless we know what we are doing paintComponent() paints only component (panel) but paint() paints component and all its children.

91. Give us the Name of the List LayoutManagers in Java?
List is here :
> Flow Layout Manager
> Grid Layout Manager
> Box Layout Manager
> Border Layout Manager
> Card Layout Manager
> GridBag Layout Manager.
More Questions & Answers :-
Part1  Part2  Part3  Part4  Part5  Part6  Part7  Part8  Part9

No comments:

Post a Comment