COP 3252 Final Test Complete Solution
Which statement is false? Normally, an applet __________ - ANSWER can read files on
any server that can be reached over the network
Using a URL as an argument to the __________ method of interface AppletContext causes
the browser in which an applet is executing to display the URL - ANSWER
showDocument
Which statement is false? - ANSWER With datagram sockets a process establishes a
connection to another process
Once the ServerSocket is created, the server can listen indefinitely (or block) for an
attempt by a client to connect. This is accomplished with a call to the ServerSocket
method __________ - ANSWER accept
A(n) _________ is thrown when a String that is not in proper URL format is passed to a
URL constructor - ANSWER MalformedURLException
If an ObjectInputStream is used to read information from the server, an __________ is
generated when the client attempts to read a value from a stream on which
end-of-stream is detected - ANSWER EOFException
A(n) __________ is thrown when a server address indicated by a client cannot be
resolved - ANSWER UnknownHostException
A JEditorPane generates HyperlinkEvents only if it is __________ - ANSWER uneditable
__________ sockets and the __________ protocol are more desirable for the vast majority
of Java programmers. - ANSWER Stream, TCP
UDP is a connection-oriented protocol - ANSWER False
Which statement is false? - ANSWER A non-generic class cannot be derived from a
generic class
Which statement is false? - ANSWER A List cannot contain duplicate elements
One generic Stack class could be the basis for creating many Stack classes, e.g.,
Stack<Double>, Stack<Integer> and Stack<Employee>. These classes are known as
__________. - ANSWER parameterized classes
When the compiler translates a generic method into Java bytecodes, it uses __________
to replace the type parameters with actual types. - ANSWER erasure
When a generic class is instantiated without specifying a type argument, it is said to
have a __________. - ANSWER raw type
, A(n) __________ allows a program to walk through the collection and remove elements
from the collection. - ANSWER Iterator
The collections framework algorithms are __________, i.e., each of these algorithms can
operate on objects that offer given interfaces without concern to the underlying
implementations. - ANSWER polymorphic
__________ enable programmers to specify, with a single method declaration, a set of
related methods. - ANSWER Generic methods
Collections method sort that accepts a List as an argument sorts the elements of a List,
which must implement the __________ interface. - ANSWER Comparable
The classes and interfaces which comprise the collections framework are members of
package ________. - ANSWER java.util
An uncaught exception: - ANSWER is an exception that occurs for which there are no
matching catch clauses.
When a __________ method or block is running on an object, the object is locked so no
other such method can run on that object at the same time. - ANSWER synchronized
The preferred means of creating multithreaded Java applications is by implementing the
________ interface. An object of a class that implements this interface represents a task
to perform. - ANSWER Runnable
A new thread begins its life cycle by transitioning to the __________ state. - ANSWER new
To catch an exception, the code that might throw the exception must be enclosed in a -
ANSWER try block
Which of the following statements about try blocks is true? - ANSWER The try block
should contain statements that may throw an exception
In the catch block below, what is arithmeticException?
catch ( ArithmeticException arithmeticException )
{
System.err.printf( arithmeticException );
} // end catch - ANSWER The name of catch block's exception parameter
The main method executes in the ________ thread of execution. - ANSWER main
Which of the following is not true of ExecutorService? - ANSWER It is an object that can
be run in a separate thread
Which statement is false? Normally, an applet __________ - ANSWER can read files on
any server that can be reached over the network
Using a URL as an argument to the __________ method of interface AppletContext causes
the browser in which an applet is executing to display the URL - ANSWER
showDocument
Which statement is false? - ANSWER With datagram sockets a process establishes a
connection to another process
Once the ServerSocket is created, the server can listen indefinitely (or block) for an
attempt by a client to connect. This is accomplished with a call to the ServerSocket
method __________ - ANSWER accept
A(n) _________ is thrown when a String that is not in proper URL format is passed to a
URL constructor - ANSWER MalformedURLException
If an ObjectInputStream is used to read information from the server, an __________ is
generated when the client attempts to read a value from a stream on which
end-of-stream is detected - ANSWER EOFException
A(n) __________ is thrown when a server address indicated by a client cannot be
resolved - ANSWER UnknownHostException
A JEditorPane generates HyperlinkEvents only if it is __________ - ANSWER uneditable
__________ sockets and the __________ protocol are more desirable for the vast majority
of Java programmers. - ANSWER Stream, TCP
UDP is a connection-oriented protocol - ANSWER False
Which statement is false? - ANSWER A non-generic class cannot be derived from a
generic class
Which statement is false? - ANSWER A List cannot contain duplicate elements
One generic Stack class could be the basis for creating many Stack classes, e.g.,
Stack<Double>, Stack<Integer> and Stack<Employee>. These classes are known as
__________. - ANSWER parameterized classes
When the compiler translates a generic method into Java bytecodes, it uses __________
to replace the type parameters with actual types. - ANSWER erasure
When a generic class is instantiated without specifying a type argument, it is said to
have a __________. - ANSWER raw type
, A(n) __________ allows a program to walk through the collection and remove elements
from the collection. - ANSWER Iterator
The collections framework algorithms are __________, i.e., each of these algorithms can
operate on objects that offer given interfaces without concern to the underlying
implementations. - ANSWER polymorphic
__________ enable programmers to specify, with a single method declaration, a set of
related methods. - ANSWER Generic methods
Collections method sort that accepts a List as an argument sorts the elements of a List,
which must implement the __________ interface. - ANSWER Comparable
The classes and interfaces which comprise the collections framework are members of
package ________. - ANSWER java.util
An uncaught exception: - ANSWER is an exception that occurs for which there are no
matching catch clauses.
When a __________ method or block is running on an object, the object is locked so no
other such method can run on that object at the same time. - ANSWER synchronized
The preferred means of creating multithreaded Java applications is by implementing the
________ interface. An object of a class that implements this interface represents a task
to perform. - ANSWER Runnable
A new thread begins its life cycle by transitioning to the __________ state. - ANSWER new
To catch an exception, the code that might throw the exception must be enclosed in a -
ANSWER try block
Which of the following statements about try blocks is true? - ANSWER The try block
should contain statements that may throw an exception
In the catch block below, what is arithmeticException?
catch ( ArithmeticException arithmeticException )
{
System.err.printf( arithmeticException );
} // end catch - ANSWER The name of catch block's exception parameter
The main method executes in the ________ thread of execution. - ANSWER main
Which of the following is not true of ExecutorService? - ANSWER It is an object that can
be run in a separate thread