Login Form




FAQ in Core Java - 3 Print E-mail

1. What is the difference between yielding and sleeping?

When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

 

2. Can an object's finalize() method be invoked while it is reachable?

An object's finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an object's finalize() method may be invoked by other objects.

 

3. What  is a transient variable?

A transient variable is a variable that may not be serialized.

 

4. What is the catch or declare rule for method declarations?

If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.

 

5. What is the range of the char type?

The range of the char type is 0 to 2^16 - 1.

 

6. When a thread blocks on I/O, what state does it enter?

A thread enters the waiting state when it blocks on I/O.

 

7. Which containers use a FlowLayout as their default layout?

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

 

8. Why do threads block on I/O?

Threads block on i/o (that is enters the waiting state) so that other threads may execute while the i/o Operation is performed.

 

9. Which method of the Component class is used to set the position and size of a component?

setBounds()

 

10. What value does readLine() return when it has reached the end of a file?

The readLine() method returns null when it has reached the end of a file.

 

11. What is the immediate superclass of the Applet class?

Panel

 

12. Which containers use a border Layout as their default layout?

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

 

13. What modifiers may be used with an inner class that is a member of an outer class?

A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.

 

14. To what value is a variable of the String type automatically initialized?

The default value of an String type is null.

 

15. In which package are most of the AWT events that support the event-delegation model defined?

Most of the AWT-related events of the event-delegation model are defined in the java.awt.event package. The AWTEvent class is defined in the java.awt package.