Stuff the purple heart programmers cook up

L

Last Timer

Stuff the purple heart programmers cookup.

Topic: Java 2: Survey Author: Serban Popescu
What is the likely reason that the most important members contained in
the java.sql package, such as Connection, Statement, ResultSet and
Driver, are defined as interfaces instead of classes?




A Interfaces are easier to use.
B To make the platform independence easier.
C To act like a framework for the JDBC driver developers.
D To hide the specifics of accessing particular kinds of database
systems.
E It was a choice of the JDBC developers.


Topic: Java 2: Survey Author: Serban Popescu
What is most likely the output of the following sample of code?

public void sortTest()
{
byte [] b = new byte[ 15 ];
new Random().nextBytes( b );

System.out.println( Arrays.binarySearch( b, b[ 5 ] ) );
Arrays.sort( b );
}




A Displays the location of the fifth element in the byte array.
B Displays the fifth element in the byte array.
C The results displayed cannot be predicted.
D It fails to execute because an array of bytes cannot be sorted.
E Displays an array of 15 random numbers between -127 and 128.

Topic: Java 2: Survey Author: Chris Mc Devitt
The JDBC ResultSet is actually an interface java.sql.ResultSet.


Which of the following is a true statement regarding the implementation

of this interface?




A The Statement class returns an interface which must be implemented by
the programmer in order to use the ResultSet.
B The programmer must implement a local class called ResultSet in order
to use methods from the interface.
C The implementation is determined by the Statement class. The specific
implementation, which is JDBC driver dependent, is returned when
execute() is called.
D The actual implementation of the ResultSet interface is determined by
the Statement instance, the programmer calls getResultSetImpl() from
the Statement class to get it.
E The interface is implemented by the JVM so the programmer can simply
use methods from this interface.

Which one of the following variable types is associated with a specific

Java object?




A final variables
B instance variables
C global variables
D class variables
E local variables

In the following sample of code, the compiler complains about
InterruptedException.

public void someMethod()
{
....
Thread t = new SomeThread();
.....
t.start();
....
t.sleep( aWhile );
....
}

What most likely causes the compilation problem?




A The start() method declares it can throw an InterruptedException.
B The sleep() method is called after the start() method.
C The thread 't' is not declared as SomeThread.
D The exception is not caught inside the some Method()'s code.
E The sleep() method declares it can throw an InterruptedException.

What is the character encoding that Java uses to support
internationalization?




A The Thai Character Encoding.
B The Unicode character encoding.
C The ISO-Latin-1 subset of Unicode.
D The ASCII character encoding.
E The Tamil Encoding Standard

A common problem when writing programs that use multiple threads is
having two or more threads access a shared data item at the same time.


What mechanism does Java provide to help avoid this situation?




A The shared data item should be declared as static data.
B The shared data item should be accessed through a method call and the
method must be public.
C The first thread to gain access to the item must put a lock on it via
a synchronized block.
D The shared data item must be declared within at least one of the
threads attempting to access it.
E Access to the shared data item should be done through a method call
and any code manipulating the shared resource should be placed within a
synchronized block so that access to the resource is single threaded.

What standard Java API class should one use to store a list of
localized
strings?




A java.util.ResourceBundle
B java.util.ListResourceBundle
C java.util.LocaleStringBundle
D java.util.LocaleStringList
E java.util.PropertyResourceBundle

What is the purpose of the wait and notify mechanism?




A It is a thread synchronization mechanism.
B It allows objects to communicate.
C It makes the OO programming easier.
D It allows synchronization and communication between threads.
E It is used to increase the JVM performance.

What will a programmer do to define a bundle of localized resources?




A Use the ListResourceBundle class.
B Subclass either ResourceBundle class or provide a property file.
C Use the Locale class.
D Use a localized Dictionary class.
E Subclass either the Collator class or Format class.

When using the JDBC API the programmer will obtain a Connection object
from the DriverManager. A Connection object has a method called
PrepareStatement()which returns a PreparedStatement object.


Which of the following best describes this method?




A This method takes the SQL to be executed as a String and returns the
pre-compiled statement that is to be executed as long as the driver
supports pre-compilation.
B This method takes the SQL to be executed as a String and stores that
in a buffer with the DriverManager to be executed later.
C This method returns an empty PreparedStatement object that can then
be populated with the actual SQL that is to be run.
D This method initializes the database and is required prior to
executing any SQL statements.
E This method takes the SQL to be executed as a String and returns a
PreparedStatement object which should be used with all SQL queries.

What is most likely the difference between a Collection and a Set?




A There is no difference in terms of functionality.
B A Set can contain only subclasses of the Number class.
C A Collection contains only ordered elements.
D The Set interface models the mathematical set abstraction.
E Set is a Collection that contains no duplicate elements.


Which of the following statements will throw a NumberFormatException?

1. Integer.parseInt( "-30" );
2. Integer.parseInt( "300", 16 );
3. Integer.parseInt( "283", 8 );
4. Integer.parseInt( "3E9", 15 );
5. Integer.parseInt( "250s" );
6. Integer.parseInt( "250.99" );
7. Integer.parseInt( "+112" );
8. Integer.parseInt( "7AC9", 13 );




A 1,2,6 & 7
B 1.2,4 & 8
C 3,5,6 &7
D 1,2,6 & 8
E 3,5,6 & 8


JDBC is a Java API for executing SQL statements. JDBC provides a
standard
API for tool/database developers so that they can write database
applications using a pure Java API.

JDBC makes it most possible to:




A Write platform independent database applications.
B Process results after executing an SQL statement.
C Send SQL statements.
D Connect to databases.
E A, B, C and D are correct.
F B, C and D are correct.

Which of the following best describes the differences between a
Statement
object and a PreparedStatement object?




A The PreparedStatement object extends the Statement object and
therefore should be used with databases for which there is no JDBC
driver.
B The PreparedStatement object should only be used when there are no
parameters for the query, while the statement object should be used for
parameterized queries.
C For each SQL query sent to the database the Statement object will go
through a compilation/optimization phase whereas the PreparedStatement
only does this when directed to do so by a parameter.
D The PreparedStatement object is pre-compiled and optimized. The
PreparedStatement object supports parameterized queries while the
Statement is compiled with every call and does not support parameters
in the query.
E The Statement object is serializable while the PreparedStatement is
not.


Which are the Java classes that can most likely convert between Unicode

and the character encoding set supported by the Java 2 platform?




A InputStreamReader, OutputStreamWriter, String and Character.
B String and Character.
C The subclasses of Reader and Writer.
D Java does not have classes that perform such conversion.
E InputStreamReader, OutputStreamWriter, and String.


After executing this sample of code, which will be the most likely
number
of active threads?

public class ThreadGroupTest
{
public static void main( String[] args )
{
ThreadGroup tg = new ThreadGroup( "TG" );

for( int i = 0; i < 100; i++ )
{
Thread t = new Thread( tg, "T" + i );

t.start();
if( i%2 == 0 )
{
t.stop();
t = null;
}
}
System.out.println( tg.activeCount() );
}
}




A The number of active threads will be 100.
B The number of active threads cannot be determined.
C The number of active threads will be 50.
D The number of active threads will be 0.
E The number of active threads will be less than 50.


What is most likely the purpose of the following statement?

Reader r = new BufferedReader( new InputStreamReader( System.in,
System.getProperty( "file.encoding" ) ) );




A This statement writes characters to the console.
B This statement reads characters from the console.
C This statement reads characters from the console in the system's
character encoding.
D This statement reads characters from a file in the system's character
encoding.
E This statement reads characters from a file.

What is most likely the output of the following sample of code?

public void listTest()
{
List al = new ArrayList();
for( int i = 0; i < 100; i++ )
{
if( i % 2 == 0 )
al.add( new Integer( i ) );
}
List ll = new LinkedList( al );
for( Iterator lIt = ll.iterator(); lIt.hasNext(); )
{
System.out.println( lIt.next() );
}
}




A It displays the even numbers between 0 and 100.
B It displays the odd numbers between 0 and 100.
C It displays all numbers between 0 and 100.
D The compilation will fail because in Java the Iterator class does not
exist.
E An ArrayList cannot be copied in a Linked List. An exception will be
raised.

Which of the following import statements is in error?




A import java.*;
B import *
C import java.awt.Color;
D import java.awt.*;
E import java.util.Calendar;

SQLInput, SQLOutput and SQLData are interfaces used to:




A handle special SQL types.
B handle SQL queries.
C read, write and manage the custom mapping of SQL user-defined types.
D manage the update counts with a batch of commands.
E handle data retrieved from the database.


Topic: Java 2: Java Servlets Author: Chris Mc Devitt
A condition that may occur when a servlet is processing data and
getting
ready to send a response is the user may hit the Stop button on the
browser.


Which of the following is the correct flow in the servlet under this
condition?




A The servlet is interrupted with a signal and should cease
immediately.
B The servlet gets an exception when attempting a write. The servlet
should free its resources in a finally block when this exception is
thrown.
C The servlet is not notified that the client has disappeared. The
response is sent and the web server knows not to forward the response.
D The servlet knows that the client has disappeared only when
performing the write. The write throws an exception and the servlet
should end immediately.
E The servlet is interrupted with a signal and should send a status
code back indicating that it was interrupted.


Which of the following is not a valid state for an entity bean to be in

at any given time?




A No state: When the entity bean is in this state it has not been
instantiated yet.
B Pooled and suspended state: This is when the entity bean is in the
instance pool but its execution is suspended.
C Multithreaded state: This is any time that the entity bean has
initiated a separate thread of execution.
D Ready state: This is when the bean instance has been associated with
an EJB object and is ready to respond to method calls.
E Pooled state: This is when the entity bean has been instantiated but
has not been associated with an EJB object.

Topic: Java 2: Java Databases Author: Neal Ford
The developer is designing a large scale series of untrusted applets
that
must connect to JDBC databases.

What type of JDBC driver(s) provides the most flexibility in terms of
where the database can be located in relation to the web server?




A JDBC Type 3
B JDBC Type 3 and Type 4
C JDBC Type 1
D JDBC Type 2
E JDBC Type 4
F None of the JDBC drivers work with untrusted applets

Topic: Java 2: Enterprise JavaBeans Author: Chris Mc Devitt
Suppose two different clients call the same business method on the same

stateless session bean at exactly the same moment.


Which of the following accurately describe what happens within the
server?




A The EJB server prevents this from happening by serializing these
requests so that on the server it appears as if one request is received
before the other so there are no contention problems.
B The EJB server reads the SessionContext of the available instances of
the invoked session bean to determine which one should service which
client.
C The server associates an instance from the Method-Ready pool with a
given EJBObject and calls the business method that was invoked. It does
the same thing with a second instance. Each instance can not determine
the exact client that made the request.
D The EJB server will use a round robin method of determining which
instance of the bean should handle each request once the order is
determined the server creates the instance to handle the requests.
E The server will associate individual instances with each request and
will set the SessionContext making it possible for each instance to
obtain information about the client.

Topic: Java 2: Java Databases Author: Serban Popescu
Disabling the AutoCommit mode of the Connection interface:




A kills the connection with the database.
B does not allow the retrieving of results after executing a query.
C allows the application to decide when to commit statements.
D allows the application not to commit the transaction.
E prevents the execution of a query.

Topic: Java 2: Java Servlets Author: Chris Mc Devitt
Java servlets handle requests using the HTTP protocol. This is a
request/response oriented protocol.


When creating a Java servlet which of the following best characterizes
the relationship between the servlet and the HTTP protocol?




A Since the HTTP protocol is stateful the servlet needs to maintain
state variables that contain information about the users previous
requests.
B Your servlet will be a subclass of the HttpServlet class and will be
called by the web server when the server receives an HTTP request.
C The servlet is a class that runs within the browser and initiates
HTTP requests.
D The purpose of the servlet is to interpret the fields within the HTTP
header and then call a Java class to process the request.
E The servlet is called by the web server as the server receives HTTP
requests the servlet can be called in this manner because it implements
the HttpServlet interface.

Topic: Java 2: Enterprise JavaBeans Author: Neal Ford
The developer is writing an application using several stateful session
beans to handle connectivity to the database. Are there any special
considerations that have to be taken for beans of this type?




A The database connection object must be marked as protected so that
the container will preserve the connection between bean invocations.
B No special considerations must be taken.
C The database connection must be relinquished in the ejbStore() method
and restored in the ejbLoad() method.
D Care must be taken to ensure multiple threads cannot access the
database connection concurrently.
E Database connections must be relinquished in ejbPassivate() and
restored in ejbActivate().
F The client connection must be saved in the ejbPassivate() method and
restored in the ejbActivate() method.

Topic: Java 2: Enterprise JavaBeans Author: Neal Ford
You are writing a order tracking application where customers, sales,
and
inventory are the primary focus of the application. You are developing
an
EJB that encapsulates Customer information that must write records into
a
database using a combination of stored procedures.

What type of bean(s) should be used to accommodate this requirement?




A An Entity bean with bean-managed persistence
B A Stateless Session bean
C An Entity bean with container-managed persistence
D A combination of 2 Stateless Session beans
E An entity bean with CallableStatment persistence
F An Entity bean with a customized Deployment Descriptor

Topic: Java 2: Java Databases Author: Serban Popescu
The Blob and Clob interfaces are new built-in types added by SQL 3 and
are supported by JDBC 2.0. These interfaces are used to:




A represent binary large objects and character large objects.
B represent arrays.
C represent a SQL reference.
D represent large object data types.
E represent a SQL structured type.

Topic: Java 2: Enterprise JavaBeans Author: Chris Mc Devitt
When deploying an entity bean that uses bean managed persistence, which

of the following describes the two key components that need to be set
in
the deployment descriptor?




A There must be no container managed fields and the <persistence-type>
tag must be set to "Bean".
B The container managed fields must be present but empty and the
<persistence-type> must be set to "Bean".
C The container managed fields must have the server name and the
<persistence-type> must be set to "home".
D The <method-permission> component must have <role-name> set to
"everyone" and the <persistence-type> should be set to "class".
E The <reentrant> tag must be set to "true" and the <persistence-type>
tag should be set to "instance".

Topic: Java 2: Networking Author: Michael Morrison
On which port number should custom network communication be performed?




A a port number higher than 1024
B a port number higher than 0
C port 21
D port 80
E a port number lower than 1024

Topic: Java 2: Enterprise JavaBeans Author: Neal Ford
The developer is creating an application where the number of users will

be very high and the network traffic will also be very high. What type
of
bean will enable the container to most effectively cache bean instances

to promote fast invocation time?




A A database connection pool will allow any type of bean to respond
well to high volume situations.
B It doesn't matter, the container will treat all bean types the same
with regards of resource allocation, sharing, and invocation time.
C A stateless session bean.
D A Stateful session bean.
E An Entity bean with container-managed persistence.
F An Entity bean with bean-managed persistence.

Topic: Java 2: Networking Author: Chris Mc Devitt

What application technique describes the best way to ensure that a
connection opened on a socket is available as often as possible ?




A Use the constructor from the Socket class that allows one to register
a callback function to be called when the Socket goes down.
B Use the test() method, from the Socket class, this method returns
true if the Socket is alive, false otherwise.
C Application code should only assume that Socket connections are good
for a very short period of time. The application should close and
reestablish fairly often.
D Periodically attempt to write to the Socket and see if the write call
throws an exception.
E Use the setKeepAlive() method to turn SO_KEEPALIVE on. This will
allow the TCP layer to attempt to keep the connection alive.

Topic: Java 2: Networking Author: Chris Mc Devitt
When using an HttpURLConnection object to establish a connection with a
site, how do you tell if the page that you connected to issued a
redirect?




A Call the getURL() method and check the value of that.
B Call the connection.getHeaderField() and check to see if the location
is null.
C Call the connection.getHeaderField() with "location" as a parameter
to get the location field from the HTTP header, compare this with the
URL that was connected too.
D Call the getRedirect() method from the HttpURLConnection class and
check the return for null.
E Call the setInstanceFollowRedirects() with a value of false.
Topic: Java 2: Java Databases Author: Serban Popescu
A very important enhancement was added to the JDBC 2.0 ResultSet
interface, which is part of the JDK 1.2. What enhancement was added?




A Scrolling types
B Concurrency types
C Storing the ResultSet in an Array.
D Retrieving any type of Object
E Retrieving dates and timestamp objects.

Topic: Java 2: Java Servlets Author: William Wright
What technique or techniques can a servlet engine use to associate a
client session with a servlet request?




A Cookies or URL rewriting
B A hash table of host names
C A hash table of session IDs
D An object of type SessionMappingAdapter
E Cookies
Topic: Java 2: Java Servlets Author: Chris Mc Devitt
Which of the following best describes the mechanisms for having an
object
receive notification when it is added to or removed from the current
HttpSession?




A The object can implement the HttpSessionBindingListener interface.
The servlet engine calls the load() method of all objects that
implement this interface when session data changes.
B The object can implement the HttpSession interface and the notify()
method from this class is called by the servlet engine.
C The object can implement the HttpSessionBindingListener interface.
The valueBound() or valueUnbound() methods are called when the object
is added to or removed from the session.
D The object can register with the Servlet engine through a properties
file.
E The object can implement a notify() method, which will be called by
the servlet engine when the object is added to or removed from the
session.

Topic: Java 2: Java Servlets Author: Chris Mc Devitt
Which of the following best describes the differences between a GET
request and a POST request?




A In general POST requests are usually accompanied by a long query
string while GET requests are not.
B POST requests are used to perform explicit client actions GET
requests are not and consequently can not be bookmarked.
C GET requests are used when the browser needs to display graphic
images while POSTS are used to exchange text.
D GET requests are used when the browser needs to read data so the HTTP
request body is usually small whereas POST Requests send their data to
the server in the HTTP message body resulting in potentially larger
request bodies.
E GET requests are processed by the servlet engine while POST requests
are handed to a doPost() method in a servlet for processing.

Topic: Java 2: Java Servlets Author: William Wright
In the class HttpServlet, what does the default implementation of the
service() method accomplish?




A It parses the HTTP input and dispatches requests to the methods that
support them.
B It does nothing. It must be implemented by a subclass to support HTTP
requests.
C It initializes the servlet.
D It reads the HTTP input data into a file that can be accessed by the
servlet.
E It returns a success status code to the client and passes the request
to its subclass.
 
A

Andrew Thompson

Last Timer said:
Stuff the purple heart programmers cookup.
[...]
Is there a point, or are you just wasting bandwidth?

The OP forgot to mention they are currently sitting in a room doing
this test as part of a job interview/screening, but there is an
internetted computer there as well. The OP would appreciate some
answers 'real quick', so (checks watch) ..time's a wasting, get
to it Ryan, the answers are...? ;)
 
R

Ryan Stewart

Andrew Thompson said:
The OP forgot to mention they are currently sitting in a room doing
this test as part of a job interview/screening, but there is an
internetted computer there as well. The OP would appreciate some
answers 'real quick', so (checks watch) ..time's a wasting, get
to it Ryan, the answers are...? ;)
lol

Guess 'c'
 
L

Last Timer

Ah, some bleeding heart java programmers. It's not like there are not
enough java books and sun's java groups to answer the questions.
 
A

Andrew Thompson

Ah, some bleeding heart ..

Purple Heart, Bleeding Heart..

*Damn* them! All I need is an Ace of Spades and I've won!

[ And as an aside, if your posts made more - or any - sense they
might provoke more profound comments. Now stop wasting bandwidth with
your 738 lines of drivel and think of something interesting to post. ]
 
L

Last Timer

For Andrew the old hag:

How much did java programmers contribute to the tsunami relief?
NaN

How many java programmers does it take to rewrite a C program?
A class full of them

What happens to StarBucks if java programmers save enough money to buy
coffee there?
They will rename themselves PointerBucks

What happened to Java Woman?
She gave birth to Java Man, named him Jesus and flew to Sun.
 
A

Andrew Thompson

For Andrew the old hag:

(snip drivel) I want my money back.

Why don't you reserve further posts until you have ..
a) taken your medication
b) something to say that is interesting
c) something that relates to Java.

Others can waste further attention on you if they see fit.
I'm outta' this one.
 
R

Ryan Stewart

Andrew Thompson said:
Others can waste further attention on you if they see fit.
I'm outta' this one.
I'll jump in. Wouldn't the Starbucks/Pointerbucks be more suited to C
programmers? I really don't see how that applies to Java.

And really, why are you posting all this junk? If you're just a troll,
you'll make a name for yourself quickly.
 
L

Last Timer

Ryan said:
I'll jump in. Wouldn't the Starbucks/Pointerbucks be more suited to C
programmers? I really don't see how that applies to Java.

And really, why are you posting all this junk? If you're just a troll,
you'll make a name for yourself quickly.

You're asking for more:

Why Java uses semi-colon?

A full colon will be organ donation

What is java importing all the time?
It's the american way

What is an inner class?
It's a co-ed class

Why is the signature public static void main required?
Anything else would be a forgery

How many java programmers does it take to replace a light bulb?
None; the bulb is javacuum.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,820
Messages
2,569,723
Members
45,510
Latest member
ThaliaMaxi

Latest Threads

Top