-
Does garbage collection guarantee that a program will not run out of memory
Garbage collection does not guarantee that a program will not run out of memory. It ispossible forprograms to use up memory resources faster than they are garbage collected. It is alsopossible forprograms to create objects that are not subject to garbage collection
-
What restrictions are placed on the location of a package statement within asource code file
A package statement must appear as the first line in a source code file (excluding blanklines andcomments).
-
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 objectis still reachable.However, an object's finalize() method may be invoked by other objects.
-
-
Name three Component subclasses that support painting
The Canvas, Frame, Panel, and Applet classes support painting.
-
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.
-
-
What is clipping
Clipping is the process of confining paint operations to a limited area or shape.
-
What is a native method
A native method is a method that is implemented in a language other than Java.
-
Can a for statement loop indefinitely
Yes, a for statement can loop indefinitely. For example, consider the following:for(;;) ;
-
When a thread blocks on I/O, what state does it enter
A thread enters the waiting state when it blocks on I/O.
-
To what value is a variable of the String type automatically initialized
The default value of an String type is null.
-
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 musteither catch theexception or declare it in its throws clause.
-
What class is the top of the AWT event hierarchy
The java.awt.AWTEvent class is the highest-level class in the AWT event-classhierarchy.
-
When a thread is created and started, what is its initial state
A thread is in the ready state after it has been created and started.
-
Can an anonymous class be declared as implementing an interface andextending a class
An anonymous class may implement an interface or extend a superclass, but may not bedeclared to doboth.
-
What is the range of the short type
The range of the short type is -(2^15) to 2^15 - 1.
-
-
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.
-
Java Interview Questions
Ans