-
-
If a method is declared as protected, where may the method be accessed
A protected method may only be accessed by classes or interfaces of the same package orby subclasses ofthe class in which it is declared.
-
How can the Checkbox class be used to create a radio button
By associating Checkbox objects with a CheckboxGroup.
-
Which non-Unicode letter characters may be used as the first character of anidentifier
The non-Unicode letter characters $ and _ may appear as the first character of anidentifier
-
What restrictions are placed on method overloading
Two methods may not have the same name and argument list but different return types.
-
What is the return type of a program's main() method
A program's main() method has a void return type.
-
Name four Container classes
Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane
-
What class of exceptions are generated by the Java run-time system
The Java runtime system generates RuntimeException and Error exceptions.
-
What class allows you to read objects directly from a stream
The ObjectInputStream class supports the reading of objects from input streams.
-
What is the difference between a field variable and a local variable
A field variable is a variable that is declared as a member of a class. A local variable is avariable that isdeclared local to a method.
-
Under what conditions is an object's finalize() method invoked by the garbagecollector
The garbage collector invokes an object's finalize() method when it detects that the objecthas becomeunreachable.
-
How are this() and super() used with constructors
This() is used to invoke a constructor of the same class. super() is used to invoke asuperclass constructor.
-
What is the relationship between a method's throws clause and the exceptionsthat can bethrown during the method's execution
A method's throws clause must declare any checked exceptions that are not caught withinthe body of themethod.
-
Why are the methods of the Math class static
So they can be invoked as if they are a mathematical code library.
-
-
What state is a thread in when it is executing
An executing thread is in the running state.
-
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.
-
How are the elements of a GridLayout organized
The elements of a GridBad layout are of equal size and are laid out using the squares of agrid.
-
What an I/O filter
An I/O filter is an object that reads from one stream and writes to another, usuallyaltering the data in someway as it is passed from one stream to another.
-
If an object is garbage collected, can it become reachable again
Once an object is garbage collected, it ceases to exist. It can no longer become reachableagain.
Java Interview Questions
Ans