Saturday 31 January 2015

Java Swing Programming interview questions and answers (Part6)

51. What is the difference between scrollbar and scrollpane?
Main diff are there :
> A Scrollbar is a Component, but not a Container whereas Scrollpane is a Container and handles its own events and perform its own scrolling.

52. What is a layout manager and what are different types of layout managers available?
A layout manager is basically an object, Its mainly used to organize components in a container.
The different layouts are available here : 
> FlowLayout,
> BorderLayout,
> CardLayout,
> GridLayout ,
> GridBagLayout,
> Boxlayout and
> SpringLayout.

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

54. What are types of applets?
There are two different types of applets. that are defined as :
> Trusted Applets and
> Untrusted applets.
> Trusted Applets : are applets with predefined security .and
> Untrusted Applets : are applets without any security.

55. What are the restrictions imposed by a Security Manager on Applets?
Applets cannot read or write files on the client machine that's executing it. They cannot load libraries or access native libraries. They cannot make network connections except to the host that it came from. They cannot start any program on the client machine. They cannot read certain system properties. Windows that an applet brings up look different than windows that an application brings up.

56. What is the difference between the Font and FontMetrics classes?
Main diff are there :
> The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.

57. What is the relationship between an event-listener interface and an event-adapter class? 
An Event-listener interface bassically defines the methods , WHich  must be implemented by an event handler for a particular kind of event. An event adapter provides a default implementation of an event-listener interface.

58. 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.

59. What is the difference between the paint() and repaint() methods? 
Main diff are there :
> The paint() method : Its supports painting via a Graphics object.
> The Repaint() method : It is used to cause paint() to be invoked by the AWT painting thread.

60. What interface is extended by AWT event listeners?
java.util.EventListener interface is extented by all AWT event listeners.
More Questions & Answers :-
Part1  Part2  Part3  Part4  Part5  Part6  Part7  Part8  Part9

No comments:

Post a Comment