Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

November 2, 2009

SCWCD ques

21 Which method is used to store file in the server ?

A GET
B PUT
C POST
D HEAD

Answer
B
A PUT method is used to store a file or data in the server. The request URI identifies the location in the server to store the file.
Answer
22 When a user clicks on a link in a page, which method will get invoked ?

A POST
B PUT
C GET
D HEAD

Answer
C
When the user types the request URL into the browser's location field or clicks on a hyperlink, the GET method is triggered. When the user submits the form with the method attribute as "GET" or without any method attribute, then also GET will invoked.
Answer
23 What method will get executed on clicking the following code.?





A GET
B POST
C HEAD
D PUT

Answer
A
See the explanation for the above answer.
Answer
24 Which character is used to separate the URI and query string ?

A ?
B &
C =
D ;

Answer
A
Choice A is correct. ? is used to separate the URI and query string. & is used to separate the name value pairs from each other.
Answer
25 What will be the output of the following code? Assume that all the variables are declared properly
String str= request.getDateHeader("Accept-Language");
out.println(str);

A Compiler error
B An IO Exception is thrown
C Null
D An IllegalArgumentException thrown

Answer
D
Answer D is the correct choice. If the header value cannot converted to date , then an IllegalArgumentException will be thrown. Since the header value is a String, it will throw the IllegalArgumentException.
Answer
26 Which of the following listeners will be called when a context is destroyed?

A HttpServletContextListner
B HttpSessionListener
C ServletContextDestroyedListener
D ServletContextListener

Answer
D
The contextDestroyed(ServletContexEvent) method of ServletContextListener is called, when a context is destroyed.
Answer
27 Which method is called when a context is initialized ?

A contextInitialize(ServletContextEvent)
B contextInitialized(HttpServletContextEvent)
C contextInitialized(ServletContextEvent)
D contextInitialized(SevletContext)

Answer
C
The contextInitialized(ServletContextEvent) method is called when a context is initialized.
Answer
28 Which of the following listeners will be invoked ,when a session is created?

A HttpSessionListener
B HttpListener
C HttpSessionAttributeListener
D HttpSessionActivationListener

Answer
A
Option A is the correct choice. B is incorrect because there is no such Listener. C is incorrect because HttpSessionAttributeListener deals with session attributes. D is incorrect because HttpSessionActivationListener will be invoked only when session is activated or passivated.
Answer
29 Which exception will be thrown, when a servlet is unavailable temporarily ?

A ServletException
B UnavailableException
C IOException
D UnAccessibleException

Answer
B
The UnavailableException will be thrown, when a servlet is unavailable temporarily.
Answer
30 Which interface is having method getSession() ?

A ServletSession.
B ServletRequest
C HttpServletRequest
D ServletResponse
E HttpServletResponse

Answer
C
The HttpServletRequest interface contains the method getSession().

No comments: