1
Fill in the blank. In Java, each class can have ________________.
Choose one answer.
a. Only one subclasses
b. Only one superclass
c. State and behavior from only one other class
d. More than one subclass and superclass
.
.
Question 2
What are the instances of an object called?
Choose one answer.
a. Bundle
b. Function
c. Method
d. Object
.
.
Question 3
Which of the following is a characteristic of an object?
Choose one answer.
a. Behavior
b. State
c. Both A and B
d. None of the above
.
.
Question 4
Which of the following is an advantage of object-oriented code?
Choose one answer.
a. Code reuse
b. Information-hiding
c. Modularity
d. All of the above
.
.
Question 5
A method in Java is used to change the state in which of the following?
Choose one answer.
a. Class
b. Object
c. Program
d. All of the above
.
.
Question 6
An object includes which of the following?
Choose one answer.
a. Behavior
b. Field
c. State
d. All of the above
.
.
Question 7
Data encapsulation includes which of the following?
Choose one answer.
a. Internal state
b. Behavior
c. Method
d. All of the above
.
.
Question 8
Which of the following is a Java package?
Choose one answer.
a. Class
b. Interface
c. Namespace
d. Relationship
.
.
Question 9
Which of the following statement best describes an interface?
Choose one answer.
a. Implementing an interface formally describes the behavior it provides.
b. Methods defined by the interface do not have to appear in its source code to compile.
c. The interface does not form its “contract” between the class and the outside world until the compiled program is run.
d. All of the above
.
.
Question 10
With inheritance, a class can have which of the following?
Choose one answer.
a. A commonly used state from another class
b. A rarely used behavior from a number of other classes
c. Only one subclass
d. All of the above
.
.
Question 11
Which of the following statements best describes a race condition in a multi-threaded program?
Choose one answer.
a. Another thread may change or invalidate a result before the originating thread completes its sequence.
b. A race condition only exists when counting is in process.
c. The thread involves a sequence of actions, but each action is independent of a previous action.
d. All of the above
.
.
Question 12
Which of the following statements best describes how networks that use blocking apply multi-threading?
Choose one answer.
a. At any given time the number of active threads may only be a fraction of the total number of threads.
b. The number of active threads should be comparable to the number of available processors.
c. Network operations may choose to block a thread that handles communication with a client.
d. All of the above
.
.
Question 13
Which of the following statements best describes using a thread pool?
Choose one answer.
a. A thread pool is a large collection of threads available for tasks to be performed.
b. A new task is assigned to a thread in the pool rather than creating a new thread.
c. Thread pools are used when a small number of tasks are to be performed.
d. All of the above
.
.
Question 14
Which of the following statements best describes using multi-threading?
Choose one answer.
a. A thread pool is used to make a new thread for each client connection.
b. A task that runs a significant amount of time may cause other clients to wait.
c. The server program processes connection requests from many clients.
d. All of the above
.
.
Question 15
Which instance method is called inside a try..catch statement, because it can throw exceptions of type IOException?
Choose one answer.
a. Public char peek()
b. Public boolean eof()
c. Public String getln()
d. All of the above
.
.
Question 16
Which Java class allows you to stream data?
Choose one answer.
a. DataInputStream
b. PrintWriter
c. Scanner
d. All of the above
.
.
Question 17
Which Java stream is best used in network communications?
Choose one answer.
a. Byte
b. Character
c. Network
d. Public
.
.
Question 18
Which Java stream is best when using a scanner?
Choose one answer.
a. Binary data
b. Letters in a word
c. Tokens
d. All of the above
.
.
Question 19
Which of the following statements best describes the use of streaming in Java?
Choose one answer.
a. A stream is an abstraction for input/output.
b. A stream is a specific destination for output such as a network connection.
c. A stream allows the programmer to specify the source file.
d. All of the above
.
.
Question 20
Which statement best describes a problem in using Java stream objects?
Choose one answer.
a. They suffer from the fragility that is often seen in character data.
b. The data in object streams is not easily available to programs written in other languages.
c. The objects can only be transmitted over a network connection from one Java program to another.
d. All of the above
.
.
Question 21
Which statement best describes how to write mutable objects to an ObjectOutputStream?
Choose one answer.
a. Avoid writing the same object more than once.
b. Call the stream's reset() method before writing the object to the stream.
c. Use only string data.
d. All of the above
.
.
Question 22
Which statement best describes Java stream objects?
Choose one answer.
a. They suffer from the fragility that is often seen in binary data.
b. The object streams are byte streams.
c. The objects are represented in machine-readable form for efficiency.
d. All of the above
.
.
Question 23
Which statement describes why Object OutputStreams are designed to be used with an immutable stream object?
Choose one answer.
a. These streams are optimized to avoid writing the same object more than once.
b. If the object has been modified, the new data will not be written.
c. When an object is encountered for a second time, only a reference to the first occurrence is written.
d. All of the above
.
.
Question 24
A Java program requires a completed form be written on the server before access is granted. Which of the following steps is required to satisfy the server?
Choose one answer.
a. Retrieve the URLConnection object.
b. Set output capability on the URLConnection.
c. Write to the output stream.
d. All of the above
.
.
Question 25
Java.net classes include which of the following?
Choose one answer.
a. Client-server
b. Port
c. Socket
d. All of the above
.
.
Question 26
The Java Network Interface can be used to do which of the following?
Choose one answer.
a. To create a new instance of the interface
b. To determine a virtual connection's IP address
c. To set constructor to public
d. All of the above
.
.
Question 27
The java.net.NetworkInterface can be used to do which of the following?
Choose one answer.
a. Create a socket
b. Connect/access multiple NIC's
c. Join a multicast group
d. All of the above
.
.
Question 28
The TCP protocol provides a reliable channel for internet applications developed in HTML under which condition?
Choose one answer.
a. The data can be transformed to the order needed by the receiving URL.
b. The data must be received in the order in which it was sent.
c. The protocol allows networks to detect corrupt files and return them to the sender.
d. All of the above
.
.
Question 29
Which method allows Java to access an URL over a network?
Choose one answer.
a. getPort
b. URL
c. URLConnection
d. All of the above
.
.
Question 30
Which of following describes a datagram packet?
Choose one answer.
a. It is another name for a TCP packet.
b. It requires a reliable flow of data between two computers.
c. It relies on the UDP protocol.
d. All of the above
.
.
Question 31
Which of the following applications require code to generate the input/output stream?
Choose one answer.
a. Cookie
b. Form
c. Search
d. All of the above
.
.
Question 32
Which of the following is the purpose of the site CookieManager constructor?
Choose one answer.
a. To create the default cookie handler
b. To determine where session cookies will be stored
c. To set cookie policy for the session
d. All of the above
.
.
Question 33
Fill in the blank. Namespace support to resolve DTD naming conflicts is provided by___________.
Choose one answer.
a. DOM
b. JAXP
c. SAX
d. XSLT
.
.
Question 34
Fill in the blank. The API for parsing XML data in the Java programming language is ___________.
Choose one answer.
a. DOM
b. JAXP
c. SAX
d. XSLT
.
.
Question 35
Fill in the blank. The API for processing XML data written in the Java programming language is __________.
Choose one answer.
a. DOM
b. JAXP
c. SAX
d. XSLT
.
.
Question 36
How is an element in XML similar to a HTML statement?
Choose one answer.
a. Both contain a beginning tag <>.
b. Both contain an ending tag </>.
c. Both can be nested.
d. All of the above
.
.
Question 37
JAXP pluggability includes which of the following?
Choose one answer.
a. DOM
b. SAX
c. XSL
d. All of the above
.
.
Question 38
The package java.io includes a class named URL. Which statement best describes what this class does?
Choose one answer.
a. The URL contains a socket address for a webpage on a network.
b. The URL object defines the web owner.
c. The URL object has an openConnection() method to access the information that it represents.
d. All of the above
.
.
Question 39
The SAX parsing APIs include which of the following classes?
Choose one answer.
a. SAXParserFactory
b. SAXReader
c. SAXParser
d. DTDHandler
.
.
Question 40
The SAX parsing APIs include which of the following wrappers?
Choose one answer.
a. SAXParserFactory
b. SAXReader
c. SAXParser
d. DefaultHandler
.
.
Question 41
The SAX parsing APIs include which of the following methods?
Choose one answer.
a. SAXParserFactory
b. SAXReader
c. SAXParser
d. EntityResolver
.
.
Question 42
When coding in XML, which of the following is similar to coding in HTML?
Choose one answer.
a. With coding in XML or HTML, always use utf-8.
b. With coding in XML or HTML, start with the declaration statement <?
c. With coding in XML or HTML, use any text editor to create the file
d. All of the above
.
.
Question 43
Which of the following describes the use of the declaration in XML?
Choose one answer.
a. It identifies the file as an XML document.
b. It is the first processing instruction in the program.
c. It starts with the characters <?
d. All of the above
.
.
Question 44
Which of the following is a set of built-in (default) template rules defined in XSLT?
Choose one answer.
a. Automatic copying of text
b. Processing instructions
c. Skipping comments
d. All of the above
.
.
Question 45
Which of the following is NOT defined in XSLT's built in template rules?
Choose one answer.
a. Copying attribute nodes
b. Section Title
c. Skipping comments
d. None of the above
.
.
Question 46
Which of the following statements best describes an XML filter chain in Java?
Choose one answer.
a. It is the normalization of an XSLT transformation.
b. The output of one transformation becomes the input of the next.
c. The final output is always XML.
d. All of the above
.
.
Question 47
Which statement best describes JAXP?
Choose one answer.
a. JAXP leverages the parser routines.
b. JAXP provides control over the presentation of XML data.
c. JAXP prevents streaming of events by building object representations.
d. All of the above
.
.
Question 48
The package java.io includes a class named URL. Which statement best describes what this class does?
Choose one answer.
a. The URL contains a socket address for a webpage on a network.
b. The URL object defines the web owner.
c. The URL object has an openConnection() method to access the information that it represents.
d. All of the above
.
.
Question 49
The SAX parsing APIs include which of the following error interface?
Choose one answer.
a. DTDHandler
b. EntityResolver
c. SAXParser
d. All of the above
.
.
Question 50
When a method throws an exception, what does your code include?
Choose one answer.
a. A try statement with a catch clause to handle the exception.
b. The method definition declares that calling the method might throw the exception.
c. The method heading includes a throws clause.
d. All of the above
.
.
Question 51
When using DOM, an application can recover from an error using which of the following?
Choose one answer.
a. DTDHandler
b. EntityResolver
c. ErrorHandler
d. All of the above
.
.
Question 52
Which of the following is an area in which DOM is weak in serialization of an XML?
Choose one answer.
a. File
b. OutputStream
c. Writer
d. All of the above
.
.
Question 53
Which of the following will create an URLConnection object?
Choose one answer.
a. getInput Stream operation
b. getOutput Stream operation
c. openConnection method
d. All of the above
.
.
Question 54
When a subroutine encounters an error during execution, what happens?
Choose one answer.
a. An exception is generated.
b. The program that called the subroutine attempts to resolve the problem.
c. The program abends.
d. All of the above
.
.
Question 55
When you create a remote interface, you must follow which of these guidelines?
Choose one answer.
a. Each method in the interface must declare java.rmi.RemoteException in its throws clause.
b. The remote interface must be private.
c. The remote interface must have “package access.”
d. All of the above
.
.
Question 56
When you include a try..catch statement in your code, which of the following is true?
Choose one answer.
a. The thrown object must belong to the class Throwable (or any of its subclasses).
b. The thrown object carries information about the exception.
c. The Throwable class represents all possible objects that can be thrown.
d. All of the above
.
.
Question 57
When you use preconditions in your code, which of the following is true?
Choose one answer.
a. A condition could occur in a subroutine that would cause an error.
b. Your code includes logic to check for correct values being input.
c. Robustness has been included in your code.
d. All of the above
.
.
Question 58
Which of the following is an API that developers can use to write XML messaging?
Choose one answer.
a. SAAJ
b. SOAP
c. XPATH
d. XSLT
.
.
Question 59
Which of the following must you consider in creating an rmi?
Choose one answer.
a. Use network connection operations
b. Pretend the remote object is local.
c. Use rmic tool to create stubs and skeletons.
d. All of the above
.
.
Question 60
Which of the following must you consider in creating an rmi reference?
Choose one answer.
a. Any object passed into a remote object must implement Serializable.
b. Any object argument from a remote object must implement Remote.
c. Include stubs and skeletons to perform deserialization.
d. All of the above
.
.
Question 61
Consider the following code:

public class IdentifyMyParts {
public static int x = 7;
public int y = 3;
}

Which of the following is a class variable?
Choose one answer.
a. X
b. Y
c. IdentifyMyParts
d. All of the above
.
.
Question 62
Consider the following code:

public class IdentifyMyParts {
public static int x = 7;
public int y = 3;
}

Which of the following is a variable?
Choose one answer.
a. X
b. Y
c. IdentifyMyParts
d. All of the above
.
.
Question 63
Examine this code:

IdentifyMyParts a = new IdentifyMyParts();
IdentifyMyParts b = new IdentifyMyParts();
a.y = 5;
b.y = 6;
a.x = 1;
b.x = 3;
System.out.println("a.y = " + a.y);
System.out.println("b.y = " + b.y);
System.out.println("a.x = " + a.x);
System.out.println("b.x = " + b.x);
System.out.println("IdentifyMyParts.x = " +
IdentifyMyParts.x);

Which of the following is the value output for IdentifyMyParts?
Choose one answer.
a. 3
b. 5
c. 6
d. None of the Above
.
.
Question 64
Which of the following is a keyword used in programming a Java interface?
Choose one answer.
a. Behavior
b. Implements
c. Method
d. Plugs
.
.
Question 65
What is the purpose of the Java “package” concept?
Choose one answer.
a. To organize unrelated classes and interfaces
b. To organize a limited number of classes and interfaces
c. To provide application infrastructure
d. All of the above
.
.
Question 66
You have created the following code. What is the output?
public class SomethingIsWrong {
public static void main(String[] args) {
Rectangle myRect;
myRect.width = 40;
myRect.height = 50;
System.out.println("myRect's area is "
+ myRect.area());
}
}
Choose one answer.
a. 2000
b. Does not compile.
c. Does not run.
d. Generates a “null exception” message.
.
.
Question 67
Examine this code:
String[] students = new String[10];
String studentName = "Jack Jones";
students[0] = studentName;
studentName = null;

Which object is eligible for garbage collection?
Choose one answer.
a. Students array
b. Jack Jones string
c. Both students and Jack Jones
d. None of the above
.
.
Question 68
Is the following interface valid?

public interface Marker {
}
Choose one answer.
a. It needs a Method.
b. It is a valid interface.
c. It needs a Class.
d. All of the above
.
.
Question 69
Consider this code:

public class ThreadSafeCounter {

private int count = 0; // The value of the counter.

synchronized public void increment() {
count = count + 1;

}

synchronized public int getValue() {
return count;

}

}

Which statement best describes the appropriate code?
Choose one answer.
a. Both the increment() method and getValue() have been correctly synchronized.
b. Neither synchronization is necessary.
c. Only the increment() method should be synchronized to prevent interruption by another thread.
d. Only the getValue() should be synchronized to prevent racing.
.
.
Question 70
Consider this code:

private static class CountDivisorsThread extends Thread {
CountDivisorsThread() {
setDaemon(true);
}
public void run() {
while (true) {
try {
Task task = blockingTaskQueue.take();
task.compute();
}
catch (InterruptedException e) {
}
}
}
}

Which statement best describes the appropriate code, if the queue is not empty?
Choose one answer.
a. Use a ConcurrentLinkedQueue for the task queue.
b. The Daemon is not necessary as it keeps the program from ending.
c. Remove the exception when using the LinkedBlockingQueue for the task queue.
d. This program works fine, especially if a thread pool is to be used.
.
.
Question 71
Consider the code:

out = new PrintWriter( new FileWriter("data.dat") );

What is the purpose of this statement?
Choose one answer.
a. By wrapping PrintWriter with File Writer, you get the ability to use File Writer methods.
b. The FileWriter is a stream object that knows how to send individual characters to a printfile.
c. Wrapping the FileWriter adds capabilities to the file output stream but still sends the data to the same destination.
d. All of the above
.
.
Question 72
Consider the code:

out = new PrintWriter( new FileWriter("data.dat") );

What does this statement do?
Choose one answer.
a. By wrapping the File Writer in a PrintWriter, you get the ability to write other data types to the file using the PrintWriter's print() and println() methods.
b. The PrintWriter class is being used as a "wrapper" for the FileWriter class.
c. Wrapping the FileWriter adds capabilities to the file output stream but still sends the data to the same destination.
d. All of the above
.
.
Question 73
Consider the following code:

public class ParseURL {
public static void main(String[] args) throws Exception {
URL aURL = new URL("http://quiz.com");
System.out.println("protocol = " + aURL.getProtocol());
System.out.println("authority = " + aURL.getAuthority());
System.out.println("host = " + aURL.getHost());
System.out.println("port = " + aURL.getPort());
System.out.println("path = " + aURL.getPath());
System.out.println("query = " + aURL.getQuery());
System.out.println("filename = " + aURL.getFile());
System.out.println("ref = " + aURL.getRef());
}
}

Which of the following is an Openstream accessor method?
Choose one answer.
a. getFile
b. getPath
c. getQuery
d. All of the above
.
.
Question 74
Consider this code:

java.net.CookieManager cm = new java.net.CookieManager();
java.net.CookieHandler.setDefault(cm);

What is the purpose of this code?
Choose one answer.
a. Create Cookie Handler
b. Create Cookie Policy
c. Create Cookie Manager and set CookieHandler
d. All of the above
.
.
Question 75
Examine the following code.  Then complete the question below.

<testresult score="82"><name>Joe Smith</name<subject>Math</subject>  </testresult>

What internet standard is being used?
Choose one answer.
a. HTML
b. XML
c. Both HTML and XML
d. All of the above
.
.
Question 76
Examine this code:
 
<?xml version="1.0"?>
<Article>
  <ArtHeader>
    <Title>Title of my (Docbook) article</Title>
  </ArtHeader>
  <Sect1>
    <Title>Title of Section 1.</Title>
    <Para>This is a paragraph.</Para>
 
</Article>
</Sect1>

How would you fix the code to compile and run?
Choose one answer.
a. Add stylesheet for Docbook.
b. Correct ending of Sect1.
c. Remove period from Para.
d. It is correct as written.
.
.
Question 77
Consider the following code:

public class ClassA {
    public void methodOne(int i) {
    }
    public void methodTwo(int i) {
    }
    public static void methodThree(int i) {
    }
    public static void methodFour(int i) {
    }
}

public class ClassB extends ClassA {
    public static void methodOne(int i) {
    }
    public void methodTwo(int i) {
    }
    public void methodThree(int i) {
    }
    public static void methodFour(int i) {
    }
}

Which method overrides a method in the superclass?
Choose one answer.
a. methodOne
b. methodTwo
c. methodFour
d. All of the above
.
.
Question 78
Consider this code:

public class ClassA {
    public void methodOne(int i) {
    }
    public void methodTwo(int i) {
    }
    public static void methodThree(int i) {
    }
    public static void methodFour(int i) {
    }
}

public class ClassB extends ClassA {
    public static void methodOne(int i) {
    }
    public void methodTwo(int i) {
    }
    public void methodThree(int i) {
    }
    public static void methodFour(int i) {
    }
}

Which method causes a compile-time error?
Choose one answer.
a. methodOne
b. methodTwo
c. methodFour
d. All of the above
.
.
Question 79
Consider the following interface code:

public interface House {
    /**
    * @deprecated use of open
    * is discouraged, use
    * openFrontDoor or
    * openBackDoor instead.
    */
    @Deprecated
    public void open();
    public void openFrontDoor();
    public void openBackDoor();
}

and its implementation:

public class MyHouse implements House {
    public void open() {}
    public void openFrontDoor() {}
    public void openBackDoor() {}
}

If you compile this program, the compiler complains that open has been deprecated (in the interface). What should you do before running the program?
Choose one answer.
a. Deprecate the implementation of open.
b. Suppress the warning.
c. Ignore the warning, as it is not an error.
d. Both A and B
.
.
Question 80
When you include a try..catch statement in your code, which of the following is true?
Choose one answer.
a. The thrown object must belong to the class Catchable (or any of its subclasses).
b. The thrown object carries information about the exception.
c. The Catchable class represents all possible objects that can be thrown.
d. All of the above
.
.