MCQ 4
MCQ 4
4.
package com.accenture.lkm.application;
@SpringBootApplication
public class Application {
public static void main(String [] args) { Error while deployment as Primary configuration is
SpringApplication.run(Application.class, args); not in………
}
}
//------------------------------------------------------------------------
package com.accenture.lkm.web.controller; @RestController
public class MessageController {
@RequestMapping(value= "/sayHi / {message}",
producer={ "application/json"},
method= RequestMethod.GET) public ResponseEntity<String>
getEmployeeById(@pathvariable("message") String
messageVar) {
return new ResponseEntity<String>("Message From
Controller": messageVar.Httpstatus.ok);
@SpringBootApplication,SpringApplication.......
5.
(!)A spring MVC application can have multiple child content only(!)
(!!) Child content belongs to DispatcherServelet Choose the
appropriate option from below
6.
identify the characteristics of Microservices [choose 2] Highly cohesive
Independently deployable
7.
Refer the below incomplete code for a Spring rEST based
application @RequestMapping(value = RequestMethod,MediaType,ResponseEntity,@Reques
"/students/updateStudent", method =___Line1__PUT, tBody
consumes = _____Line2____.APPLICATION_JSON_VALUE) public
_____Line3____<StudentBean>updatedStudent(____Line4____
StudentBean student) { StudentBean updateStudent = null;
//code goes here
10.
Choose a valid option from below that helps to auto the @EnableAutoConfiguration
database correction and... in Springboot
11.
In the digital era there are key success factors addressed by All of the above
mywizard Deveops. Pick the valid success factors.
12.
What are the features are possible to be availed through the
provisioning of Intelligent using myWizard DevOps? Highly Scalable, Manual Healing
13.
question is blur @SpringBootApplication, @RestController,
@RequestMapping, TEXT_HTML_VALUE
14.
It is required to secure the Spring MVC based application using
the following matrix by using Spring Security 4.x <intercept-url pattern=/saveStudent**
*/saveStudent*** -should be accessible to ADMIN, access="ROLE_ADMIN"/>
*/getStudentDetails*** -should be accessible to ADMIN, DBA
and USER <intercept-url pattern=/getStudentDetails**
Refer below the incomplete spring security coniguration <http access="ROLE_ADMIN, ROLE_DBA, ROLE_USER"/>
use-expression="false">
------Line1------ <!---- Other related configuration goes here---->
</http>
Assume ADMIN(ROLE_ADMIN),DBA(ROLE_DBA) and
USER(ROLE_USER)
configurated property within the AuthenticationManager tag
Choose from below a valid option to complete the above code
15.
Question is not visible @Autowired, @Autowired
16.
Refer the incomplete code given below
---------Line 1------------ public class EmployeeController { @RestController, @RequestMapping, ResponseEntity
@Autowired
private EmployeeServiceImpl employeeService:
---------Line 2--------- (value="emp/controller
/getDetails",.method=RequestMethod, GET,
produces=MediaType,APPLICATION_JSON_VAL
public------------Line 3--------------<List<EmployeeBean>>
getEmployeeDetails() {
return employeeServices.getAllEmployees();
}
Choose from below a valid option to complete the above code,
in the order as it appears.
17.
<http auto-config="false">
Refer the below Requirement to be implented using Spring <intercept-url pattern="/LoadReport"
Security, access="hasRole('CST_ADMIN','ADMIN_DBA)"
1) LoadSave should be accessible to CST_ADMIN, CST_DBA /><intercept- url
pattern="/LoadSave" access="hasRole('CST_ADMIN')"
2) LoadReport should be accessible to CST_ADMIN only Choose />
from below valid option to complete the above requirement </http>
18.
Which of the components are connected to myWizard DevOps. All of the above
19. <dependency>
which maven dependency is used to create a spring boot web <groupId>org.springframework.boot</groupId>
application <artifactId>spring-boot-starter-web</artifactId>
</dependency>
20.
refer the incomplete spring security configuration given below authorization-manager, authentication-provider,user-
<!--Assume that the HTTP element is configured properly--> sevices
<
<__Line1__>
<__Line2__>
<__Line3__>
< ………………."ROLE_MSD_USER" />
< …………………..="ROLE_MSD_ADMIN" />
< ………………….="ROLE_MSD_DBA" />
<__Line3__>
<__Line2__>
<__Line1__>
…………………………………………………….above code
21.
Refer the incomplete code given below:
@Controller
public class EmployeeController @ModelAttribute,@PersistenceContext,createQuery
{ Assume appropriate DAO injected by using appropriate
annotation.
public Map getEmployeeDetails(
){
Map map= new HashLinkedMap<>();
return map}
} DAO Layer
@Repository
@Transactional public class EmployeeDao{
private EntityManager entityManager; List
getEmployeeDetails(){
Query query = entityManager("Select E from Employee E"),
List entities=query.getResultList();
return beans;
22.
choose from below a valid option representing the proper name
of the default properties files in springboot Only (i) & (ii)
(i)application.properties
(ii)web.xml
(iii)appliction.xml
23.
refer the below incomplted code for a spring Rest based RequestMethod,MediaType,ResponsesEntity,@Reque
appliction stBody
@RequestMapping(value ="/students/updateStudent",
method=___line1____put,
consumes=___line2___APPLICTION_json_value
public____Line3____updateStudent
(_____Line4_____StudentBean student){ }
25.
Refer the code given below
@RestController public class CstController { restTemplate.delete("http://localhost:8089/App/cst/controller
@RequestMapping(value = /deleteCstBean/1002");
"/rest/controller/deleteCstBean/{id}", method =
RequestMethod.DELETE ,
produces = MediaTyper.APPLICATION_JSON_VALUE)
public ResponseEntity<CstBean>
deleteCstBean(@PathVariable("id") int myId) {
CstBean cstBean=null'
// Code goes here to initialize the CST bean
return new ResponseEntity<CstBean>(cstBean.
HttpStatus.OK);
}
}
Assume Application is deployed on port number 8089
and is accessible using the URL:
http//localhost:8089/App Assume the restTemplate is
holding the instance to the
org.springframework.web.client.RestTemplate Choose
from below a valid RestTemplate call to invoke the
above method
26. Which one of the HTTP verbs given is not POST
idempotent and not safe.
27.
Refer the incomplete code below: @Controller public
class CstController {
//Assume Request mapping code is written here
public ModelAndView
register(@ModelAttribute("custBean") CustomerBean
bean) throws InvalidNameException { @ExceptionHandler(value=InvalidNameException.class),$
//code goes here... (ErrorMessage}
throw new InvalidNameException();
return modelAndView;
} ____________// LineX
public ModelAndView
handleException(InvalidNameException
exception) {
ModelAndView modelAndView = new
ModelAndView();
modelAndView.setViewName("DisplayMessage"):
//Logical Name of the view to Navigate in case of error
modelAndView.addObject("ErrorMessage",exception);
return modelAndView;
}
}
DisplayMessage.jsp ========================
<center>
<h2>Exception Handler Page</h2>
<hr> Details of Exception:<br/>
__________________________________<!-- LineY -
Code to print exception details -->
</center>
Choose from below a valid option to fill in LineX and
LineY in the order as it appears to
complete the above code so that DisplayMessage.jsp
displays the error message when
InvalidNameException is thrown
28.
Refer the incomplete spring boot code given below:
package com.accenture.lkm; @SpringBootApplication, @RestController , @PathVariable
________________________
public class Application{
public static void main (String args[]){
SpringApplication.run(Application.class,args);
}
}
//-----------------------------------------------------------------------
---------------------------- package
com.accenture.lkm.web.controller;
___________________________
public class MessageController{
@Requestmapping(value="/sayHi/{message}",
produces={"application/json"},
method=RequestMethod.GET)
public ResponseEntity<String>
getemployeeById(________________("message")string
messagevar) {
return new ResponseEntity<String>("Message From
Controller:"+messagevar,Httpstatus.OK);
}
29.
Choose from below a valid combination of annotations
which is equivalent to @SpringBootApplication All 1,2 and 3
1)@Configuration
2)@EnableAutoConfiguration
3)@ComponentScan
30.
package com.accenture.lkm.application;
@SpringBootApplication
public class Application Move the Primary configuration to the root package
{ public static void main (String args[]){ "com.accenture.lkm"
SpringApplication.run(Application.class,args);}}
//-----------------------------------------------------------------------
----------------------------
package com.accenture.lkm.web.controller;
@RestController
public class MessageController{
@Requestmapping(value="/sayHi/{messege}",
produces={"application/json"},
method=Requestmethod.GET) public
ResponseEntity<string>
getemployeebyid(
@pathvariable("message")string messagevar)
{
return new responseEntity<string>("message from
controller:"+messagevar,httpstatus,OK);}
31.
Refer the incomplete code given below for a Spring @ResponseBody , @RequestBody
REST based application: @Controller Public Class
CstController{
@RequestMapping(value="/cst/controller/createCst",
method=RequestMethod.POST,
consumes=MediaType.APPLICATION_JSON_VALUE,
produces=MediaType.APPLICATION_JSON_VALUE)
_________________________
public CstBean
updateCstMember(_________________ CstBean
cstBean)
{
CstBean bean1=null;
//Logic goes here
return bean1;
}
}
Choose from a valid option in order as it appears to
complete above code.
32.
Refer the incomplete configuration for Spring Security <user-name="cst_dba" password="cst_dba"
given below: <authentication-manager> authorities="ROLE_CST_DBA"/>
<authentication-provider>
<user-service> <user-name="cst_admin" password="cst_admin"
<!-- Line1 --> authorities="ROLE_CST_ADMIN"/>
</user-service>
</authentication-provider>
</authentication-manager>
Assume CST_ADMIN Credentials are
:username:cst_admin password:cst_admin Assume
CST_DBA Credentials are :username:cst_dba
password:cst_dba Choose from below a valid option to
complete the above configuration to configure users
using
in-memory service
33.
Which of the following is/are the valid Content both (i) and (ii)
Negotiation strategies in Spring Boot ?
i) URL Extension Based
ii) URL Parameter Based Choose the most
appropiate option
34.
The annotation @RestController is equivalent to both (i) and (ii)
_______________
a) annotation @Controller
b) annotation @ResponseBody
c) annotation @RequestMapping
d) Both 1 & 2
35.
Refer the incomplete code given below for Spring post , dispCstLogin.html, cstSecureLogin
Security
CustomSecurityLoginPage.jsp
1 <form name='loginForm' action="<c:url
value='cstSecureLogin/' 2 User:<input type='text'
name='uname' > <br/>
3 Password:<input type='password' name='pwd" >
<br>
4 <input name="submit" type="submit"
value="submit" />
5 </form>
Configuration in Spring security's <http> element 1
<form-login
2 login-page="/____Line1_____" 3 login-processing-
url="/____Line2______" 4 username-
parameter="___Line3_____" 5 password-
parameter="___Line4_____" 6 authentication-failure-
url="/dispСstLogin.html?cst_Error=try
Assume dispСstLogin.html is mapped to display the
CustomSecurityLogin Page jsp us Choose from below a
valid option in the order as it appears to complete the
above code
36.
//Code to invoke the DAO addEmployee(employeeBean) @controller@Repository@Transectional
}
}DAO Layer ======= @Repository ______line3____
pulic class EmployeeDAO{ _____Line4_____
private EntityManager entity manager;
//Assume addEmployee(EmployeeBean employeeBean) is already coded
}
view
=====
<form:form___Line5___="empobj"method="GET"action
=""saveEmployee.html">
<!--Code goes here to enter the employee details--->
<input type = "submit"value="Register"/>
</form.form>
37. @requestmapping(values="cst/controller/
refer the incomplete given below for a spring Rest based application: getdetailsInRange/{p1}", method =
@restcontroller requestmethod.GET, produces = media
public class cstcontroller Type.APPLICATION_JSON_VALUE)
{
// line -1
public responseEntity<list> getDetails(
@pathvariable(*p1*)double data){ listlist=cstServiceimp1.getcstDetails(data);
//logic goes here ..... return new ResponseEntity<list>(list,httpStatus.OK);
}
}
Assume application is deployed on port 8080 and following URL is hit to
access the application using a
web BROWSER URL:
http://localhost:8090//app/cst/controller/getDetailsinrange/120 choose from
below a valid option to be placed at 'line1' to complete the above code so that
json response to the req.
38.
refer the incomplete code given below: .......class ------------------ ----line1----- ---
----line2-----(locations="classpath;com/accenture/lkm/resources/springservlet- @springbootapplication,@importresources,
xml') public class Application{public static void main(String args[]){/*code goes contentNegotiationManagerFactoryBean,
here*/}} XML configuration file to overrides the ContentNegotiation content-negotiation- manager
========================================================= assume
rest of files are coded appropriately choose from below a valid option to
complete the above code,in order as it appears
39.
package com.accenture.lkm.application;
@SpringBootApplication error while deployment as primary
public class application configuration is not in root packages
{
public ctatic void main (String args[]){
springapplication.run(application.class,args);
}
}
//---------------------------------------------------------------------------------------------------
package com.accenture.lkm.web.controller; @restController public class
messagecontroller{
@requestmapping(value="/sayHi/{messege}", produces={"application/json"},
method=requestmethod.GET)
public responseEntity<string>
getemployeebyid(
@pathvariable("message")string messagevar)
{
return new responseEntity<string>("message from
controller:"+messagevar,httpstatus,OK);}
40.
in spring rest which of the following triggers httpmessageconverter to convert @requestbody
the java object to json. xml,other MME type based on configuration? choose
most appropritae options
41.
refer thr incomplete spring security configuration given below @use-expressions="false",intercept-url,
<----line2-----pattern='/getdetails process=
ROLE_MSD_ADMIN,ROLE_MSD_DBA,ROLE_MSD_USER"/>
----LINE3-----------
http>
choose from below a valid option, in order as it appears , to complete the
above code
42.
Choose from Below the beans that are not inherited from the springMVC’s BeanPostProcessors and
parent context BeanFactoryPostProcessors
43.
refer the incomplete code given below
Controller ============ @Controller public class EmployeeController{
//Assume methos to display the view and do model binding already exists @ModelAttribute, @Valid, BindingResult,
@RequestMapping (value= "registration", method= RequesrMethodPOST) hasBindErrors,
Public ModelAndView register(--------line1-------{"employeeBean")-----line2----- ReloadableResourceBundleMessageSource
--- EmployeeBean employeebean----------line3-------result){ ModelAndView
modelAndView = new ModelAndView();
//your code goes here
return modelAndView;}} View
=========================
<form form method ="post" modelAttribute+"employeeBean" action
="registration.htm">
employee name<form.input path="name"/><br/> password <form password
path="password"/>>br/>
<input type="submt"value="register"> <spring----------line4--------
name="employeebeans"><h3>ALL errors</h3>
<form.error path=" " cssclass="error"/></spring------------line4--------
></form.form>
configuration file ==============================
<bean><!---assume rest of the configuration is written ---->
<bean id ='messagesource"
class= "org.springframework.context.support----------line5----------">
<property name ="basename"
value="classpath.com/accenture/lkm/resources/message"/>
<property name "defaultencoding" value="UTF-8"/></bean></beans>
note:assume employeebean is coded and messages properties is already
configured properly.
choose from below a valid option to complete the above code, in the order as
it appears
44. server.port,spring-boot-starter-
web,@SpringBootApplication,@RestController
refer the incomplete code given below
application properties ============= server.port, spring-boot-starter-
#Assume other properties are configured web,@SpringBootApplication,@Controller
_____Line1_____=8080
pom.xml ========
<!--Assume other dependencies are configured-->
<Dependency>
<groupid>org.springframework.boot</groupid>
<artifactid>___Line2___</artifactid>
<!---Depedency for web application-->
<dependency> Starter Class =============
____Line3_____
public class Application {
public static void main(String[]args) {
/*Code goes here*/
}
45.
Refer the incompleted code given below for spring Mvc controller @Controller , @Requestmapping ,value
____Line1____
public class GreetController{ ____-Line2___(___line3__="Home") public
modelandView Homepage(){
}
}
choose from below a valid option , in the order as it appears , to complete the
above code
46. 1- Easy to adapt
What are the features to be possible that can be availed through the 2- Highly Scalable
provisioning of Intellegent Automation using MyWizard DevOps 3- Looks Tremendous Buiness Value
4- Manual Healing
47.
Spring does not store the data in ____ instead stores in ____. Choose from requestScope,SpringModel
below valid option.
4- Request Method.POST,
@RequestParam("userName"),
@RequestParam("password")
49.
Which of the following statements is/are correct with respect to Spring MVC.
1. A Spring MVC application can have multiple child context. Both (1) and (2)
2. Child context belongs to DispatcherServlet. Choose the most appropriate
option.
50.
Jack is new to Spring MVC and wants to display home.jsp, when ever request
for the home.html is placed. Help jack to complete code given below.
Configuration file:
---------------- <!_ Assume other configuration is done properly_> prefix, suffix, setViewName("home"),
<bean addObject
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="__Line1__">
<value>/WEB-INF/jspViews/</value>
<property name="__Line2__">
<value>.jsp</value>
</property>
</bean>
Controller
----------- @Controller public class LoginController {
@RequestMapping(value="/home.html", method = RequestMethod.GET)
public ModelAndView getWelcomeMessage() {
ModelAndView mv = new ModelAndView();
mv.__Line3__;
mv.__Line4__("obj","Welcome!! "):
return mv;
}
}
home.jsp
---------- <html>
<h2>${obj}</h2>
Continuation...........
51.
Which of the following is used to translate the logical view name to physical ViewResolver
view name.
52.
Choose most appropriate option.
@RequestBody @Autowired, @PersistanceContext
Refer the incomplete code given below
Controller ============ @Controller public class EmployeeController {
_______Line1____
private EmployeeDAO employeeDao;
}DAO Layer ============= @Repository public class EmployeeDAO {
_______Line2_____
private EntityManagerFactory entityManagerFactory;
}
Choose from below a valid option to complete the above code in the order as
it appears
53.
Choose from below the beans that are not ingerited from the spring mvc's All bean are not inherited
parent context.
54.
Which of the following statement(s) is/are CORRECT with respect to Spring
MVC? both(i)and(ii)
(i) In an application there can be more than one web context
(ii) Web context belongs to whole application Choose the most
appropriate option.
55.
The Http verb which is Idempotent ans safe is __________________ Get
56.
What is the correct syntax to generate a drop down box All the above
57.
Assumingly we are using Spring's Validation framework. In order to display a <form:input path="firstName"
text field along with its error message(s), which of the following options will size="30"/><font color="red"><form:errors
you use to accomplish this? path="firstName" /></font>
58.
A handler method annotated with TRUE
@RequestMapping supports String as its return type.
State True or False 1. TRUE 2. FALSE
59.
Refer to the following statements :-
Statement 1 : A Command Class is called a FormBacking Bean. Statement 1 is True and Statement 2 is False
Statement 2 : This class also returns a ModelAndView Object.
Choose the most appropriate option:-
1)Statement 1 is True and Statement 2 is False
2)Statement 2 is True and Statement 1 is False
3)Both the statements are True
4)Both the statements are False
60.
Identify the right syntax to add data to a ModelAndView object and send to
the Controller. ModelAndView mv = new ModelAndView();
Choose two most appropriate options. mv.addObject("data",new SomeData());
ModelAndView mv = new ModelAndView();
mv.addObject("data",new SomeData());
new ModelAndView("data",new SomeData());
new ModelAndView(new SomeData(),"data");
63. <form:errors>
the ____ tag in sprng view page will help users view validation related errors
64.
the valid implementations of view resolver in spring MVC are: option 1 and 2
65.
in spring mvc the front controller uses handlerMapping implementaton to option 1
fgure out which controller class should process request.
66.
consider the below code:
optionA:myadmin-servlet.xml
<servlet>
<servlet-name>myadmin
</servlet-name>
<servlet-class>org.sprngframework.web.servlet.DispatcherServlet</servlet-
class>
</servlet>