File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes some questions on J2EE test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "some questions on J2EE test" Watch "some questions on J2EE test" New topic

some questions on J2EE test

kathy Tsui

Joined: Oct 08, 2004
Posts: 2
There may be up to three correct answers to the following questions. I'm not sure aboout them and come here to get your help.

1. if the business logic of an existing application is implemented using a set of CGI programs, which of the following Java
technologies can be used to implement the CGI programs as a Java-based solution?
A. Servlets
B. Enterprise JavaBeans
C. Screen Scrapers

2. In the doPost() method of a servlet below, assuming that getNameFromDB() returns NULL. Which of the following
statements are correct?

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out=response.getWriter();
out.println("Hello, ");
String name = getNameFromDB();
if(name==null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Unable to get name");

A. It will throw an IllegalStateException
B. It will throw a NullPointerException while serving a request
C. It will throw an InvalidStateException while serving a request.
D. It will throw a ServletException while serving a request.
E. It will not throw any exception.

3. Assume that the subcontexts com and com/sams already exist in the JNDI directory. Upon excuting the "try"
blocks below, which of the following events will result?

Context ctx=new InitialContext();
catch(NamingException exe){
A. The context com/sams/book and the subcontext sams/book are automatically created.
B. The context com/sams/book is suscessfully created.
C. The contet com/sams/book is created and the subcontext sams/com/book are automatically created.
D. NameAlreadyBoundException is thrown.
E. No changes occur in the directory system.

For question 1, I think answer is A; question 2, I don't know how the servlet get commited. I checked its API. it is said that if the Servlet is already commited, sendError() would throw IllegalStateException. For question 3, my answer is B.

I agree. Here's the link:
subject: some questions on J2EE test
It's not a secret anymore!