Java Interview Question and Answers Part 3
Java Interview Question and Answers
What
is an Applet ?
A java applet is
program that can be included in a HTML page and be executed in a java enabled
client browser. Applets are used for creating dynamic and interactive web
applications.
Explain the life cycle of an Applet.
An applet may undergo the following states:
• Init: An applet is initialized each time is loaded.
• Start: Begin the execution of an applet.
• Stop: Stop the execution of an applet.
• Destroy: Perform a final cleanup, before unloading
the applet.
What happens when an applet is loaded ?
First of all, an instance of the applet’s controlling class
is created. Then, the applet initializes itself and finally, it starts running.
What are untrusted applets ?
Untrusted applets are those Java applets that cannot access
or execute local system files. By default, all downloaded applets are
considered as untrusted.
What is the applet security manager, and what does it
provide ?
The applet security manager is a mechanism to impose
restrictions on Java applets. A browser may only have one security manager. The
security manager is established at startup, and it cannot thereafter be
replaced, overloaded, overridden, or extended.
What is a layout manager ?
A layout manager is the used to organize the components in a
container.
What is the difference between a Scrollbar and a
JScrollPane ?
A Scrollbar is a Component, but not a Container. A
ScrollPane is a Container. A ScrollPane handles its own events and performs its
own scrolling.
Which Swing methods are thread-safe ?
There are only three thread-safe methods: repaint,
revalidate, and invalidate.
Name three Component subclasses that support painting. The
Canvas, Frame, Panel, and Applet classes support painting.
What is clipping ?
Clipping is defined as the process of confining paint
operations to a limited area or shape.
What is the difference between a MenuItem and a
CheckboxMenuItem ?
The CheckboxMenuItem class extends the MenuItem class and
supports a menu item that may be either checked or unchecked.
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. The elements are of different sizes and may occupy more than one row or
column of the grid. Thus, the rows and columns may have different sizes.
What is the difference between a Window and a Frame ?
The Frame class extends the Window class and defines a main
application window that can have a menu bar.
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 is the relationship between an event-listener
interface and an eventadapter class ?
An event-listener interface defines the methods that must be
implemented by an event handler for a particular event. An event adapter
provides a default implementation of an event-listener interface.
How can a GUI component handle its own events ?
A GUI component can handle its own events, by implementing
the corresponding event-listener interface and adding itself as its own event
listener.
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 layout managers aren’t
tied to absolute sizing and positioning, they are able to accomodate
platform-specific differences among windowing systems.
What is the design pattern that Java uses for all Swing
components ?
The design pattern used by Java for all Swing components is
the Model View Controller (MVC) pattern.
What is an applet?
An applet is a Java program that runs in a Web browser. An
applet can be a fully functional Java application because it has the entire
Java API at its disposal.
An applet extend which class?
An applet extends java.applet.Applet class.
Explain garbage collection in Java?
It uses garbage collection to free the memory. By cleaning
those objects that is no longer reference by any of the program.
Define immutable object?
An immutable object can’t be changed once it is created.
Explain the usage of this with constructors?
It is used with variables or methods and used to call
constructer of same class.
Explain Set Interface?
It is a collection of element which cannot contain duplicate
elements. The Set interface contains only methods inherited from Collection and
adds the restriction that duplicate elements are prohibited.
Explain TreeSet?
It is a Set implemented when we want elements in a sorted
order.
If you feel our post is helpful to you so please subscribe
our blog and share with your friends.
please write your comments in comments box for encouraging me .
Thanks !!
Java Interview Question and Answers Part 3
Reviewed by Unknown
on
October 09, 2018
Rating:
No comments: