Advanced Java Questions and Answer for Interview
121. When is the finally clause of a try-catch-finally statement executed?
The finally clause of the try-catch-finally statement is always executed unless the thread of execution terminates or an exception occurs within the execution of the finally clause.
122. Which class is the immediate superclass of the Container class?
123. If a method is declared as protected, where may the method be accessed?
protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.
124. How can the Checkbox class be used to create a radio button?
By associating Checkbox objects with a
125. Which non-Unicode letter characters may be used as the first character of an identifier?
The non-Unicode letter characters
$ and _ may appear as the first character of an identifier
126. What restrictions are placed on method overloading?
Two methods may not have the same name and argument list but different return types.
127. What happens when you invoke a thread's interrupt method while it is sleeping or waiting?
When a task's
interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an
InterruptedException is thrown.
128. What is casting?
There are two types of casting, casting between primitive numeric types and casting between object references.
Casting between numeric types is used to convert larger values, such as
double values, to smaller values, such as
Casting between object references is used to refer to an object by a compatible
class, interface, or
array type reference.
129. What is the return type of a program's main() method?
main() method has a
void return type.
130. Name four Container classes.
Window, Frame, Dialog, FileDialog, Panel, Applet, or