YouTube Icon

Interview Questions.

Top 100+ Java Swing Interview Questions And Answers - May 31, 2020

fluid

Top 100+ Java Swing Interview Questions And Answers

Question 1. What's Java Swing?

Answer :

Swing is a GUI toolkit for Java. It is one part of the Java Foundation Classes (JFC). Swing consists of graphical consumer interface (GUI) widgets inclusive of textual content containers, buttons, break up-panes, and tables.
Swing widgets offer extra sophisticated GUI additives than the earlier Abstract Window Toolkit. Since they're written in pure Java, they run the same on all platforms, not like the AWT that's tied to the underlying platform's windowing gadget. Swing supports pluggable look and experience – not by the usage of the local platform's facilities, however by using roughly emulating them. This means you can get any supported look and experience on any platform. The disadvantage of lightweight components is slower execution. The gain is uniform conduct on all structures.

Question 2. What Is Jfc?

Answer :

JFC stands for Java Foundation Classes. The Java Foundation Classes (JFC) are a fixed of Java magnificence libraries furnished as part of Java 2 Platform, Standard Edition (J2SE) to aid building graphics person interface (GUI) and pics functionality for patron packages with the intention to run on popular systems such as Microsoft Windows, Linux, and Mac OSX.

Adv Java Interview Questions
Question three. What Is Awt?

Answer :

AWT stands for Abstract Window Toolkit. AWT enables programmers to develop Java applications with GUI components, along with windows, and buttons. The Java Virtual Machine (JVM) is responsible for translating the AWT calls into the appropriate calls to the host working machine.

 

Question 4. What Are The Differences Between Swing And Awt?

Answer :

AWT is heavy-weight additives, however Swing is light-weight components. AWT is OS established because it uses native additives, But Swing components are OS independent. We can trade the appearance and sense in Swing which isn't always possible in AWT. Swing takes less reminiscence compared to AWT. For drawing AWT uses display screen rendering wherein Swing makes use of double buffering.

Adv Java Tutorial
Question 5. What Are Heavyweight Components?

Answer :

A heavyweight component is one that is associated with its very own native display screen aid (usually known as a peer).

J2EE Interview Questions
Question 6. What Is Lightweight Component?

Answer :

A lightweight element is one that "borrows" the display screen useful resource of an ancestor (which means it has no local resource of its personal -- so it is "lighter").

Question 7. What Is Double Buffering?

Answer :

Double buffering is the technique of use of two buffers rather than one to quickly keep statistics being moved to and from an I/O tool. Double buffering will increase records switch pace because one buffer can be crammed even as the alternative is being emptied.

J2EE Tutorial Core Java Interview Questions
Question eight. What Is An Event In Swing?

Answer :

Changing the country of an item is called an occasion.

 

Question 9. What Is An Event Handler In Swing?

Answer :

An occasion handler is a part of a computer program created to inform the program a way to act in reaction to a specific occasion.

JSP Interview Questions
Question 10. What Is A Layout Manager?

Answer :

A format manager is an object this is used to arrange additives in a box.

Core Java Tutorial
Question eleven. What Is Clipping?

Answer :

Clipping is the technique of confining paint operations to a restricted place or form.

Java-Springs Interview Questions
Question 12. Which Containers Use A Border Layout As Their Default Layout In Swing?

Answer :

The window, Frame and Dialog training use a border layout as their default format.

Adv Java Interview Questions
Question 13. What Is The Preferred Size Of A Component?

Answer :

The desired length of a aspect is the minimum component size with the intention to permit the component to show usually.

JSP Tutorial
Question 14. What Method Is Used To Specify A Container's Layout?

Answer :

The setLayout() technique is used to specify a box's format.

Question 15. Which Containers Use A Flowlayout As Their Default Layout?

Answer :

The Panel and Applet instructions use the FlowLayout as their default layout.

JMS(Java Message Service) Interview Questions
Question 16. Which Method Of The Component Class Is Used To Set The Position And Size Of A Component?

Answer :

setBounds
Method of the Component class is used to set the placement and length of a component.

Java-Springs Tutorial
Question 17. What Is The What Is The Difference Between Invokeandwait() And Invokelater()??

Answer :

invokeAndWait() technique in swing is synchronous. It blocks until Runnable venture is entire. InvokeLater() technique in swing is asynchronous. It posts an movement event to the occasion queue and returns at once. It will now not wait for the assignment to finish.

Java applet Interview Questions
Question 18. Why Should Any Swing Call Back Implementation Execute Quickly?

Answer :

Callbacks are invoked by means of the occasion dispatch thread. Event dispatch thread blocks processing of different occasions as long as name lower back technique executes.

J2EE Interview Questions
Question 19. What Is An Applet?

Answer :

Applet is a java program that runs inner a web browser.

Java Tutorial
Question 20. What Is The Difference Between Applications And Applets?

Answer :

Application have to be run explicitly inside Java Virtual Machine whereas applet loads and runs itself automatically in a java-enabled browser. Application starts offevolved execution with its major approach while applet starts offevolved execution with its init approach. Application can run with or without graphical consumer interface while applet have to run inside a graphical user interface. In order to run an applet we want a java enabled internet browser or an appletviewer.

Java Interview Questions
Question 21. Which Method Is Used By The Applet To Recognize The Height And Width?

Answer :

getParameters()
Method is utilized by the applet to understand the peak and width.

Question 22. When We Should Go For Codebase In Applet?

Answer :

If the applet magnificence isn't in the same directory, codebase is used.

Java 8 Tutorial
Question 23. What Is The Lifecycle Of An Applet?

Answer :

init( ) approach - known as when an applet is first loaded 
start( ) method - referred to as each time an applet is began 
paint( ) technique - referred to as whilst the applet is minimized or maximized 
forestall( ) technique - called whilst the browser movements off the applet's page 
wreck( ) method - called whilst the browser is finished with the applet
Java 8 Interview Questions
Question 24. Which Method Is Used For Setting Security In Applets?

Answer :

setSecurityManager()
Method is used for setting security in applets .

Core Java Interview Questions
Question 25. What Is An Event And What Are The Models Available For Event Handling?

Answer :

Changing the nation of an object is known as an occasion. An occasion is an event object that describes a nation of trade. In different phrases, event occurs while an movement is generated, like urgent a key on keyboard, clicking mouse, and many others. There exclusive styles of models for managing activities are event-inheritance model and occasion-delegation version

Adaptive software improvement Tutorial
Question 26. What Are The Advantages Of The Event-delegation Model Over The Event-inheritance Model?

Answer :

Event-delegation version has  advantages over occasion-inheritance version. A)Event delegation model permits event handling with the aid of gadgets aside from those that generate the events. This allows a easy separation between a element's design and its use. B)It plays lots higher in programs in which many events are generated. This performance improvement is due to occasion-delegation version does no longer ought to be again and again process unhandled occasions as is the case of the event-inheritance.

Java Programmer Interview Questions
Question 27. What Are Types Of Applets?

Answer :

There are  specific types of applets. Which might be defined as :

 Trusted Applets.
Untrusted applets.
Trusted Applets : are applets with predefined protection.
Untrusted Applets : are applets with none protection.

 

JSP Interview Questions
Question 28. Give Us The Name Of The List Layoutmanagers In Java?

Answer :

List is right here :

Flow Layout Manager
Grid Layout Manager
Box Layout Manager
Border Layout Manager
Card Layout Manager
GridBag Layout Manager.
Question 29. Difference Between Paint() And Paintcomponent()?

Answer :

The Key point is that the paint() approach invokes three strategies within the following order :

PaintComponent()
paintBorder()
paintChildren()
As a fashionable rule, in Swing, we must be overriding the paintComponent technique unless we understand what we're doing paintComponent() paints simplest factor (panel) however paint() paints factor and all its children.

Question 30. How Are The Elements Of A Gridbaglayout Organized?

Answer :

The Elements of a GridBagLayout are organized consistent with a grid. However,the elements are of different sizes and can occupy extra than row or column of the grid. In addition, the rows and columns can also have diff sizes.

Question 31. How Are The Elements Of A Borderlayout Organized?

Answer :

The Elements of a BorderLayout are prepared at the borders(North, South, East and West) and the center of a field.

Question 32. What Is The Relationship Between The Canvas Class And The Graphics Class?

Answer :

A Canvas object affords get right of entry to to a pix object through its paint() method.

Question 33. What Is The Diff Between Choice And The List?

Answer :

The distinction are  :

A Choice is displayed in a compact from that requires we to pull ot down tosee the list of available preference, Oly one object may be selected from a Choice.
A List can be dsplyaed in this type of way that numerous List gadgets are visible. A List supports the selection of the one or greater List items .
Java-Springs Interview Questions
Question 34. When Should The Method Invokelater() Be Used?

Answer :

This approach is used to make certain that Swing additives are updated via the occasion­dispatching thread.

Question 35. What Advantage Do Java’s Layout Managers Provide Over Traditional Windowing Systems?

Answer :

Java uses format managers to lay out additives in a constant manner across all windowing platforms. Since Java’s layout managers aren’t tied to absolute sizing and positioning, they may be able to accommodate platformspecific differences among windowing structures.

Question 36. What Is The Relationship Between Clipping And Repainting?

Answer :

When a window is repainted by the AWT portray thread, it sets the clipping regions to the location of the window that calls for repainting.

JMS(Java Message Service) Interview Questions
Question 37. What Is The Difference Between A Window And A Frame?

Answer :

The Frame class extends Window to outline a prime utility window that can have a menu bar. A window can be version.

Question 38. How The Canvas Class And The Graphics Class Are Related?

Answer :

A Canvas object presents access to a Graphics object through its paint() method.

Question 39. Which Is The Super Class Of All Event Classes?

Answer :

The java.Awt.AWTEvent elegance is the best­degree class inside the AWT event­elegance hierarchy.

Question 40. What Is The Difference Between A Menuitem And A Checkboxmenuitem?

Answer :

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

Java applet Interview Questions
Question 41. What Is The Purpose Of The Enableevents() Method?

Answer :

The enableEvents() technique is used to allow an event for a particular item.Normally, an occasion is enabled whilst a listener is added to an item for a particular event. The enableEvents() approach is used by gadgets that cope with occasions by way of overriding their event­dispatch strategies.

Question 42. What Is The Difference Between A Canvas And A Scroll Pane?

Answer :

Canvas is a part. ScrollPane is a container. 
Canvas is a rectangular region wherein the application can draw or lure enter occasions. ScrollPane implements horizontal and vertical scrolling.
 

Java Interview Questions
Question 43. What Is A Convertor?

Answer :

Converter is essentially an application that converts distance measurements among metric and U.S gadgets.

Question forty four. What Is The Difference Between Jfc & Wfc?

Answer :

JFC supports strong and portable user interfaces. The Swing training are robust, well matched with AWT, and offer you with a first rate deal of control over a person interface. Since supply code is to be had, it is especially clean to extend the JFC to do exactly what you want it to do. But the variety of 1/3­birthday celebration controls written for Swing continues to be pretty small.
WFC runs most effective at the Windows (32­bit) person interface, and uses Microsoft extensions to Java for occasion handling and ActiveX integration. Because ActiveX additives are available to WFC applications, there are theoretically extra controls to be had for WFC than for JFC. In exercise, but, maximum ActiveX providers do not actively help WFC, so the variety of controls available for WFC is probably smaller than for JFC. The WFC programming model is carefully aligned with the Windows platform.

Question 45. What Method Is Used To Specify A Container’s Layout?

Answer :

The SetLayout() approach is essentially used to specify a field’s layout.

Question forty six. What Is The Difference Between Awt And Swt?

Answer :

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

Question 47. Why Does Jcomponent Class Have Add() And Remove() Methods But Component Class Does Not?

Answer :

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

Question 48. What Is Difference Between Swing And Jsf?

Answer :

The key distinction is that JSF runs on server, It desires a server like Tomcat or WebLogic or WebSphere. It presentations HTML to the customer. But Swing application is a stand by myself utility.

Question forty nine. What Does Realized Mean?

Answer :

Realized suggest basically is element, Which has been painted on display or that is ready to be painted. Realization can take vicinity with the aid of invoking any of those methods. Which are following as :

 SetVisible(true).
 Show() .
 Pack().
Question 50. What Is The Default Layout For A Contentpane In Jfc?

Answer :

The Defaulf Layout for the ConteutPane in JFC is that :

 BorderLayout.




CFG