TOP Swing Interview Questions and Answers

Read Latest Swing Interview Questions and Answers for Freshers, 2+ Years Experienced Q and A with Explanation PDF.

What are the features of JFC?

Mainly features are there :
> Pluggable Look-and-Feel,
> Accessibility API,
> Java 2D API,
> Drag and
> Drop Support.

What does x mean in javax.swing?

x mean in javax.swing is that :
> Extension of java.

What are invisible components?

Invisible components are basically light weight components, Which is perform no painting, but can take space in the GUI. This is mainly used for layout management.

What is the default layout for a ContentPane in JFC?

The Defaulf Layout for the ConteutPane in JFC is that :
> BorderLayout.

What does Realized mean?

Realized mean basically is  component, Which has been painted on screen or that is ready to be painted. Realization can take place by invoking any of these methods. Which are following as :
> SetVisible(true),
> Show() or
> Pack().

What is difference between Swing and JSF?

Many diff are there which is following here :
> The key difference is that JSF runs on server, It needs a server like Tomcat or WebLogic or WebSphere. It displays HTML to the client.  But Swing program is a stand alone application.

Why does JComponent class have add() and remove() methods but Component class does not?

JComponent is a subclass of Container and can contain other components and JComponents.

What method is used to specify a container’s layout?

The SetLayout() method is basically used to specify a container’s layout.

What is the difference between AWT and SWT?

SWT : SWT is stands for Standard Widget Toolkit, It is a completely independent Graphical User Interface (GUI) toolkit from IBM. They created it for the creation of Eclipse Integrated Development Environment (IDE). AWT is from Sun Microsystems.

What is the difference between JFC & WFC?

JFC supports robust and portable user interfaces. The Swing classes are robust, compatible with AWT, and provide you with a great deal of control over a user interface. Since source code is available, it is relatively easy to extend the JFC to do exactly what you need it to do. But the number of third-party controls written for Swing is still relatively small.
WFC runs only on the Windows (32-bit) user interface, and uses Microsoft extensions to Java for event handling and ActiveX integration. Because ActiveX components are available to WFC programs, there are theoretically more controls available for WFC than for JFC. In practice, however, most ActiveX vendors do not actively support WFC, so the number of controls available for WFC is probably smaller than for JFC. The WFC programming model is closely aligned with the Windows platform.

What is a convertor?

Converter is basically an application that converts distance measurements between metric and U.S units.

What is the difference between a Canvas and a Scroll Pane?

Many diff are there :
> Canvas is a component. ScrollPane is a container. > Canvas is a rectangular area where the application can draw or trap input events. ScrollPane implements horizontal and vertical scrolling.

What is the purpose of the enableEvents() method?

The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.

What is the difference between a MenuItem and a CheckboxMenuItem?

The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.

Which is the super class of all event classes?

The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy.

How the Canvas class and the Graphics class are related?

A Canvas object provides access to a Graphics object via its paint() method.

What is the difference between a Window and a Frame?

The Frame class extends Window to define a main application window that can have a menu bar. A window can be modal.

What is the relationship between clipping and repainting?

When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.

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.

When should the method invokeLater() be used?

This method is used to ensure that Swing components are updated through the event-dispatching thread.

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 .

Which component subclass is used for the drawing and painting?


Which containers may have a menu bar?


Which class is the immediate super class of the menuComponent class?

Object class is the immediate super class of the menu Component class.

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.

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.

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.

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.

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.


Popular posts from this blog

TOP Agile Testing Interview Questions and Answers

Latest Agile Testing Interview Questions and Answers

Most Asked ADO.NET Interview Questions and Answers