-
-
What method is invoked to cause an object to begin executing as a separate thread
The start() method of the Thread class is invoked to cause an object to begin executing asa separate thread.
-
Java Copy Command
Write the Java version of MS DOS Copy Command
-
What happens when you invoke a thread's interrupt method while it issleeping or waiting
When a task's interrupt() method is executed, the task enters the ready state. The nexttime the task enters the running state, an InterruptedException is thrown.
-
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 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.
-
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.
-
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 class of exceptions are generated by the Java run-time system
The Java runtime system generates RuntimeException and Error exceptions.
-
What classes of exceptions may be caught by a catch clause
A catch clause can catch any exception that may be assigned to the Throwable type. Thisincludes the Errorand Exception types.
-
How are the elements of a CardLayout organized
The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.
-
For which statements does it make sense to use a label
The only statements for which it makes sense to use a label are those statements that canenclose a break orcontinue statement.
-
What modifiers may be used with an interface declaration
An interface may be declared as public or abstract.
-
What modifiers can be used with a local inner class
A local inner class may be final or abstract.
-
What are the legal operands of the instanceof operator
The left operand is an object reference or null value and the right operand is a class,interface, or array type.
-
What must a class do to implement an interface
It must provide all of the methods in the interface and identify the interface in itsimplements clause.
-
What classes of exceptions may be thrown by a throw statement
A throw statement may throw any expression that may be assigned to the Throwabletype.
-
What is the purpose of finalization
The purpose of finalization is to give an unreachable object the opportunity to performany cleanupprocessing before the object is garbage collected.
-
What is the purpose of the finally clause of a try-catch-finally statement
The finally clause is used to provide the capability to execute code no matter whether ornot an exception isthrown or caught.
Java Interview Questions
Ans