Network Transporting
Network Transporting

Network Transporting

Lead Author(s): Saylor Academy

Source: Saylor

Student Price: FREE

A Network Applications Development question pack by Saylor Academy.

This content is licensed under the Creative Commons Attribution 3.0 Unported License.

CC BY 3.0 - Saylor

Content on this site is licensed under a Creative Commons Attribution 3.0 Unported License .

Saylor Academy and Saylor.org® are trade names of the Constitution Foundation, a 501(c)(3) organization through which our educational activities are conducted.

Course Designer: n/a

Network Transporting Q1

When using DOM, an application can recover from an error using which of the following?

A

DTDHandler

B

EntityResolver

C

ErrorHandler

D

All of the above

Network Transporting Q2

Which of the following is an area in which DOM is weak in serialization of an XML?

A

File

B

OutputStream

C

Writer

D

All of the above

Network Transporting Q3

Which of the following will create an URLConnection object?

A

getInput Stream operation

B

getOutput Stream operation

C

openConnection method

D

All of the above

Network Transporting Q4

When a subroutine encounters an error during execution, what happens?

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

Network Transporting Q5

When you create a remote interface, you must follow which of these guidelines?

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

Network Transporting Q6

When you include a try..catch statement in your code, which of the following is true?

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

Network Transporting Q7

When you use preconditions in your code, which of the following is true?

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

Network Transporting Q8

Which of the following is an API that developers can use to write XML messaging?

A

SAAJ

B

SOAP

C

XPATH

D

XSLT

Network Transporting Q9

Which of the following must you consider in creating an rmi?

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

Network Transporting Q10

Which of the following must you consider in creating an rmi reference?

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

Network Transporting Q11

Consider the following code: public class IdentifyMyParts { public static int x = 7; public int y = 3; } Which of the following is a class variable?

A

X

B

Y

C

IdentifyMyParts

D

All of the above

Network Transporting Q12

Consider the following code: public class IdentifyMyParts { public static int x = 7; public int y = 3; } Which of the following is a variable?

A

X

B

Y

C

IdentifyMyParts

D

All of the above

Network Transporting Q13

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?

A

3

B

5

C

6

D

None of the above

Network Transporting Q14

Which of the following is a keyword used in programming a Java interface?

A

Behavior

B

Implements

C

Method

D

Plugs

Network Transporting Q15

What is the purpose of the Java “package” concept?

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

Network Transporting Q16

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()); } }

A

2000

B

Does not compile.

C

Does not run.

D

Generates a “null exception” message.

Network Transporting Q17

Examine this code: String[] students = new String[10]; String studentName = "Jack Jones"; students[0] = studentName; studentName = null; … Which object is eligible for garbage collection?

A

Students array

B

Jack Jones string

C

Both students and Jack Jones

D

None of the above

Network Transporting Q18

Is the following interface valid? public interface Marker { }

A

It needs a Method.

B

It is a valid interface.

C

It needs a Class.

D

All of the above

Network Transporting Q19

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?

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.

Network Transporting Q20

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?

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.

Network Transporting Q21

Consider the code: out = new PrintWriter( new FileWriter("data.dat") ); What is the purpose of this statement?

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

Network Transporting Q22

Consider the code: out = new PrintWriter( new FileWriter("data.dat") ); What does this statement do?

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

Network Transporting Q23

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?

A

getFile

B

getPath

C

getQuery

D

All of the above

Network Transporting Q24

Consider this code: java.net.CookieManager cm = new java.net.CookieManager(); java.net.CookieHandler.setDefault(cm); What is the purpose of this code?

A

Create Cookie Handler

B

Create Cookie Policy

C

Create Cookie Manager and set CookieHandler

D

All of the above

Network Transporting Q25

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?

A

HTML

B

XMl

C

Both HTML and XML

D

All of the above

Network Transporting Q26

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?

A

Add stylesheet for Docbook.

B

Correct ending of Sect1.

C

Remove period from Para.

D

It is correct as written.

Network Transporting Q27

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?

A

methodOne

B

methodTwo

C

methodFour

D

All of the above

Network Transporting Q28

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?

A

methodOne

B

methodTwo

C

methodFour

D

All of the above

Network Transporting Q29

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?

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

Network Transporting Q30

When you include a try..catch statement in your code, which of the following is true?

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