-
Which package is always imported by default
The java.lang package is always imported by default.
-
What interface must an object implement before it can be written to a streamas an object
An object must implement the Serializable or Externalizable interface before it can bewritten to a stream asan object.
-
How are this and super used
This is used to refer to the current object instance. super is used to refer to the variablesand methods of thesuperclass of the current object instance.
-
What is the purpose of garbage collection
The purpose of garbage collection is to identify and discard objects that are no longerneeded by a programso that their resources may be reclaimed and reused.
-
What is a compilation unit
A compilation unit is a Java source code file.
-
What interface is extended by AWT event listeners
All AWT event listeners extend the java.util.EventListener interface.
-
How can a dead thread be restarted
A dead thread cannot be restarted.
-
What happens if an exception is not caught
An uncaught exception results in the uncaughtException() method of the thread'sThreadGroup beinginvoked, which eventually results in the termination of the program in which it is thrown.
-
What is a layout manager
A layout manager is an object that is used to organize components in a container.
-
Which arithmetic operations can result in the throwing of anArithmeticException
Integer / and % can result in the throwing of an ArithmeticException.
-
What are three ways in which a thread can enter the waiting state
A thread can enter the waiting state by invoking its sleep() method, by blocking on I/O,by unsuccessfullyattempting to acquire an object's lock, or by invoking an object's wait() method. It canalso enter thewaiting state by invoking its (deprecated) suspend() method.
-
Can an abstract class be final
An abstract class may not be declared as final.
-
What is the ResourceBundle class
The ResourceBundle class is used to store locale-specific resources that can be loaded bya program totailor the program's appearance to the particular locale in which it is being run.
-
What is the difference between a Scrollbar and a ScrollPane
A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. AScrollPane handles itsown events and performs its own scrolling.
-
What is the difference between a public and a non-public class
A public class may be accessed outside of its package. A non-public class may not beaccessed outside ofits package.
-
To what value is a variable of the boolean type automatically initialized
The default value of the boolean type is false.
-
Can try statements be nested
Try statements may be tested.
-
What is the purpose of a statement block
A statement block is used to organize a sequence of statements as a single statementgroup.
-
What modifiers may be used with a top-level class
A top-level class may be public, abstract, or final.
-
When is an object subject to garbage collection
An object is subject to garbage collection when it becomes unreachable to the program inwhich it is used.
Java Interview Questions
Ans