Login Form




FAQ in Core Java - 7 Print E-mail

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

 

2. What is the SimpleTimeZone class?

The SimpleTimeZone class provides support for a Gregorian calendar.

 

3. What is the argument type of a program's main() method?

A program's main() method takes an argument of the String[] type.

 

4. What are the high-level thread states?

The high-level thread states are ready, running, waiting, and dead.

 

5. What is the relationship between an event-listener interface and an event-adapter class?

An event-listener interface defines the methods that 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.

 

6. What event results from the clicking of a button?

The ActionEvent event is generated as the result of the clicking of a button.

 

7. How are commas used in the intialization and iteration  parts of a for statement?

Commas are used to separate multiple statements within the initialization and iteration parts of a for statement.

 

8. What is the advantage of the event-delegation model over the earlier event-inheritance model?

The event-delegation model has two advantages over the event-inheritance model. First, it enables event handling to be handled by objects other than the ones that generate the events (or their containers). This allows a clean separation between a component's design and its use. The other advantage of the event-delegation model is that it performs much better in applications where many events are generated. This performance improvement is due to the fact that the event-delegation model does not have to repeatedly process unhandled events, as is the case of the event-inheritance model.

 

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

 

10. What is the highest-level event class of the event-delegation model?

The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.

 

11. Can an object be garbage collected while it is still reachable?

A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected..

 

12. What is the Map interface?

The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.

 

13. Is &&= a valid Java operator?

No, it is not.

 

14. If a variable is declared as private, where may the variable be accessed?

A private variable may only be accessed within the class in which it is declared.

 

15. What is the difference between the Font and FontMetrics classes?

The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.