-
What is the purpose of the enableEvents() method
The enableEvents() method is used to enable an event for a particular object. Normally,an event is enabled when a listener is added to an object for a particular event. TheenableEvents() method is used by objects that handle events by overriding their eventdispatchmethods.
-
What interface must an object implement before it can be written to astream as an object
An object must implement the Serializable or Externalizable interface before it can bewritten to a stream as an 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 the superclass of the current object instance.
-
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.
-
What happens if an exception is not caught
An uncaught exception results in the uncaughtException() method of the thread'sThreadGroup being invoked, which eventually results in the termination of the programin 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 an ArithmeticException
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 unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait()method. It can also enter the waiting 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 to tailor the program's appearance to the particular locale in which it is beingrun.
-
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 its own 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 of its package.
-
To what value is a variable of the boolean type automatically initialized
The default value of the boolean type is false.
-
What is the difference between the prefix and postfix forms of the ++ operator
The prefix form performs the increment operation and returns the value of the incrementoperation. The postfix form returns the current value all of the expression and thenperforms the increment operation on that value.
-
What is the purpose of a statement block
A statement block is used to organize a sequence of statements as a single statementgroup.
-
What are the Object and Class classes used for
The Object class is the highest-level class in the Java class hierarchy. The Class class isused to represent the classes and interfaces that are loaded by a Java program..
-
Can an unreachable object become reachable again
An unreachable object may become reachable again. This can happen when the object'sfinalize() method is invoked and the object performs an operation which causes it tobecome accessible to reachable objects.
-
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.
-
What method must be implemented by all threads
All tasks must implement the run() method, whether they are a subclass of Thread orimplement the Runnable interface.
Java Interview Questions
Ans