0% found this document useful (0 votes)
2 views

Java Full ??

Uploaded by

fibeti7925
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Java Full ??

Uploaded by

fibeti7925
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

1.

ANS: B

Refer the code given below. <bean id="library" class="com.accenture.lkm.library">


Class Library <constructor-arg>
{ Private Book book ; <bean class="com.accenture.lkmBook">
Public Library(Book book){ <constructor-arg value="book1"><constructor-arg>
This.book = book;} </bean>
} </constructor-arg>
</bean>

2.
ANS:B
Consider the code
Package com.accenture.lkm; Employee Address:Bangalore-Maharasthra
@Component(“address”)
Public class Address{
//common word (“Hyderabad- Telangana”)//
//common word (“Bangalore-Maharasthra”)//

3. ANS:A
Package com.accenture.lkm;
@Component(“employee”) /// common @Autowired,@Qualifier(“room1”),com
word(@Autowired,Gettors and Setters,UITester
_____Line1_____ _____Line2_____
_____Line3_____ House,room1,room2

4.Select correct options to refer a Spring ANS:A,D


configuration file inside aa package? Choose2
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("com/accenture/lkm/resource/my_
springbean.xml");

ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("classpath:com/accenture/lkm/reso
urce/my_springbean.xml");
Refer the Spring configuration code gievn
below:
1 @Configuration ApplicatonContext ctx=new
2 public class AppConfig { AnnotationConfigApplicationContext(AppConfig.class); Address
3 @Bean("address") address=(Address) ctx.getBean("address");
4 public address createAddress( ) {
5 Address address = new Address( ) :
6 return address ;
7}
8}
Identify the correct code to create spring
container object and get the address object
injected Choose the most appropriate option

6.Choose from below…..specific ANS:B


EntityManagerFactory and Transaction
Management LocalContainerEntityManagerFactoryBean

7.
1 @Entity ANS:A
2 public class CustomerEntity{
3 @Id @Modifying
4 private int cid; @Query("delete from CustomerEntity & where k where
5 private String cname; k.credit*cname)
6 private double credit; int delete @Param(credit) double credit
7 // getter and setter methods

Choose the valid implementation of the delete


query to delete customers who has credit less
than a particular value.

8.
Which of the following is/are CORRECT with ANS:B
respect to Spring transaction methods?
(i) If a method throws Only(i)
runtime/unchecked exception, then
rollback will be triggered implicity
(ii) (ii) If a method throws checked
exception, then rollback will be
triggered implicitly Choose the
most appropriate option
9.
1 ANS:A
2
3 @Transaction(value = "txManager", propogation =
4 Propogation.REQUIRES_NEW)
//Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean
employeeBean, DepartmentBean departmentBean) throws
Exception {
6 int result = 0;
7 int deptId =
employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId +
employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }

10.
Which of the following statements is/are CORRECT with respect
to JSP? both (i) and (ii)
(i) Default scope of a variable is page
(ii) Session scope variable will be available in all JSP files if it is
accessed in a single session
(iii) JSTL codes are placed inside service() method of
translated servlet Choose the most appropriate option

11. ANS:A
From the Following identify two INCORRECT statements about I and ii only
ServletConfig Object
(i)it is not created for each servlet during servlet initialization (ii)it
will be available to all servlets of an application
(iii)Its lifetime ….object is destroyed
(iv)one object per servlet class

12.
Which object is created by web container for each Servlet during ANS:B
servlet initialization? ServletConfig
13.
Mr.john has been assigned the task of creating a servlet filter to ANS: A
log IP address of the computers ……servlet filters in web.xml file

14.
Blessie is a web developer wants to create a wep pageis a web
developer wants to create a web page which always lands in
portal.accenture.com, whenever user hits on welcome button response.sendRedirect("https:/portal.accenture.co
in index.html given below: index.html ----------------------- m");
MyServlet.java ---------------------------
@WebServlet(urlPatterns="/MyServlet) public class MyServlet
extends HttpServlet{ public static final long serialVersionUID = 1L;
public myServlet(){ super(); }

15. A) To delete the session attribute we can call


When you want to remove the user data from sessions, what all public void removeAttribute(String Name)
the various options available in JSP? [Choose 3]. B) By invoking public void invalidate()
C) in web.xml file use<session-
timeout>15</session-timeout>
16.Sadana wants to share the common database data throughout ANS:C
the application,Help her to identify the appropriate code to
achieve this task? <%
String username = (String)
application.getAttribute("dbname");
%>
17.
<%
<%@page language="java" contextType = "text/html:charset=ISO- String companyName = "Accenture"; String
8859-1" pageEncoding = "ISO-8859-1"%> projectName = "ABC";
String location = "HYD";
<!DOCTYPE html> %>
<%= companyName %>
<html> <%= projectName %>
<%= location %>
<head>

<meta charset="ISO-8859-1">

<title>Sample</title>

</head>

<body>

<%--Add JSP Script here-->

</body>

</html>

Miss Linda has been asked to design a JSP page to display


company name, project name, location using JSP scripting
elements such as expression and scriplet tags.

18.
1
Refer the folowing JSP pages
Header.jsp:
<%@ page language = "java" contentType="text/html; charset =
ISO-8859-1" pageEncoding = "ISO-8859-1" %> <!DOCTYPE html
PUBLIC "//W3C//DTD HTML 4.01 Transitional//EN"
"HTTP://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset =
ISO-8859-1">
<title> insert title here </title>
</head>
<body>
<h2> <font color="blue"> This is content of Header </font> </h2>
</body>

</html>
Footer.jsp
<%@ page languages = "java" contentType = "text html; charset =
ISO-8859-1" %>

Half question pending

19.
Refer the incomplete code given below:
package com.model; @ContextCOnfiguration(locations="/com/resource
public class Author{ s/my_springbean.xml")@Test
public Authore(){
System.out.println("author");
}
} Below configuration is available in the file located at
/com/resources/my_springbean.xml package come.test;
@Runwith(SpringJUnit4ClassRunner.class)
____Line1____
public class TestAuthorClass{
@Autowired private Author author;
____Line2___
public void testAuthor()
{ Assert.assertTrue(author!=null);
20.
Which of the following is/are correct statement(s) with respect
to spring test? only (i)
(i) @DirtiesContest is used to mark the context dirty so
that it can be closed
(ii) (ii) @ContextConfiguration can only point to Spring
XML..... Choose the most appropriate option.

21. System.setProperty(“spring.profiles.active”,”mypro
refer the code given below file”);
@Component
@Profile(“myprofile”) Class product{ }
Choose from the below a valid option to activate the profile
“myprofile”

22. ANS:A
John has created a properties file below: @Component Public…
config.properties @Value… Private int customer;
customerName: James @Value(…”) Private String Coustomer Name}
CustomerId: 1009090
Choose from below a valid option to inject values in Customer @Componet public class Customer{
bean from confiig.properties file @Value("${customerID}") private int customerID;
@Value("${customerName}") private int
customerName;

23. ANS:
Which of the following is correct with respect to spring? Only (ii)
(i)@Configuration is used to declare a XML files Spring
configuration
(ii)@componentScan is used to scan stereotype annotation
24.
Which of the following statement(s) is/are CORRECT?
(i) JVM Supports IOC option (ii) is correct
(ii) Spring container manages the instance of the beans
mentioned in configuration and provides them back to code
when needed
25.
Refer the code given below. List<EmployeeEntity>findBySalaryBetweenOrderBy
@Entity Public class EmployeeEntity{ SalaryDesc(Double param1, Double param2)
@Id;
private int employeeId;
private String employeeName; private Double salary;
//Getters and Setters are coded }
26.
Refer the code given below
@Entity public class EmployeeEntity{
@Id
private int empId;
private String name;
private double salary;
//getter and setter methods }
Choose the valid implementation of the Update query to update
employee salary, using Spring JPA Data.
27.
Which of the following are with respect to Spring transaction Both (i) &(ii)
propagation types:
(i) propagation type Propagation.REQUIRED starts a new
transaction, if a method is provided from another
method and a transaction does not exist.
(ii) (ii) propagation type Propagation.REQUIRED_NEW
starts a new transaction, if a method is invoked from
another method and a transaction already exists.
Choose the most appropriate

28.
CORRECT with respect to JSP? ANS: A
(i) Default scope of a variable is request Both (i) and (ii)
(ii) Application Scope variable will be available in all JSP
files irrespective of session …
(iii) (iii)JSTL codes are not placed inside
services()method

29.
Choose from below the CORRECT statement about Autowiring. Autowiring requires setters or constructors in bean
classes

30. RegistrationServlet extends HTTPServlet


From the following identify the correct hierarchy of servlets HttPServlet extends GenericServlet GenericServlet
assuming you are required to create a registration servlet to implements Servlets
process registration request.
31.
Which is an Abstract class which provides the basic
implementation of Sevlet interface except Service method? Generic Servlet

(Or)

which provides the basic implementation of Servlet interface


except

32.

From the following tables match the JSP implicit objects given in 1 - ii 2 - i 3 - iv 4 – iii
table A with APIs in sevlets package given in table B.
Table A Table B 1. OUT - JSPWRITER 2. APPLICATION-
1) out i) ServletContext SERVLETCONFIG 3. EXCEPTION -
2) application ii) JSPWriter THROWABLE 4. PAGE - OBJECT
3) exception iii) Object
4) page iv) Threwable

33. ANS: C
Incorrect statement about JSR-330 annotation JSR-330 annotations can not beuesd along with
Spring framework annotations

34.
Assume that class “Employee” is created with property “empid”
and its setter method. Refer the spring configuration given below
1
bean id =”emp” class=”com.Employee”> Employee object
///applicationContext///
35. classes, @ActiveProfile
(Option was not visible properly spelling may be
Refer the below incomplete code for a test class different)
1 @RunWith(SpringJUnit4ClassRunner.class)
2 @ContextConfiguration(__________ = MyConfig.class)
3 __________________(profiles = "myProfile") 4
public class TestSpringCustomClass (
5 @Autowired
6 private Employee employee:
7 // test cases goes here
8}
Choose from below a valid combination to complete the above
code in the order as it appears

36.
Refer the code given below:
@Entity findByPublisherType(String pType)
class BookEntity{
@ld private int bookld;
private String title;
private String authorName;
private String publisher Type;
// getters and setters
}
Choose from below the valid option to retrieve the books based
on given publisher type by using Query Method Approach

37.
Refer the JSP code below and predict the output
<body> Book Id: 2 publish Year: 2001
<h3>
<%!
int bookld = 1;
int publish Year = 2000;
public int incrementBookId(int bookId) {
return bookld++;
%>
<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <%= bookld %> </h3>
<h3> Publish Year: <%= publish Year %></h3>
</body>

Predict the Output.


38.

Which of the following statements is/are CORRECT with respect


to JSP?
(i) Default scope of a variable is application
(ii) (ii) Session scope variable will be available in all JSP both (i) and (ii)
files if it is accessed in a single session
(iii) (iii) JSTL codes are placed inside service() method of
translated servlet Choose the most appropriate
option.
39.
When Servlet destroy() method will be invoked by Servlet 1) When you make any change in the servlet class
Container? [Choose 2] and same
2) When you stop the server, destroy method of all
existing servlet objects all be invoked

40.
Refer the code given below
package com.model;
@component("prodObject") @ActiveProfiles(profiles="myorderProfile")
@Profile("myProdProfile")
public classs Product {
private int productid;
private String productName;
}
package com.model;
@component("orderObject")
@Profile("myOrderProfile")
public classs Order {
private int orderId;
private String orderDetail;
} choose from the below the valid option to activate ....

41.
Refer the incomplete code given below:
@Component
class Customer( _____ @Value("#(cartObj")
private Cart cart;
}
Assume instance of the Cart is managed by
Spring Container ________
Choose from below a valid SpEL to inject the cart object in
Customer bean;
42.
_____Line 1_____
class Customer{ private int customerId; @Component,@Autowied,@Coponent,@Configur
_____Line 2_____ ation,AnnottionConfigApplicationContext
private Address address; }
______Line 3_____
class Address{ public Address(){
------ ------ -------

43.
Which of the following are stereotype annotations? [Choose 2] @Component ,@Sevice

44. ANS: A
/springormdemos”/> DriverManagerDataSource,
Id-“cst_entityManagerFactory” LocalContainerEntityManagerFactoryBean,@repos
class=*org.springframework.com… / itory,@Auto f
// dataSource , JpaVendorAdapter”
Class=”org.springframework.orm.jpa.vendor.hibernate.jpavendor
adapter

45.
Refer the incomplete code given below:
ANS: C
<beans> @Repository,@PersistenceContext,@Transactional
(value="txConfiguration public class")
<!--Assume rest of the configuration is written-->

<tx:annotation-driven transaction-manager="txManager"/>

<bean id="txManager"class="org.springframework.orm.jpa.jpa">

<property
name="entityManagerFactory"ref="cst_entityManagerFactory">

</bean>

</beans>

Line 1

public class EmployeeDAolmpl implements EmployeeDAO{

Line2
private EntityManager entityManager;

Line3

public Integer addEmployee(EmployeeBean employeeBean)

Integer employeeID = 0;

return employeelD;

46.
Consider the code given below:

package com.accenture.ikm;

public class Employee( private List<String>hobbies;

) Employee 2 Hobbies : [Playing Cricket


Watching Movies
<beans>

<bean id="employee"class="com.accenture.ikm.Employee">

<property name="hobbies">

<list>

<value>playing cricket </value>

<value>watching Movies</value>

</list>

</property></bean></beans>

public class UITester{

public static void main(String args[]){

not visible further question


47.
Refer the incomplete code below
package com.accenture.ikm; @Value("=(myjob)"1 @configuration
public class job @Bean @Beanvalue ="myjob")
{
private int jobid; //getter and setter
}
public class person{
private String[] skills;
--------Line1-----------
private job job;
person(String[] skills){ } //getter and setter
}
Refer the Springconfig java class below
------------------Line2-------------------
public class Springconfig(

48.

1
2 @Transaction(value = "txManager",
3 propogation =
Propogation.REQUIRES_NEW)
@Transactiona(value="txManager",rollbackFor=InvalidDummyException.class)
public Integer addEmployeeAndDepartment

4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean
employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0;
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }

49. getLastAccessedTime(
Which method is used to retrieve the recent access time of a request by user
by session?

50. i & iii


Komal's task is to create a customer report on daily............ everyday when she
generates a report help her to identify...

task.
i.
<% java.uti.Date date = new java.util.Date();
out.print(date);
%>

ii.
<%
java.uti.Date date = new java.uti.Date();
%>

Iii.
<%=date;%>
<% java.uti.Date date =new java.uti.Date(): out.print(date);
%>
<%date%>

51.
Book Servlet
Refer the code below:

Web.xml

<web-app>

<servlet>

<servlet-name>Book</servlet-name>

<servlet-class>com.accenture.BookServlet</servlet-class>

<load-on-startup>0</load-on-startup>

</servlet>

<servlet>

<servlet-name>Magazine</servlet-name>

<servlet-class>com.accenture.MagazineServlet</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

</web-app>

52. ANS: B It is used to close and Load


………………about @ DiritesContext annotation. the application context once again for
other …
53.
Which of the following is correct statement with respect to Spring test @DirtiesContext

54.
Miss Ashrey has been asked to add headers and footers while designing login <jsp include page="Header.jsp">
page and homepage in jsp. from the following options help her to identify the <jsp param value="userName"
right tags in JSP so that headers and footers are consistent in web pages. name="${name}"/>
Moreover she has to display username captured in the login page in headers </jsp include>
across at pagesheaders and footers ate html pages named Header.jsp and <jsp include page="Footer.jsp">
footer.jsp </jsp include>

55. ANS:B
which lifecycle method of jsp is invoked by the container to perform the _jsp service
actual task also the method is invoked by the container each ….

56. Answer :- B
Farhan wants to write a code to add 2 numbers and return the result……….
……………………………………….. JSP scripting element.

57. Answer :- B) Both (i) and (ii).


Which of the following statements(s) is/are CORRECT with respect to JSP?
i. Request Scope variable………………………………………
ii. ii. RequestDispatcher…………………………………………..

58. classes, @ActiveProfiles


Refer the below incomplete code for a test class
deWith(SpringJUnit4ClassRunner.class)

59. A & B (A) Use @Autowired at LineX


Public class customer { and (B) Use @Autowired at LineY
Private cart ……………………..
……………………………………..
……………………………………..

60.
Which of the following is CORRECT with respect to propogation type
Propogation.REQUIRES_NEW?
(i) For a method, begin a new transaction always Option-(i)
(ii) If a method is invoked from another method and a transaction
exists, then the same transaction is used. Choose the most
appropriate option
61.
Assume that class "Employee is created with property "empld" and its setter
method.
Refer the spring configuration given below. 1
1 <bean id = "emp" class = "com.Employee">
2 <property name = "empId" value = "John">
3 </bean>
How many Employee objects will be created if the below code executes
successfuly in a main method?
Assume that "context" referes to spring container ApplicationContext
1 public static void main(String[] args) {
2 // code for ApplicationContext creation goes here
3 Employee emp1 = (Employee) context.getBean("emp");
4 Employee emp2 = (Employee) context.getBean("emp");
5 Employee emp3= emp1;
6}
Use the most appropriate option

62.

From the following identify TWO INCORRECT statements about Servlet Coding
i and ii only
objects.

i) It is not created for each servlet during servlet initialization.

ii) It will be available to all servlets of an application.

ii) Its lifetime is until the servlet class object is destroyed.

iv) One object per servlet class

63.
Raghav added following query in orm.xml file @Query(name="getPatientData")
List getPatientsData();
<named-query name="getPatientsData">

<query>select p.pName,p.appointmentDate from patients


p </query>

</named-query>

Select the correct methid declaration in DAO interface.


Refer the patients class and patients table.
64. @Modifying is not used on the method output should return
Raghav has added a method to update the details of the the string data which i.. the updated appointment time.
patients as below public interface PatientsDAO

{ @Query(name="updateQuery1")

int updateAppointmentSlot (Patients patients, String new


Appointment(Time);
But he getting exception as "DML operation is not
supported" What went wrong?

65.

Raghav added the following methods in Service and DAO addPatientInDAO() method always exceutes in a new
implementation classes to add paitent's information in db. transaction rather than the interface started in service layer of
addPatientInService() method.
//service implementation

@transactional(propagation=Propagation.REQUIRED)
Integer addPatientInService (Patients patient)

} //calling DAO method

//DAO implementation

@transactional(propagation=Propagation.REQUIRES_NEW)
Integer addPatientInService(Patients patient)

{ //implementation

}
what is the behaviour of the addPatientInDAO() method?
<web-app>
66. <filter>
Mr. john has been assigned the task of creating a servlet <filter-name>...</filter-name>
filter to log IP addresses of the computers from which the <filter-class>...</filter-class>
request originate. help him from the follwing options to </filter>
identify the correct order of tags meant for servlet filters in <web-mapping>
web.xml file.(Option is not Visible but answer is correct. <filter-name>...</filter-name>
just cross check in exam) <urt-pattern>...</urt-pattern>
</filter-mapping>
</web-app>
67.
which of the following is CORRECT with respect to spring
transection propagation
1) propagation type Propagation REQUIRED starts a both(1) and (2)
new transection ,it a method is involved another
method and a transection does not required.
2) propagation type Propogation.REQUIRED_NEW
start a new transaction. If a method is involved
from another method and a transection already
exists choose most appropriate option
68.
Peter wants a method to add 2 numbers and return the <%!
result. He also wanted to place it inside the service public int add(int num1, int num2) { return num1 + num2;
method. Help him to select the appropriate JSP scripting. }
%>
69.
Sadana wants to share the common database data <%
throughout the application. Help her to identify the String userName = (String)application.getAttribute("dbname")
appropriate code to achieve the task.
%>

70.
Miss Monica has given login request to Translation, Compilation, Instantiation, Service and Destroy
EventmanagementApp. The app displays a JSP page to
prompt her to enter the username and password. Identify
the phases of JSP page it goes through until the response is
generated in right order

71.

Which of the following is/are CORRECT with respect to only (i)


Spring transaction methods?
(i) If a method throws runtime/unchecked
exception, then rollback will be triggered
implicity
(ii) (ii) If a method throws checked exception,
then rollback will be triggered implicitly
Choose the most appropriate option
72.
Which object is created by web container for each Servlet ServletConfig
during servlet initialization

73. <bean id="messageSource" class="org


springframework.support
rohit wants to externalize the validation error messages.
So, he defined the messages in <property name="name"
'com/accenture/lkm/resoruces/messages_en.properties value="classpath\com\accenture\lkm\resources\messages_en.
files'.Help rohit to configure the MesageSource beam in properties"/> </bean>
the context file by choosing a valid option from below
74.
A) Configure<context:component-scan base-
Rohit deployed the application in the Apache Tomcat package="com.accenture.lkm.dao"/> in the root context
Server. But he got an exception as confifuration
"org.springframework.beans.factory.
NoSuchBeanDefinitionException:No qualifying vean of C) Configure <mvc:annotation-driven/> in the child context
type [com.accenture.lkm.dao.PruchaseDAO]". Choose configuration
from below valid options to succesfully execute his
application
75.
Rohit wants to display all the validation error messages in <form:form method="POST" modelAttribute="bean"
purchase jsp. Help him to display those messages at the action="store.html">
bottom of the page. Choose from below a valid option. <table border="3">
Asssume the below taglib directives are added in the <!--Assume form elements are mentioned appropriately -->
jSP……………….. </table>
……………………………………. <spring:hasBindErrors name="bean">
……………………………………………………

76.
Rohit wants to validate the quantity entered by the Add @Range(min=1, max=10)anotation in the Bean class The
customer as mentioned in requirement 2. Choose from the request handler method should include @Valid to
below valid option.[Choose 2] @ModelAnnotation parameter

77. <bean class="org.springframework>


Rohit wants to navigate to success.jsp page on successful <property name="prefix">
submission. Assume he wrote a handler method to return <value>/WEB-INF/jspViews/</value>
ModelAndView with logical view name as success. He </property>
needs to configure a View Resolver bean in child <property name="suffix">
configuration file to resolve the logical view name.Choose <value>jsp</value>
from below a valid option </property>
</bean>
78.
Rohit wants to create a request handler method in Create a request handler method in the controller to map the
controller that can handle customer request and send the request using @RequestMapping annotation and return the
response back to the response back to the customer. Help ModelAndView object.
rohit to achieve this with a valid option given below
79.
Rohit wants to auto populate the items available for the <form:select path="items">
selected SportsType to the respective drop-down box. <form:option value="label="select"/>
Assume he defined the respective method in the controller <form:options items=$(itemsList)"/>
which can return Map. Rohit is supposed to bind the key as </form:select>
label attribute, value as value attribute in the drop-down
box. Choose from below a valid option.
80. Create a method in the controller to invoke DAO layer method
Rohit wants to create an auto populated drop-down box in which returns the Map of SportsType with @ModelAttribute
purchase.jsp page. Help Rohit to implement a proper annotation.
handler method in controller that can retrieve sportsType
defined in DAO layer. Choose from below a valid option.

81. ANS : REQUEST……………


From the following identify which is NOT a session
management technique?
82.

Consider the following code


Login.html:
<html>
<body>
<h2> Login Page</h2>
<form action="SessionServlett">
<table> Answer :- B) Page2 welcomes null(check once).
<tr><td> UserName</td><td><input type="text"
name="name"<p><b>
<tr><td> Password</td><td> <input type="password"
name="pwd"
</table>
<input type="submit" value="Login" />
</form>
</body>
</html>
Consider user is entering "John" in the username field
and "admin" in the password fat then……………………
83.
Which of the following is/are CORECT statement(S) with
respect to spring Test
Both (i) & (ii)
(i)ContextConfiguration can point to Spring XML,
configuration and JAVA configuration
(ii)@Active Profiles is used to activate one or more profile
for the test cases
1.
Refer the incomplete code given below: application propperties
=================== Assume other properties are configured
____Line1_____=8080
pom.xml ====
<!--Assume other dependencies are configured-->
<dependenc> server.port,sprint-boot-starter-web,@Spring........
<groupId>org.springframework.boot</groupId>
<artifactId>___ Line2__</artifact><!--Dependency for web (OR)
application-->
</dependency> Need to configure the int param ........
....Class =========
__Line3__
......class Application{ public static void main(String [] args){
__Line 4__.run(Application.class,args);
......Controller,Starter Class is coded appropriately.
... required to deploy the application on port 8080
choose valide option from below to complete the code
2. spring.datasouce url.spring-boot-starter- data-
jpa,@Repositorydefinition,findBySalary
It is required by jack to fetch eemployee details by salary, such
that salary greater than equal
to certain value, and result should be ordered in descending
order of EmployeeId. Refer the incomplete code and help jack
to complete the requirement:
application.properties ==============
#Assume other properties are configured properly #DataBase
url ____Line1____= jdbc:mysql://localhost:3306/springbootdb
pom.xml ======
<!--Assume other dependencies are configured-->
<dependency>
groupId>org.springframework.boot</groupId>
<artifactId>
___Line2___
</artifactid><!--Dependency for DB-->
</depenency>
___Line3___
(domainClass=EmployeeEntity.class,idClass=Integer.class)
@Transactionalsactional public interface EmployeeDAO
3. Refer the incomplete code given below: application
propperties ===================
#Assume other properties are configured
#Database url
____Line1_____=jdbc.mysql://localhost:3306/springbootdb
pom.xml ==== spring.datasouce url.spring-boot-starter data-
<!--Assume other dependencies are configured--> jpa,@RepositoryDefinition,@Query @pathVariable
<dependenc>
<groupId>org.springframework.boot</groupId>
<artifactId>___ Line2__</artifact><!--Dependency for web
application-->
</dependency> DAO
=========
__Line3__(domainClass =
Employeeentity.class.idClass=integer.class) @transactional
public interface EmployeedAO{ __Line4__("select k from
EmployeeEntity k where k salary.=?")
List,EmployeeEntity>getAllEmployeesBySalary(Double salary)
......class Application{ public static void main(String [] args){
__Line 4__.run(Application.class,args);
......Controller,Starter Class is coded appropriately.
... required to deploy the application on port 8080
choose valide option from below to complete the code

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

return new ___Line3____


<studentBean>(updateStudent, HttpStatus.OK);
Choose from below a valid option , in the order as it appears, to
complete the above code
8.
Only (ii)
Which of the following is correct with respect to Spring MVC?
1) Root context belongs to dispatcher servlet.
2) Common configuration is configured in root context and
presentation layer configuration is configured in child context
9.
Which of the following feature(s) is/are included in myWizard All of the above
DevOps?

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){ }

24. @RequestMapping , RequestMethod.GET


Refer the incomplete code given below:
@Controller public class CstController {
__________( value = "/registration", method
=_______________________)
public ModelAndView register(@ModelAttribute("empBean")
EmployeeBean employeeBean) {
ModelAndView modelAndView = new ModelAndView();
// Business logic goes here....
return modelAndView;
}
}
Assume that a view exists that submits the Request for action
"/registration" using Spring form's default request submission
method.
Choose from below a valid option in the order as it appears to
complete above code:

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.

48. Choose the best option


Code not visible clearly: 1- RequestMethod.POST,
@RequesParam("uName")
Assume that HTML code exists which submits a POST request ,@RequestParam("pwd")
validatedLogin.html with parameter name: uName and pwd Choose from
below valid option in the order as it appears to complete above code 2- RequestMethod.GET,
@Param("uName"),@Param("pwd")
3- RequestMethod.GET,
@RequestMapping("userName"),
@RequestMapping("password")

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");

61. The ___________ annotation is used to inject dataobjects before a jsp


page loads in order to ensure that the jsppage has all the data required to @ModelAttribute
display itself.
Choose the most appropriate option: @ModelAttribute @Model @ModelMap
@ModelData
62. Assume the below code is written in a Controller class
1@modelAttribute("countryList"); <form:radiobuttons path="country"
2public List populateCountry(){ items="${countryList}" />
List myList=new ArrayList();
myList.add("India");
myList.add("US");
return myList; }

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>

You might also like