Translate

Thursday, September 6, 2012

ADVANCED JAVA PART 7


ADVANCED JAVA PART 7


121. Which class is the immediate superclass of the Container class?

Component.

122. 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 or by

subclasses of the class in which it is declared.

123. How can the Checkbox class be used to create a radio button?

By associating Checkbox objects with a CheckboxGroup.

124. Which non-Unicode letter characters may be used as the first character of an

identifier?

The non-Unicode letter characters $ and _ may appear as the first character of an identifier

125. What restrictions are placed on method overloading?

Two methods may not have the same name and argument list but different return types.

126. What happens when you invoke a thread's interrupt method while it is sleeping or

waiting?

When a task's interrupt() method is executed, the task enters the ready state. The next time the

task enters the running state, an InterruptedException is thrown.

127. What is casting?

There are two types of casting, casting between primitive numeric types and casting between object

references.

Casting between numeric types is used to convert larger values, such as double values, to smaller

values, such as byte values.

Casting between object references is used to refer to an object by a compatible class, interface,

or arraytype reference.

128. What is the return type of a program's main() method?

A program's main() method has a void return type.

129. Name four Container classes.

Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane.

130. What is the difference between a Choice and a List?

A Choice is displayed in a compact form that requires you to pull it down to see the list of available

choices. Only one item may be selected from a Choice.

A List may be displayed in such a way that several List items are visible. A List supports the selection

of one or more List items.

131. What class of exceptions are generated by the Java run-time system?

The Java runtime system generates RuntimeException and Error exceptions.

132. What class allows you to read objects directly from a stream?

The ObjectInputStream class supports the reading of objects from input streams.

133. 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 a variable that is declared local to a method.

134. Under what conditions is an object's finalize() method invoked by the garbage

collector?

The garbage collector invokes an object's finalize() method when it detects that the object has

become unreachable.

135. What is the relationship between a method's throws clause and the exceptions that

can be thrown during the method's execution?

A method's throws clause must declare any checked exceptions that are not caught within the body of

the method.

136. What is the difference between the JDK 1.02 event model and the event-delegation

model introduced with JDK 1.1?

The JDK 1.02 event model uses an event inheritance or bubbling approach. In this model, components

are required to handle their own events. If they do not handle a particular event, the event is

inherited by (or bubbled up to) the component's container. The container then either handles the

event or it is bubbled up to its container and so on, until the highest-level container has been tried.

In the event-delegation model, specific objects are designated as event handlers for GUI components.

These objects implement event-listener interfaces. The event-delegation model is more efficient than

the event-inheritance model because it eliminates the processing required to support the bubbling of

unhandled events.

137. How is it possible for two String objects with identical values not to be equal under the

== operator?

The == operator compares two objects to determine if they are the same object in memory. It is

possible for two String objects to have the same value, but located indifferent areas of memory.

138. Why are the methods of the Math class static?

So they can be invoked as if they are a mathematical code library.

139. What Checkbox method allows you to tell if a Checkbox is checked?

getState().

140. What state is a thread in when it is executing?

An executing thread is in the running state.

No comments:

Post a Comment