Top 25+ Advanced Java Swing Interview Questions 2019-2020 - 1

Question: 1

What is Event Driven Thread (EDT) is Swing?

Event Driven Thread or EDT is a special thread in Swing and AWT. Event Driven Thread is used to draw graphics and listen for events in Swing.

You will get a bonus point if you able to highlight that time consuming operations like connecting to database, opening a file or connecting to network should not be done on EDT thread because it could lead to freezing GUI because of blocking and time consuming nature of these operations instead they should be done on separate thread and EDT can just be used o spawn those thread on a button click or mouse click.

Question: 2

What are differences between Swing and AWT?

There is couple of differences between swing and AWT.

AWT component are considered to be heavyweight while Swing component are lightweights.

Swing has plug gable look and feel.

AWT is platform dependent same GUI will look different platform while Swing is developed in Java and is platform dependent.

Question: 3

What is the difference between a Window and a Frame?

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

Question: 4

What is the difference between the paint() and repaint() methods?

The paint() method supports painting via a Graphics object.

The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

Question: 5

How can a GUI component handle its own events?

A component can handle its own events by implementing the required event listener interface and adding itself as its own event listener.

Related Questions