Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

some questions on J2EE test

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
D. JMAPI
E. CORBA

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, ");
out.flush();
String name = getNameFromDB();
if(name==null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Unable to get name");
}
out.println(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?

try{
Context ctx=new InitialContext();
ctx.createSubContext("com/sams/book");
}
catch(NamingException exe){
System.err.println(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.

Thanks
 
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic