WCD1题库.docx
《WCD1题库.docx》由会员分享,可在线阅读,更多相关《WCD1题库.docx(21页珍藏版)》请在冰点文库上搜索。
![WCD1题库.docx](https://file1.bingdoc.com/fileroot1/2023-5/4/36c87779-4e26-45e1-9993-9f1e41bb2e70/36c87779-4e26-45e1-9993-9f1e41bb2e701.gif)
WCD1题库
1.Whichofthefollowingisreferredtoasastatelessprotocolandsupportsonlyonerequestperconnection?
A.Webapplication
B.WebsiteURL
C.URL
D.HTTP
2.WhichofthefollowingisacanonicalnamethatlocatesaspecificresourceontheInternet?
A.Webapplication
B.Website
C.URL
D.HTTP
3.IntheJ2EEplatform,themodel,viewandcontrollerresponsibilitiesareallottedtothedifferentelements.Oneoftheelementsisusuallyaservlet.Theservletdelegatesthehelperclassestocarryoutspecificactions,ratherthanaddressingtheminternally.Whichisthiselement?
A.Controller
B.View
C.Model
D.Component
3.YouareusingtheMVCparadigmtodividetheapplicationintothreedistinctrolesthathavewelldefinedresponsibilitiestowardseachother.Oneoftheelementscontainsthepartsoftheapplicationthatcanberenderedonanydeviceandcanbeperceivedbytheuser.Thiselementcanpasstheuserinterfaceactionstothecontrollerelement.Whichofthefollowingoptionswillyouuseinyourapplicationtodescribethiselement?
A.Modelelement
B.Viewelement
C.Controllerelement
D.Acombinationoftheseelements
4.Mandyneedstodesignawebapplicationforhisorganization.HedecidestousetheservletinthewebapplicationtorespondtoanHTTPrequestfromtheclient.Hefirstcreatesaform,create_form.do,toacceptinputfromtheuser.Heneedstomakesurethatwhentheuserselectsthesubmitbuttonontheform,thedatatobesenttoserveriscontainedinthebodyoftheHTTPrequest.Whichofthefollowingcodeshouldheuseintheformtoaccomplishthistask?
A.
B.
C.
D.
5Mandyneedstodesignawebapplicationforhisorganization.HedecidestousetheservletinthewebapplicationtorespondtoanHTTPrequestfromtheclient.Hefirstcreatesaform,create_form.do,toacceptinputfromtheuser.Heneedstomakesurethatwhentheuserselectsthesubmitbuttonontheform,thedatatobesenttoserveriscontainedintheURLoftheHTTPrequest.Whichofthefollowingcodeshouldheuseintheformtoaccomplishthistask?
A.
B.
C.
D.
6WhichofthefollowingHTTPmethodsisreservedforusewithaproxythatcanswitchtobeingatunnel?
A.HEAD
B.OPTIONS
C.TRACE
D.CONNECT
7WhichofthefollowingHTTPmethodsrequestfortheservertostoretheentityenclosedinthebodyoftheHTTPmessage?
A.HEAD
B.OPTIONS
C.TRACE
D.PUT
8Youareworkingonanapplicationthathasmultiplecomponents.Thecontrolneedstransferredfromonecomponenttoanothercomponent.Theinvokingcomponentshouldnotbeabletoproduceanyoutputofitsown.WhichmethodfromtheRequestDispatcherinterfacecanbeusedtoperformthetask?
A.request
B.include
C.response
D.forward
9Considerthefollowingcodesnippet:
CodeforUserInterface:
Login:
Password:
CodeforServlet:
importjavax.servlet.*;
importjavax.servlet.http.*;
importjava.io.*;
publicclassvalidateextendsHttpServlet
{
publicvoiddoPost(HttpServletRequestreq,HttpServletResponseres)
ThrowsServletException,IOException
{
res.setContentType(“text/html”);
PrintWriterout=res.getAWriter();
Stringz1=req.getParameter(“t1”);
Stringz2=req.getParameter(“t2”);
out.println(“”);
if(z1.equals(“User1”))
{
if(z2.equals(“password”))
{
out.println(“Welcometothewebsite”);
}
else
{
out.println(“InvalidPssword”);
}
}
else
{
out.println(“NoSuchuser”);
}
out.println(“
”);
out.println(“
”);
out.println(“”);
out.println(“”);
}
}
Whatwillbetheoutputoftheabovecode,ifusernameasUSER1andPasswordaspassword?
A.Welcometothewebsite.
B.InvalidPassword.
C.NosuchUser.
D.Thecodewillnotcompilesuccessfully.
10Whichofthefollowingistheruntimerepresentationofthewebapplication?
A.init
B.service
C.ServletContext
D.Servlet
11WhichofthefollowingisissuedauniquerequestandresponseobjectbythewebcontainerforeachHTTPrequestmappedtoagivenservlet?
A.init
B.service
C.ServletContext
D.Servlet
12.YouhavecreatedtheAddLeagueFormservletthatincludesasingleinitializationparametercalledseasons-listwiththevalueSpring,Summer,Autumn,Winter.Thisconfigurationobjectispassedtotheservletinstancebywayoftheinitmethod,whichissentbythewebcontainer.Howwillyouwritethecodeintheweb.xmlfiletoinitializetheseasons-listparameterwiththerequiredvalues?
A.
AddLeagueForm
sl314.view.AddLeagueFormServlet
season-list
Spring,Summer,Autumn,Winter
B.
AddLeagueForm
classes.sl314.view.AddLeagueFormServlet
season-list
Spring,Summer,Autumn,Winter
C.
AddLeagueForm
sl314.view.AddLeagueFormServlet
season-list
Spring,Summer,Autumn,Winter
D.
AddLeagueForm
sl314.view.AddLeagueFormServlet
Spring,Summer,Autumn,Winter
13.You,beingasoftwaredeveloper,needstodevelopawebapplicationforyourorganization.Youdecidedtouseservletstocreatethewebapplication.Youcreatedaform,AddEmpFormServlet.javatoaddthedetailsofthenewemployeesandcompiledit.Theclassfileisstoredunderthe/WEB-INF/classes/viewdirectory.Thedeploymentdescriptorfile,web.xml,storesthedefinitionoftheservlet,AddEmpFormServlet.Whatcodeshouldbewrittenintheweb.xmlfiletodefineAddEnpFormServletinit?
A.
AddEmpForm
view.AddEmpFormServlet
B.
AddEmpForm
AddEmpFormServlet
14.Youarecreatingawebapplicationusingservlets.Theapplicationrequiresthatapplication-specificdataissharedacrossindependentwebcomponents.Whichobjectcanbeusedtoimplementthis?
A.Servlet
B.ServletConfig
C.ServletContext
D.ServletContextListener
14Youarecreatingawebapplicationusingservlets.Youneedtoensurethatsharedapplicationdatamustbein-memorybeforeanyHTTPrequestsareexecutedonthewebapplication.Whichobjectcanbeusedtoperformthisinitialization?
A.Servlet
B.ServletConfig
C.ServletContext
D.ServletContextListener
15JamesisdevelopingawebapplicationusingStrutsframework.Forthis,heneedstoconfigurealloftheapplication-specificclassesinthestruts-config.xmlfile.Whichofthefollowingtaginthisfileconfiguresthesetofviewmappingbetweenthesymbolicnameoftheviewtothelogicalpathtotheview?
A.action-mappings
B.forword
C.action
D.struts-config
15WhiledevelopingawebapplicationusingStruts,youneedtocreateaStructscontroller.Forthis,youarerequiredtoextendtheStrutsActionbaseandimplementtheexecutemethod.WhichofthefollowingisthesecondargumentoftheexecutemethodandissuppliedbyStruts?
A.ActionMapping
B.ActionForword
C.ActionForm
D.Action
15WhiledevelopingawebapplicationusingStruts,youneedtocreateaStructscontroller.Forthis,youarerequiredtoextendtheStrutsActionbaseandimplementtheexecutemethod.Whichofthefollowingisthesecondargumentoftheexecutemethodandissuppliedbythewebcontainer?
A.ActionMapping
B.ActionForword
C.HttpServletRequest
D.HttpServletResponse
16Whichofthefollowingtagisusedtospecifytheinitializationparametersintheweb.xmlfile?
A.init-param
B.servlet
C.servlet-mapping
D.url-pattern
17WhichofthefollowingtagisNOTapartoftheweb.xmlfile?
A.servlet
B.action
C.param-name
D.param-value
18WhiledevelopingawebapplicationusingStruts,youconfiguredStrutsActionServletintheweb.xmldeploymentdescriptor.TheActionServletusesaninitializationparameter,calledconfig,tospecifythepathtotheStrutsconfigurationfile.Forthis,thefollowingcodeintheweb.xmlfile:
/WEB-INF/struts-config.xml
However,thereanerrorinthecode,Identifytheerrorandprovidethecorrectcode?
A.
config
/WEB-INF/struts-config.xml
B.
config
/WEB-INF
19.WhiledevelopingawebapplicationusingStruts,youarerequiredtoconfiguretheStrutsconfigurationfile,struts-config.xml.Youhavetodeclaretwoforwardentries,successanderrorwithinthe/admin/add_leagueaction.Forthispurpose,thefollowingcodeinthestruts-config.xmlfile: