Download as pdf or txt
Download as pdf or txt
You are on page 1of 913

1. Refer the code given below.

Class Library{
Private Book book ;
Public Library(Book book){
This.book = book;}
}

ANS: B
<bean id=”library” class=”com.accenture.lkm.library”>
<constructor-arg>
<bean class=”com.accenture.lkmBook”>
<constructor-arg value=”book1”>< constructor-arg>
</bean>
</constructor-arg>
</bean>

2.Consider the code


Package com.accenture.lkm:
@Component(“address”)
Public class Address{
//common word (“Hyderabad- Telangana”)//
//common word (“Bangalore-Maharasthra”)//

ANS:B
Employee Address:Bangalore-Maharasthra

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

ANS:A
@Autowired,@Qualifier(“room1”),com

4.Spring configuration file inside a package? Choose2


ANS:A,D
….
ClassPathXmlApplicationContext(“com/Accenture/lkm/resourse……..”);
….
ClassPathXmlApplicationContext(“classpath:com/accenture/lkm/resourse/my_springbean.xml”)
;
5.create spring container object…
Spring configuration code
Code:
@Configuration
Public class Appconfig
@bean
Public Address createAddress(){….

ANS:A
Address address= (Address ) ctx.getBean(“createAddress”);
OR
ANS:B
……
Address address= (Address ) ctx.getBean(“Address”);

6.Choose from below…..specific EntityManagerFactory and Transaction Management


ANS:B
LocalContainerEntityManagerFactoryBean

7.Valid implementation of the delete query to delete customers….than a particular value


Code:
@Entity
Public class CustomerEntity
@Id
Private int cid;

Private double credit;
// getter and setter methods}
ANS:A
@Modifiying
@Query(“delete from CustomerEntity k where k.credit<cpoint”)
…..Int delete(….

8.Spring transaction method?


(i)…
(ii)…
common word(“
///Triggered implicitly,methods?///
ANS:B
Only(i)

9.Assume Invalid DummyException is checked exception,


////Common word(“employeeBean
Line-x, addEmployee, addDepartment,DAO Class(Logical Transactions),@transactional”)
ANS:A
@transactional(value=”txManager”,propagation=Propagation,REQUIRES_NEW

10.Following statements correct with respect to JSP?


(i) Default scope….
(ii) JSTL codes….
(iii) Page scope
ANS:C
ONLY (iii)

11.From the Following identify two INCORRECT statements about 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
ANS:A
I and ii only

12.Which object is created by web container for each Servlet during servlet initialization?
ANS:B
ServletConfig

13.Mr.john has been assigned the task of creating a servlet filter to log IP address of the
computers ……servlet filters in web.xml file
ANS: A
<web-app>
..
<filter>
<filter-name>..</filter-name>
<filter-class>..</filter-class>
</filter>
….
14.Blessie is a web developer wants to create a web page which always lands in
portal.accenture.com..
Common word(“ index.html,Blessie,unavoidable reasons,MyServlet.java
@WebServlet(urlPatterns=”/MyServlet”),
serialVersionUID=1L;
/**code is missing**/
ANS:B
Response.sentRedirect(http://portal.accenture.com);
15.When you want to remove the user data from session, what all the various options available
in JSP?(choose 3)?
ANS:A,B,C
(i)To delete the session..
(ii)by invoking public..
(iii)in web.xml file use<session-timeout>…
16.Sadana wants to share the common database data throughout the application,Help her to
identify the appropriate code to achieve this task?
ANS:C
<%
String username = (String)application.getAttribute(“dbname”);
%>

17.Refer the following Miss.Linda


///Common word(“<%@page language=”java”...
“ISO-8859-1”%>, meta charset=”iso-8859-1>
Add JSP script here…
ANS:A
<% String companyName=”Accenture”;
String projectName=”XYZ”;
String location=”MDC”;
%>
<%=companyName%><br>
<%=projectName%><br>
<%=location%><br>

18.Refer the following JSP pages


///Common word(“ Header.jsp:
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01
Transitional/EN”http://WWW.w3.org/TR/html4/loose.dtd>
Blue, red, page Encoding=”ISO-8859-1%>
Home.jsp: , Footer.jsp
ANS:A
1

19.refer the incomplete code given below


//Common word(“ Author , authorobj
@RunWith(springJUnit4ClassRunner.class
____Line1_____
@Autowired
ANS:C
@ContextConfiguration…

20.Correct statement(s) with respect to spring test?


(i)@DirtiesCOntext…
(ii)@ContextConfiuration…
ANS:B
Only(i)

21.Refer the code


@component
@Profile(“myprofile”)
classProduct{}
Common word//(“myprofile”)
ANS:B
System.setProperty(“….”);

22.John has created a properties file like below


Config.properties
Common Word(“james,1009090,inject values in customer
ANS:A
@Component
Public…
@Value…
Private int customer;
@Value(…”)
Private String Coustomer Name}

23.Which of the following is correct with respect to spring?


(i)@Configuration…XML files Spring configuration
(ii)@componentScan is used to scan stereotype annotation
ANS:Only (ii)
@componentScan

24.which of the following is correct


(i)JVM Support IOC
(ii)Spring Container Manages the instance of …
ANS : Only(ii)
25.Refer the Below Entity class
@Entity
Public Class EmployeeEntity{
@Id
Private int employeeId;
Private String employeeName;
……. Double salary;
//Getters and Setters are coded}
ANS: A
List<EmployeeEntity>findBySalaryBetweenOrderBySalary…param2)

26.Correct with respect to spring transaction propagation types?


(i)propagation type Propagation.REQUIRED starts a new transaction ,if a method …
(ii) propagation type Propagation.REQUIRED…
ANS: Both (1 and 2)

27. CORRECT with respect to JSP?


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

28.CORRECT statement about autowiring


ANS: C
Autowiring requires setter or constructor in bean class

29.Identify the correct hierarchy of servlets assuming you are required to create a registration
ANS: A
RegistrationServlet,java…
HTTPServlet…..
GeneralServlet ..

30.Which is an abstract class which provides the basic implementation of Servlet interface except
Service() method?
ANS:C
Generic Servlet
31.from the following tables match the JSP implicit Objects given in table A with APIs in servlets
package given in table B.
Table A Table B
1) Out i)ServletContext,
//Common word(“application,JSPWriter,exception,Object,page,throwable.
ANS: A
1-ii,2-I,3-iv,4-iii

32.Incorrect statement about JSR-330 annotation


ANS: C
JSR-330……

33.Assume that class “Employee” is created with property “empid” and its setter method.
Refer the spring configuration given below
<bean id =”emp” class=”com.Employee”>
<property name=”empid” value=”john”>
</bean>
Employee object ///applicationContext///
ANS: A
1

34.Refer the below incomplete code for a test class


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(____=MyConfig.class)
..
Public class TestSpringCustomClass {
@AutoWired
Private Employee employee
//Test cases goes here}
ANS: A
Classes , @ActivePro....

35.Refer the code below


@Entity
Class BookEntity{
@Id
Private int…;
///Common word(“authorName, publisherType;,getters and setters}
Choose from the below to retrieve the books using Query method approach
ANS:A
findByPublisherType(String pType)
36.Refer the JSP code below
<body>
<h3>
<%!
Int bookId=1;
Int publishYear =2000;
Public int incrementBookId(int bookId){
Return bookid==;
…….
Predict the output
ANS:B
BookId:2
PublishYear:2001

37.which of the following ..are correct with respect to JSP


(i) default scope of a variable is page
(ii) session scope variable will be available in all jsp files …
(iii)JSTL codes are placed inside service() method
ANS:B
Both(i) and(ii)

38.When servlet destroy() method will be invoked by servlet container?


ANS:A ,C
When you male any change in the servlet class and same
When you stop the server, destroy method of all existing servlet objects will ne molded

39.refer the code


Package com.model;
@component(“prodObject”)
@profile(“myProdProfile”)
Public class product {
Private int productid;
Private string product Name;
}
….

..
///Common word(“ activate”)
ANS:A
@ActiveProfiles(profiles=”myOrderProfile”)
40.Refer the incomplete code
@Component
Class customer{
….
Private Cart cart ;
}
Assume instance of the cart is managed by Spring Container by the name “cartObj” and all the
Commonword//(“SpEL to inject the cart object in customer bean
ANS:A
@Value(“#(cartOBJ”)

41.refer to the incomplete code


Package com.accenture.lkm;
___line1__
Class customer{
Private int customerId;
___Line2____
Private address address;
____Line3____
____Line4____
……Common word///(“address”, @ComponentScan(basePackage =”com”)
Public class SpringConfig{
}
Public class Tester{
ANS: A;
@Component, @Autowired, @Component,@Configuration,annotationConfigApplicationContext.
42. Type annotations? Choose 2
ANS: A,B
@component
@service

43./springormdemos”/>
<property name =”username” value….;
<property name=”password” value….;
</bean>
<bean>
Id-“cst_entityManagerFactory” class=*org.springframework.com…
/// dataSource , JpaVendorAdapter”
Class=”org.springframework.orm.jpa.vendor.hibernate.jpavendoradapter
<property name=”showSql”….
<property name=”generate..
Value=”org.hibernate.dialect.MySQL5Dialect”/>
ANS: A
driverManagerDatasource,LocalCOntainerEntityManagerFactoryBean,@Repository,@Auto f

44.incomplete code given below


<bean>
<!—Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager=”txManager”/>
<bean id=”txManager” class=”org.springframework.com.jpa…..
<property name=”entityManagerFactory” ref


----Line1___
Common word///(“ EmployeeDAOImpl implements EmployeeDAO{
addEmployee,integer employee
ANS: C
@Repository,@persistenceContext,@Transaction(value=”txManager”)

45.Consider the code given below


Package com.accenture.lkm;
Public class Employee {
Private List<String>hobbies;
//getters and setters are already codede
Common word //(“playing cricket , Watching Movies, Ui teater……’”);
ANS: B
Employee 2 Hobbies: [playing cricket ,Watching Amovie]

46.Refer the code


Package com.accenture.lkm;
Public class job {
Private int jobId;
//getters and setter
}
Public class person{
Private String[] skills;
___Line1___
Private Job job;
This skill = skill,
….
//// Spring config java class below…
..
ANS: A
@value(“#(myjob)”).@configuration, @Bean, @beanname = “my…”);

47.Service class (Physical transaction)


/line-x
Public integer addEmployee….
Employeebean , DepartmentBean
Int result=0;
Int

..
deptId+employeeDepartmentDAO.addEmployee..
return result;
// DAO Class( logical Transactions)
//
Code for creating employee
ANS: A
@Transaction(“value =”txManager”,rollback=NullPointerException.class)

48.Which method is used to retrieve the recent access time of a request by user from session?
ANS:D
getLastAccessedTime().

49.refer the code below


Web.xml
<web-app>
<servlet>
Common word//(“Magazine , com.accnture.magazine.servlet,book, load-on-startup”)
ANS: A
Book servlet

50.Komal’s task is to create a customer report on daily…


Everyday when she generates a report … task
ANS: i & iii

i.
<% java.util.Data date = new java.util.Date():
out.print(data);
%>
iii.
<%
Java.util.Data data = new java.utilDate():
%>
<%=data%>

51…… about @ DiritesContext annotation.


ANS: B
It is used to close and Load the application context once again for other ….

52.refer the code given below


@Component
@Profile(“myprodfile”)
Class product{
}
Choose from the below a valid option toactivate the profile “myprodfile”
ANS: B
System.setProperty(“spring.profiles.active”,”myprofile”);

53.which of the following are stereotype annotation?(choose 2)


ANS: A,B
@component, @service
54.login.html;
<html>
<body>
<h2>Login Page</h2>
<form action=”sessionServlet1”>
<table>
<tr><td>UserName</td><td>…..
<tr><td>Password</td><td>……
</table>
…..John, admin.
ANS: B
page2…..null

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

56.farhan wants to write a code to add 2 number and return the result…..
ANS:B

57.Miss.Ashrey has been asked to add headers and footers…..JSP….


Header.JSP and footer.JSP
ANS: A
<…
<….
<…

<..
<..

58.refer code
@entity
Public class EmployeeEntity
@Id
Private int empId;
…string name;
,,,,double salary ;
//getter and setter methods

Valid update query to update the JPA Data


ANS: A;
@modifiying
@query(“update EmployeeEntity k set k salary=new Sai’)
Int updateSalary(@Param(“newSai”)Double salary)
59.
Correct or not
i. Request scope variable in the page…
ii. Request Dispatcher of servlet API shares the request ,,,
ANS:B;
Both I and ii

60.ClassRunner.class
“myprofile”);
ANS: A, classes, @ActiveProfiles

61.multiple choice ANS:1,2


use@autowired at lineX
use@autowired at lineY
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="library" class="com.accenture.lkm.Library">


<cons........>
<bean class............Book">
<constructor-arg value="book1"></constructor-arg>
(
</bean>
</constructor-arg>
</bean>

JSR-330 annotations JSR-330 annotations can not beuesd along with Spring framework annotations

To delete the session attribute we can call public void removeAttributes(String name) , By invoking public void
invaliddate(), In web.xml file use <session->

@RunWith(Spring.Junit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile") Public class TestSpringCustomClass{
public class TestSpringCustomClass{ @Autowired private Employee employee; } ___
___
}
Choose from below a valid combination to complete the above code____

@Component class Customer{----------private Cart cart; } @Value

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


_____Line 1_____
class Customer{
private int customerId;
_____Line 2_____
private Address address;
}
______Line 3_____ @Component,@Autowied,@Coponent,@Configuration,AnnottionConfigApplicationContext
class Address{
public Address(){
------
------
-------
}
@Entity class BookEntity{ @Id private int bookId; private String authorName; private String publisherType; //getter and setters }

DriverManageDataSource , LocalContainerEntityManagerFactoryBean,@Respository ,Autowired

@Respository, @PersistenceContext , @Transactional(value="Manager")


Which of the following is correct statement with respect to Spring test @DirtiesContext

@Configuration public class AppConfig { @Bean("address") public Address creatAddress() { Adsress address= new Address(); ApplicatonContext ctx=new AnnotationConfigApplicationContext(AppConfig.class); Address address=(Address)
return Address; }} ctx.getBean("addres");

Refer the incomplete code given below:

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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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
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


Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
Already Repeated Question
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) Session scope variable will be available in all JSP files if it is accessed in a single session both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
Already Repeated Question
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked

When servlet destroy() method is invoked by servlet container?


Which of the following is correct statement with respect to Spring test @DirtiesContext

RegistrationServlet extends HTTPServlet


From the following identify the correct hierarchy of servlets assuming you are required to create a registration servlet to
HttPServlet extends GenericServlet
process registration request.
GenericServlet implements Servlets

Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.
When you want to remove the user data from session, what all the various options available in JSP? All option, other than Perform log out ...
From the following tables match the jsp implicit objects given in table A with Api's in servlets package given in table B
Table A Table B
1.out 1.Servlet c 1. OUT - JSPWRITER 2. APPLICATION- SERVLETCONFIG 3.
2.application 2.JSPWriter EXCEPTION . THROWABLE 4. PAGE - OBJECT
3.exception 3. Object
4.page 4.Throwable
which provides the basic implementation of Servlet interface except Generic Servlet
Which is an abstract class which provides the basic implementation of servlet interface except service() method? Generic Servlet
Refer the code given below
package com.model;
@component("prodObject")
@Profile("myProdProfile")
public classs Product
{
private int productid;
private String productName;
}
@ActiveProfiles(profiles="myorderProfile")
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 ....


Refer the code given below
@Entity
public class EmployeeEntity{
@Id @Modyfying
private int empId; @Query("update EmployeeEntity
private String name;
private double salary; Options are not clear
//getter and setter methods
}
Choose the valid implementation of the Update query to update employee salary, using Spring JPA Data.
From the following identify TWO INCORRECT statements about ServletCoding objects.
i) It is not created for each servlet dusring servlet initialization.
ii) It will be available to all servletsof an application. i and ii only
iii) Its lifetime is until the servlet class object is destroyed.
iv) One object per servlet class
Raghav must pre populate doctor's names from doctors table in a drop down list when patient is booking appointment online.
. He has written required method implementation in DAO and service layer.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Raghav added following query in orm.xml file

<named-query name="getPatientsData">
@Query(name="getPatientData")
<query>select p.pName,p.appointmentDate from patients p </query>
List<String> getPatientsData();
</named-query>

Select the correct methid declaration in DAO interface. Refer the patients class and patients table.
Raghav has added a method to update the details of the patients as below
public interface PatientsDAO
{
@Query(name="updateQuery1") @Modifying is not used on the method output should return the string data which i.. the updated
int updateAppointmentSlot(Patients patients, String new Appointment(Time); appointment time.
}
But he getting exception as "DML operation is not supported".What went wrong?

Raghav added the following methods in Service and DAO implementation classes to add paitent's information in db.
//service implementation
@transactional(propagation=Propagation.REQUIRED)
Integer addPatientInService(Patients patient)
{
//calling DAO method
}
addPatientInDAO() method always exceutes in a new transaction rather than the interface started in service
//DAO implementation layer of addPatientInService() method.
@transactional(propagation=Propagation.REQUIRES_NEW)
Integer addPatientInService(Patients patient)
{
//implementation
}

what is the behaviour of the addPatientInDAO() method?


Which of the following is/are correct statement(s) with respect to spring test?
(i) @DirtiesContest is used to mark the context dirty so that it can be closed
only (i)
(ii) @ContextConfiguration can only point to Spring XML.....
Choose the most appropriate option.
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;

refer the code given below


@Component
@Profile("myprofile")
System.setproperty("springprofiles active","myprofile").
class Product{
}
choose from below option to activate the profile"myprofile"

DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
Which of the following is correct statement with respect to Spring test @DirtiesContext

_____ the incomplete code given below:


<beans>
<!--Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager____->
-----
-----
</bean>
@Repository,@PersostenceContext@Transactional(value="tx.Manager")
</beans>
____LIne 1____
public class EmployeeDAOlmpl implements____{
____Line 2_____
-------
____Line 3_____

<web-app>
--------------
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a serviet filter to log IP addresses of the requesis originate. help him from the following
options to identify meant for serviet filters in web.xmi file.
<web-mapping>
<filter-name>...</filter-name>
<urt-pattern>...</urt-pattern>
</filter-mapping>
----------
</web-app>

consider the code given below:


package com.accenture.ikm;
public class Employee(
private List<String>hobbies;
)
<beans>
<bean id="employee"class="com.accenture.ikm.Employee">
<property name="hobbies">
Employee 2 Hobbies : [Playing Cricket Watching Movies]
<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
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code below


package com.accenture.ikm;
public class job{
private int jobid;
//getter and setter
}
public class person{
@Value("(myjob)").@Configuration @bean
private String[] skills;
--------Line1-----------
private job job;
Person(String[]Skills){
this.skills=skills;
}
}
Refer the Spring configuration code given below:
@Configuration
public class AppConfig {
ApplicationContext.ctx=
@bean("address")
new AnnotationConfigurationApplicationContext AppConfig .....
public address createAddress(){
Address address= (Address) ctx get....("address")
Address address = new Address();
return address;
}
Refer the code given below:
@Entity
class BookEntity{
@id
private int bookid; findByPublisherType(String p Type)
private String title;
private String authorName;
private String publisherType;
}
public Integer addEmployee
employeeBean,DepartmentBean
int result= 0;
int
deptId=employeeDepartment
@Transaction(value = "txManager",Propagation.REQUIRED_NEW)
employeeBean.setDepartmentCode
result =
deptId+employeeDepartment
return result;
}
which of the following statements are correct:
(i)Default scope of a veriable is page.
(i) & (ii)
(ii) Session scope veriable will be availabe in all JSP filesif it is accessed in a single session.
(iii) JSTL codes placed inside service() method of translated serviet.
Which method is used to retrieve the recent access time of a request by user by session? getLastAccessedTime()
Which of the following is correct statement with respect to Spring test @DirtiesContext

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>
Book Servlet
</servlet>

<servlet>
<servlet-name>Magazine</servlet-name>
<servlet-class>com.accenture.MagazineServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
Choose from below valid options which provides complete support for creation of JPA specific EntityManagerFactory and
LocalContainerEntityManagerFactoryBean
Transaction Management.
Please Refer the following JSP pages Header.jsp <h1> This is Content of Header</h1> 1
<web-app>

<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the </filter>
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.(Option is not Visible but answer is correct. just cross check in exam) <filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>

</web-app>
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile")
Option 1(options not visible)
public class TestSpringCustomClass{ @Autowired private Employee employee; }
Which is an Abstract class which provides the basic implementation of Sevlet interface except Service method? Generic Servlet
Consider the code below package com.accenture.lkm @Component("address") public class Address @Value("Hyderabad-
Employee Address Banglore,Maharashtra
Telangana")
Refer the code given below @Component @Profile("myProfile") class Product{} Choose from below a valid option to activate
System.setProperty("spring.profiles.active", "myProfile");
the profile "myprofile"
@Componet public class Customer{ @Value("${customerID}")
John has created properties file as below config properties CustomerName: James,CustomerID:1009090(Once Verify once.
private int customerID; @Value("${customerName}")
As options are not visible.Go with the Syntax)
private int customerName;
which of the following statements are correct? 1.JVM supports IOC 2. Spring Container manages the instance of the beans
only II
mentioned in the configuration and provides them back to code when needed.
which of the following statements are correct? 1. @Configuration is used to declare a XML file as a Spring configuration 2.
only II
@ComponentScan is used to scan stereotype annotation.
(i) To delete the session...........
want to remove user data from session, what all various options available in (ii) by invoking public void invalidate().
(iii) in web.xml file use<session-timeout>15</session-timeout>
Which of the following is correct statement with respect to Spring test @DirtiesContext

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.uti.Date();
out.print(date);
%>
ii.
<% i & iii
java.uti.Date date =new java.uti.Date();
%>
<%=date;%>
iii.
<%
java.uti.Date date =new java.uti.Date();
out.print(date);
%>
<%date%>

about @DirtiesContext annotation it is used to closed and load the application context.......
to retrieve the recent access times of a request by user from session? getLastAccessedTime()
(i)When you makes any changes in the...........
When Servlet destroy() method will be invoked by servlet container?
(ii)Whwn you stop the server, Destroy method of the.....
Refer the incomplete code given below:
<beans>
<!--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>
____Line1_______ @Repository,@PersistenceContext,@Transactional(value="txManager")
public class EmployeeDAolmpl implements EmployeeDAO{
_____Line2______
private EntityManager entityManager;
____Line3_______
public Integer addEmployee(EmployeeBean employeeBean)
Integer employeeID = 0;
return employeeID;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<jsp include page="Header.jsp">


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

which of the followign os CORRECT with respect to spring transection propogation


1)propogation typr Ptopogation REQUIRED starts a new transection ,it a method is involved another method and a
transection does not required.
both(1) and (2)
2) propogation type Propogation.REQUIRED_NEW start a new transection.if a method is involvedfrom another method and a
transection already exists
choose most appropriate option

Refer the incomplete code given below: package com.accenture.lkm;


class House{
private String houseNum;
--------------Line1-----------
--------------line2------------
private Rooom room; @Autowired,@Qualifier("room")
//setter and getter}
class Room{
private int roomNum;
//setter and getter}
[further question not visible in mcq3(c) pdf]

Assume that class "Employee" is created with property 'empid" and its setter metod
Refer teh spring configuration below
<bean id="emp" class ='com.Employee">
<property name="empID' value ="john">
</bean>
How many Emplotyees objects will be created if the below code executes successfully?
1
public static void main(String[] arg){
Employee emp1 =(Employee) context.getBean("emp");
Employee emp2 =(Employee) context.getBean("emp");
Employee emp3 = emp1;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____________(profiles="myProfile")
classes, @ActiveProfile
public class TestSpringCustomClass{
@Autowired
(Option was not visible properly spelling may be different)
private Employee employee;
Test cases goes here
}
@Entity
public class CustomerEntity{
@Id @Modifying
private int cid; @Query("delete from CustomerEntity k where ......0
private String cname; int delete(@Param("cpoint") double ....
private double credit;
??getter and setter (the words which are not visible is marked as dots)
}

refer the code given below


@Entity
class BookEntity{
@Id
private int bookId;
private String title; findByPublisherType(String pType)
private String authorName;
private String publishertype;
//getter and setters
}
choose from below the valid option to retrieve the books based on the given publisher type by using query method approach
Refer the JSP coide given below and predict the output
<body>
<h3>
<%!
int bookId=1;
int publishYear = 2000; Book Id :2
public int incrementBookId(int bookId){ Publish Year :2001
return bookId++;
}
%>

Which of the fopllowing is CORRECT with respect to propogation type


propogation.REQUIRES_NEW?
option(!!) only
(!) For a method, begin a new transaction always
(!!) if a method is invokes from another method and a transaction exists, then the same transaction is used
choose the most appropriate
Line-X
public integer addEmployeeAndDepartment(EmployeeBean employeeBean,
Departmentbean departmentbean) throws Exception {
int result = 0;
int deptId = employeeDepartmentDAO.addDepartment(departmentBean); @Transaction(value="txmanager",propogation = Propogation.REQUIRES_NEW)
employee.Bean.setDepartmentCode(deptId);
result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

Which of the following statement are CORRECT with resepect to jsP


(!) Default scope of a variable is page
(!!) Session scope variable will be available in all JSP files if it is accessed in a single session both (!) and (!!)
(!!!) JSTL codes are placed insideservice() method of translater servlet
choose the most appropriate option
From the following identify the correct hierarchy of servelets assuming you are required to
Option not visible
create a registration servlet to process registration request
(!) When you make any changes in the servlet class and save
When Servlet destroy() method will be invoked by servlet Container?
(!!) When you stop the server, destroy method of all existing servlet objects will be mo...
John has created a properties file below: @C... (line not visible)

config.properties public class Customer{


customerName: James @Value("..........");
CustomerId: 1009090 ..........not visible.......
Choose from below a valid option to inject values in Customer bean from confiig.properties file }
Which of the following are correct with respect to Spring:

(i) @Configuration is used to declare an XML file as Spring configuration


option (ii) is correct
(ii) @CompensationScan is used to scan stereotype annotation

Choose most appropriate option


Which of the following statement(s) is/are CORRECT?
option (ii) is correct
(i) JVM Supports IOC
(ii) Spring container manages the instance of the beans mentioned in configuration and provides them back to code when needed.
(Not visible) is a web developer wants to create a web page which always lands in portal.accenture.com, whenever user hits on welcome button in index.html given below:

index.html
-----------------------
<form action="MyServelet" method="POST">
<input type="submit" value="welcome">
</form>

Now Blessie started writing the code, all of a sudden, she handed over the job of completing it to you due to unavoidable reasons. Incomplete code is attached below for your reference.

MyServlet.java
--------------------------- response.sendRedirect("https:/portal.accenture.com");
@WebServlet(urlPatterns="/MyServlet)
public class MyServlet extends HttpServlet{
public static final long serialVersionUID = 1L;

public myServlet(){
super();
}

..........................................
Which of the following is correct statement with respect to Spring test @DirtiesContext

@Entity

public class EmployeeEntity{


@Id;
private int employeeId;
List<EmployeeEntity> findBySalaryBetweenOrderBySalaryDesc(Double param1, Double param2))
private String employeeName;
private Double salary;
//Getters and Setters are coded
}

Which of the following are with respect to Spring transaction 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.
both (i) and (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 option.


Choose from below the CORRECT statement about Autowiring. Autowiring requires setters or constructors in bean classes
Consider a web application is created with a welcome index.html mapped with a Servlet class to process the response.

Refer the code below:

index.html
.......................................

<form action="LanguagesServelet" method = "POST">


<input type="checkbox" name="language" value="english"/> English
<input type="checkbox" name="language" value="hindi"/> Hindi
<input type="checkbox" name="language" value="tamil"/> Tamil
<input type="checkbox" name="language" value="malayalam"/> Malayalam
<input type="checkbox" name="language" value="telegu"/> Telegu
<input type="checkbox" name="language" value="kannada"/> Kannada
<input type="checkbox" name="language" value="french"/> French
<input type="checkbox" name="language" value="spanish"/> Spanish
<input type="submit" value="Select...........................Languages"/>
</form>

..................Not Visible....................................
when you want to remove the user data from the session,what all the various options available in JSP option starting with(to,by,in)
mr.john has been assigned the task of creating a servlet filter to log IP addresses.......................web.xml file answer not clear but i guess <web>(option 1)
Refer the following JSP pages,
Header.jsp:
<% @ page language="java" content type="text/html:charset=ISO-8859-1" 1

From the following table match the JSP implicit objects given in tabe A with APIs in servlet package given in table B 1-ii,2-i,3-iv,4-iii
.....which provide the basic implementation of servlet interface except GenericServlet
choose from the below the INCORRECT statement about JSR-300 annotation JSR-300 annotation.....
which of the following is/are CORRECT statement with respect to "spring Test" @DirtiesContext is used to mark the context dirty....
which is an abstract class which provide the basic implementation of servlet interface except service() method GenericServlet
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the code given below


package com.model;
@component("prodObject")
@profile("myProdProfile")
@ActiveProfiles(profiles="myOrderProfile")
public class Product{
private int productId'
private String productName;
}
Class Library{
private Book book;
Public Library(Book book){ <bean id="library" class="com.accenture.lkm.Library
this.book=book; <constructor-arg>
} <bean class="com.accenture.lkm.Book">
}

Class Book{ </bean>


private string bookName; </constructor-arg>
public Book(String bookName){ </bean>
this.bookName= bookName;
}
}
Refer the below incomplete code for a test class
classes, @ActiveProfiles
@RunWith(SpringJUnit4ClassRunner.class)
<%!
Peter wants a method to add 2 numbers and return the result. He also wanted to place it
public int add(int num1, int num2) {
inside the service method. Help him to select the appropriate JSP scripting.
return num1 + num2;
}
%>
<%
Sadana wants to share the common database data throughtout the application.
String userName = (String)application.getAttribute("dbname")
Help her to identify the appropriate code to achieve the task.
%>
<%@page language="java" contextType = "text/html:charset=ISO-8859-1"
pageEncoding = "ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<%
<meta charset="ISO-8859-1">
String companyName = "Accenture";
<title>Sample</title>
String projectName = "ABC";
</head>
String location = "HYD";
<body>
%>
<%--Add JSP Script here-->
<%= companyName %>
</body>
<%= projectName %>
</html>
<%= location %>
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.

Identify the CORRECT script


Miss Monica has given login request to 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 Translation, Compilation, Instantiation, Service and Destroy
right order
Which of the following is correct statement with respect to Spring test @DirtiesContext

<web-app>
........
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
Mr John has been assigned the task of creating a servlet flter to log IP addresses
of the computers from which the requests originate. Help him to identify the correct snippet
<filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>
..........
</web-app>
Which of the following is CORRECT with respect to spring transaction propogation ?

i)propogation type: Propogation.REQUIRED starts a new transaction.


another method and a transaction does not exist.
i and ii both are correct
ii)propogation type: Propogation.REQUIRED_NEW starts a new transaction.
from another method and a transaction already exist.

Choose appropriate option.


Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) JSTL codes are placed inside service() method of translated servlet only 3 is correct
(iii) page scope variable is available only on the page where it is declared
Choose the most appropriate option.
_____ the incomplete code given below:
<beans.....>
<!--Assume dataSource, EntityManagerFactory, configuration are provided>
_______Line1______

<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>

</beans>

Choose from below the valid option to enable declaration of transaction


Management using annotations.

<web-app>
<filter>
<filter-name>....</filter-name>
<filter-class>...</filter-class>
</filter>
Shed the task of creating a servlet filter to log IP addressess of the requests originate.help him from the following options
<filter-mapping>
to identify meant for servelet filters on web.xml file
<filter-name>....</filter-name>
<uri-pattern>...<uri-pattern>
</filter-mapping>
.....
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code given below:


package com.accenture.lkm;
Class House{
Private String houseNum;
_____Line1____
_____Line2____
private Room room; @Autowired,@Qualifier("room1"),com
//setter and getter
}
class Room{
private int roomNum;
//setter and getter
}
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("com/accenture/lkm/resource/my_springbean.xml");
Select correct options to refer a Spring configuration file inside aa package? Choose2
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("classpath:com/accenture/lkm/resource/my_springbean.xml");
Which of the following is/are CORRECT with respect to Spring transaction methods?
(i) If a method throws runtime/unchecked exception, then rollback will be triggered implicity
only (i)
(ii) If a method throws checked exception, then rollback will be triggered implicitly
Choose the most appropriate option
@Transactiona(value="txManager",rollbackFor=InvalidDummyException.class)
public Integer addEmployeeAndDepartment(EmployeeBean employeeBean, DeaprtmentBean departmentBean) throws Exception{
int result=0;
int
deptId=employeeDepartmentDAO.addDepartment(deprtmentBean):employeeBean.setDepartmentCode(deptId); @Transactional(value="txManager",propogation=Propagtion Requires_NEW)
result=
deptId+employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which object is creared by web container for each Servlet during servlet initilization ServletConfig

Refer the incomplete code given below:


package com.model;
public class Author{
public Authore(){
System.out.println("author");
}
}
Below configuration is available in the file located at /com/resources/my_springbean.xml
<bean id="authorobj" class="com.model.Author"></bean>
package come.test; @ContextCOnfiguration(locations="/com/resources/my_springbean.xml")@Test
@Runwith(SpringJUnit4ClassRunner.class)
____Line1____
piblic class TestAuthorClass{
@Autowired
private Author author;
____Line2___
public void testAuthor(){
Assert.assertTrue(author!=null);
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="messageSource"
rohit wants to externalize the validation error messages. So, he defined the messages in
class="org springframework.support
'com/accenture/lkm/resoruces/messages_en.properties files'.Help rohit to configure the MesageSource beam in the context file
<property name="name" value="classpath\com\accenture\lkm\resources/messages_en.properties"/>
by choosing a valid option from beiow
</bean>

Rohit deployed the application in the Apache Tomcat Server. But he got an exception as "org.springframework.beans.factory. A) Configure<context:component-scan base-package="com.accenture.lkm.dao"/> in the root context
NoSuchBeanDefinitionException:No qualifying vean of type [com.accenture.lkm.dao.PruchaseDAO]". Choose from below valid confifuration
options to succesfully execute his application C) Configure <mvc:annotation-driven/> in the child context configuration

Rohit wants to display all the validation error messages in purchase jsp. <form:form method="POST" modelAttribute="bean" action="store.html">
Help him to display those messages at the bottom of the page. <table border="3">
Choose from below a valid option. Asssume the below taglib <!--Assume form elements are mentioned appropriately -->
directives are added in the jSP. </table>
<%@taglib url="http://springframework.org/tags/form" prefix="form"%> <spring:hasBindErrors name="bean">
<%@taglib
Consider theurl="http://springframework.org/tags"
code given below: prefix="spring"%> <h3>All Errors</h3>
package com.accenture.lkm; <form:errors path="*" cssClass="error"/>
public class Employee { </spring:hasBindErrors>
private list<String>hobbies: </form:form>
//Getters and Setters are already coded
}
<beans>
<bean id ="employee" class="com.accenture.lkm.Employees">
<property name="hobbies">
<list> Employee 2 hobbies [Playing Cricket Watching Movies]
<value Playing Cricket </value>
<value Watching Movies </value>
<list>
</property>
</bean>
</beans>
public class UIT Tester {
public static void main(String

<web-app>
.......
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a servlet filter to log IP addresses of the request originate. Help him from the following options to identify
meant forservlet filters in web.xml file.
<filter-mapping>
<filter-name>....</filter-name>
<urf-pattern>....</urf-pattern>
</filter mapping>
.......
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the Spring configuration code gievn below:


1 @Configuration
2 public class AppConfig {
3 @Bean("address")
4 public address createAddress( ) { ApplicationContext ctx =
5 Address address = new Address( ) : new annotationConfigApplicationcontextAppConfig
6 return address ; Address address=(Address)ctx
7 }
8 }
Identifybthe correct code to create spring container object and get the address object injected
Choose the most appropriate option.
Refer the incomplete code given below:
package com.accenture.lkm;
public class Job {
private int jobId:
//getter and setter
}
public class Preson {
private String[] skills;
-----------line1--------------
@Value("=(myjob)"1 @configuration @Bean @Beanvalue ="myjob")
private Job job;
person(String[] skills){
}
//getter and setter
}
Refer the Springconfig java class below
------------------Line2--------------------
public class Springconfig(

Which method is used to retrieve the recent access time of a equeste by user from session?
getLastAccessedTime()
choose from below valid option.
Rohit wants to validate the quantity entered by the customer as mentioned in requirement 2. Choose from the below valid Add @Range(min=1, max=10)anotation in the Bean class
option.[Choose 2] The request handler method should include @Valid to @ModelAnnotation parameter
Rohit wants to receive the requests from customers and forward those request to other components of the application for
further processing . Choose from the most appropriate option, which Rohit performs as his first step as per Spring-MVC
workflow.
A
<bean class="org.springframework>
<property name="prefix">
Rohit wants to navigate to success.jsp page on successful submission. Assume he wrote a handler method to return <value>/WEB-INF/jspViews/</value>
ModelAndView with logical view name as success. He needs to configure a View Resolver bean in child configuration file to </property>
resolve the logical view name.Choose from below a valid option <property name="suffix">
<value>jsp</value>
</property>
</bean>
Rohit wants to create a request handler method in controller that can handle customer request and send the response back to Create a request handler method in the controller to map the request using @RequestMapping annotation and
the response back to the customer. Help rohit to achieve this with a valid option given below. return the ModelAndView object.
Rohit wants to auto populate the items available for the selected SportsType to the respective drop-down box. Assume he A
defined the respective method in the controller which can return Map<String,Double>. Rohit is supposed to bind the key as OPTION NOT VISIBLE
label attribute, value as value attribute in the drop-down box. Choose from below a valid option.
Rohit wants to create an auto populated drop-down box in purchase.jsp page. Help Rohit to implement a proper handler Create a method in the controller to invoke DAO layer method which returns the Map of SportsType with
method in controller that can retrieve sportsType defined in DAO layer. Choose from below a valid option. @ModelAttribute annotation.
Which of the following is correct statement with respect to Spring test @DirtiesContext

From the following tables match the JSP implicit objects given in table A with APIs in
sevlets package given in table B. 1 - ii
Table A Table B 2-i
1) out i) ServletContext
2) application ii) JSPWriter 3 - iv
3) exception
4) page
iii) Object
iv) Threwable
4 - iii
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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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


1
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


Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(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 both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked
1 Refer the incomplete code given below

Answer : A) @Value(“#{cartObj}”)
2 Consider the code given below:

Package com.accenture.lkm;

Public class Employee{

Answer :
3 Refer the incomplete code given below

Package com.accenture.lkm;

Public class Job{

Answer : A) Line 1= @value("#jobObjects")


line 2= @configuration
line 3= @bean ………………………etc

4 Which of the following are Stereotype annotations? [Choose 2]

Answer :- A and B (component and service)


5 Assume that class “Employee” is created with property “empid” and its setter
method. Refer the spring configuration given below

Answer : A) 1

6 Refer below incomplete code

Answer : A) @Transaction(value="txManager",propogation.REQUIRED_NEW)
7 From the following identify which is NOT a session management technique?

Answer:- A) Request…………

8 Consider the following code


Login.html:

Answer :- B) Page2 welcomes null(check once).


9 Which lifecycle method of JSP is invoked by the container to perform the………
…………………………….each time when trhe request is received?

Answer :- B) _jsp service

10 Farhan wants to write a code to add 2 numbers and return the result……….
……………………………………….. JSP scripting element.

Answer :- B
11 Miss Ashrey has beed asked to add headers and footers while designing login
and home page………………………………………..Header.jsp and footer.jsp

Answer :- A

12 Which of the following is/are CORECT statement(S) with respect to spring Test?

Answer :- A) Both (i) and (ii).


13 Refer the JSP code below and predict the output.

Answer :- B) Book id :2 Publish year :2001

14 Refer the Spring configuration code given below.

Answer :- B
15 Refer the code given below.
@Entity
Public class EmployeeEntity{

Answer:- A
16 Refer the incomplete code given below:
<beans>
<!..

Answer :- C) @Repository, @PersistenceContext,


@Transactionl(value=”txtManager”).
17 Which of the following statements(s) is/are CORRECT with respect to JSP?

i. Request Scope variable………………………………………


ii. RequestDispatcher…………………………………………..

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

18 Choose from below the INCORRECT statement about JSR-330 ………

Answer:- C) JSR 330……………………………………………………………………………..


19 Refer the code given below.

Answer : A & B (A) Use @Autowired at LineX and (B) Use @Autowired at LineY

20 Refer the below incomplete code for a test class.

Answer : (A)
21 Refer the incomplete code

Answer :- C) @Transactional(value=”txManager”,propagation=propagation REQUIRES_NEW)


22 When Servlet destroy() method will be invoked by Servlet Contsiner?[choose 2]

Answer :- A) When you make any change in the servlet class and save

C) When you stop the server, destroy method of all existing servlet objects………

23 Which is an abstract class which provides the basic implementation of Servlet interface except

Service() method ?

Answer :- C) GenericServlet
24 Refer the Below Entity class.

Answer : (A)
25 Which method is used to retrive the recent access time of a request by user from session?

Chosse from below a valid option.

Answer : D) getLastAccessedTime()
1 Refer the code given below:

Class Library{

Answer: B) <bean id=”library” class=”com.accenture.lkm.library”>

<constructor-arg>

<bean class=”com.accenture.lkm.Book”>

<constructor-arg value=”book1”></constructor=ard>

</bean>

</constructor-arg>

</bean>
2 Refer the incomplete code given below:

Package com.accenture.lkm;

Class House{

Answer :- A) @Autowired, @Qualifier(“room1”).com


3 Select correct options to refer a Spring configuration file inside a package? Choose 2

Answer :- A and D
4 Refer the Spring configuration code given below.

Identify the correct code to create spring container object and get the address object

Injected. Choose the ,ost appropriate option.

Answer :- A
5 Choose from below the valid option which provides the complete support for creation of JPA
specific EntityManagerFactory and Transaction Management.

Answer : B) LocalContainerEntityManageFactoryBean

6 Which of the following is/are Correct with respect to spring transaction methods?

Answer : b) only (i)


7 Refer the code given below.

Choose the valid implementation of the delete query to delete customers who has credit less

Than a particular value.

Answer : A
8 Which of the following statement(s) is/are CORRECT with respect to JSP?

Answer : - C) Only (iii)

9 From the following identify TWO INCORRECT statements about ServletConfig object.

Answer : A) I and ii only


10 Which object is created by web container for each Servlet during servlet initialization?

Answer :- b) ServletConfig
11 Mr.John has been assigned the task of creaing servlet filter to log IP address of the computers

……………………………………………………………………….for servlet filters in web.xml file.

Answer : A
12 Blessie is a web developer wants to create a wep page…………………whenever user hits on
welcome button on index.html given below

Answer :- B) response.sendRedirect(“https://portal.accenture.com”);
1 Sadana wants to share the common database date throughout the application. Help her to identify
the appropriate code to achieve thi task.

Answer : C) <%

String username=(String)application.getAttribute(“dbname”);

%>
2 Refer the following code:

Answer : (A)
3) Refer the following JSP Pages.

Header.jsp:
4) Refer the incomplete code given below.

Package com.model;

Public class Author{

Answer : C) @ContextConfiguration(locations=”/com/resources/my_springbeam_xml”),@test
5) Which of the following is/are CORECT statement(S) with respect to spring Test?

Answer :- B) Only (i)


1. Refer the code given below.

Answer :- B) system.setProperty("spring.profiles.active","myprofile");
2 Consider the code given below

Package com.accenture.lkm;

@component(“address”)

Public class Address{

Answer :- B)Employee Address : Bangalore-Maharashtra


3 John has created a properties file like below

Answer :- A

4. Which of the following is correct with respect to spring?

Answer : - Only 2
5 Which of the following statement(S) is/are correct.

Answer :- Only (ii) is correct.

6 Which of the following is CORRECT with respect to spring transaction pro… types ?

Answer :- A) Both (i) and (ii).


7 Which of the following statements(s) is/are CORRECT with respect to JSP?

Answer : (ii and iii ) 2 and 3 is correct.

8 Choose from below the CORRECT statement about Autowriting.

Answer :- C) Autowriting requires setters or Constructor in bean class.


9 From the following identify the correct hierarchy of servlets assuming you are
request………………………………………………………………..registration request.

Answer :- A

10 Which is an abstract class which provides the basic implementation of servlet interface except
service() method?

Answer :- C) GenericServlet
11 Mr.john has been assigned the task of creating a servlet After to log IP…………………………………………

The correct order of tags meant for servlet filters in web.xml file.

Answer :- A) <web-app>

12 Consider a web application is created with a welcome file index.html mapped with a servlet class

To process the response.

Refer the code below:

Answer :- B
13 When you want to remove the user data from sessions, what all the various options available in
JSP? [Choose 3].

Answer : A) To delete the session attribute we can call public void removeAttribute(String Name)

B) By invoking public void invalidate()

C) In web.xml file use <session-timeout>15</session-timeout>


14 From the following tables match the JSP implicit objects given in table A with API’s in servlets
package given in table B.

Answer :- A) 1.ii 2.i 3.iv 4.iii


16 Refer the code Given Below:

@Entity

Class BookEntity

Answer :- A) findByPublisherType(String p Type)


1) Refer the code given bellow
@component
@profile(“myprofile”)
Class product{
.
.
,
}

Ans: Option B
System.setProperty(“springprofileactive”.”myprofile”);
2)
Consider the code given below
Package com.accenture.lkm:
@Component(“Address”)

Public class address{

@value(“Hyderabad- Telanga)
Private String addressLine1;
//getters and settersare already coded
}

……………

Ans: Compile time error “bean name address is already used”

Option C
3)
Package com.accenture.lkm;
@Component(“employee”)
Public class Employee{
@Autowired
Private Address address;
//getter setters are already copied
}
………..

Public class UITester{


….....
}

Ans: Option C (Compile tiem error “ bean name address…..)


Q) Which of the following is correct with respect to spring?
i) @configuration is used to declare a XML file as Spring configuration
ii) @Componentscan is used to scan stereotype annotation

Choose the most appropriate option

Ans: ONLY 2

Q) Which of the following statement is /are CORRECT?

i) JVM Supports IOC


ii) Spring Container manages the instance of the beans mentioned in configuration and provide
them back to code when needed

Ans: ONLY 2

Q) Which of the following statement is /are CORRECT with respect to Spring transaction propogation
type?
i. Propagation type Propogation.REQUIRED starts a new transaction………………..
ii. Propagation type Propogation.REQUIRED_NEW starts a new transaction………………..
Choose most appropriate option.

Ans: BOTH
Q) Which of the following statement is /are CORRECT with respect to JSP?
i. Default scope of a variable is request
ii. Application scope variable will be available……………….
iii. JSTL code are not placed inside service() method of …..
iv. Choose the most appropriate option.

Ans: 2,3 Correct.


Q) Choose from the below the COORECT statement about Autowiring.

Ans: Option C (Autowiring requires setter or constructor in ….)


Refer the below entity class
@Entity
Public class public EmployeeEntity{
@Id
Private int employee
………………………
}

Choose from below valid option for Spring JPA Data……………..

………….
Who gets salary within given range in the descending order of salary.

Ans: Option D
List<EmployeeEntity>findBySalaryBetweenDesOrderBySalaryDoubleparam(double param2
Q) Which is an abstract class which provides the basic implementation of servlet interface except service() method?
Ans: Option C (GenericServlet)
Q) Consider a web application is created with a welcome file index.html mapped with a servlet class to process the
response
Refer the code below:
Index.html
……………………

Ans: req.getParameterValues("languages")

bhush
2021-04-10 13:49:37
--------------------------------------------
req.getParameterValues("languages")
Q) when you want to remove the user data from session, what all the various options available in JSP?
[choose 3]

Ans: Option A, B, C
Q) When Servlet destroy() method will be invoked by servlet Container?[choose2]
Ans:1 and 3
(when you make any changes in the servlet class and same
When you stop the servlet, destroy method of all existing……….)
Q) Which of the following is/are CORRECT statement(s) with respect to Spring
test?
i. @DirtiesContext is used to mark the context dirty so……….
ii. @ContextConfiguration can only point to Spring XML configuration……

Choose the most appropriate option


Ans: BOTH
Q) From the following table match the JSP implicit object given in table A with
APIs in servlets package given in table B.
Table A Table B.

1. OUT i) ServletContext
2. Application ii) JSPWriter
3. Exception iii) Object
4. Page iv) Throwable

Ans: Option A
1. OUT ii) JSPWriter
2. Application i) ServletContext
3. Exception iv) Throwable
4. Page iii) Object
Q) Refer the code given below:
Package com.model;
@Component(“prodObject”)
@Profile(“myProdProfile”)
Public class Product{
Private int productid;
Private String productName;
}
Package com.model;
@Component(“orderObeject”)
@Profiel(“myOrderProfile”)
Class Order{
………………….

Ans: Option A
@ActiveProfiles(profile=”myOrderProfiel”)
Q)…………………… JSR-330 annotations.
Ans: B Or
Q) Refer the code given below:
Class Library{
private Book book;
publc Library (Book book){
this.book=book;
}
}

Class Book{
............................................................................................
}
Choose from below…………….to define book as a inner bean of Library.

Ans: Option B
<bean id……………
<constrctor-arg>
……..
<bean class……….
<constructor-arg value=”book1></ constructor-arg>
</bean>
< /constructor-arg>
</bean>
Q) Refer the below incomplete code for a test class
@Runwith(SpringJUnit4ClassRunner.class
@ContextConfiguration…………
……………………….
Public class TestSpringCustomClass{
…………………..
}

Choose from the below a valid combination to complete the above code in the
order as it appears

Ans: Option B
Classes,@profiles
Q) Refer the incomplete code given below:
@Component
Class Customer{
…………………
Private Cart cart;

}
Assume instance of thr cart is managed by Spring Container by the name “cartObj” and all the classes ……
Choose from belowa valid SpEL to inject the cartobject in Customer bean.

Ans: Option A
@Value(“#(cartObj)”)
Q) ….. incomplete code given below.
Package com.accenture.lkm;
……………………Line1……………..
Class customer{

…………………………………………..

Ans: Option A ( @component,@Autowired,@Component,@Configuration,AnnotationConfigApplicationContext


Q) .. Spring configuration code given below
configuration
public class Appconfig{
@Bean(“address”)
Public Address createAddress(){
…………………….
}
}
identify the correct code to create spring container object and get the address object….
Choose the most appropriate option.

Ans: Option B [ ApplicationContext ctx= new AnnotationConfigApplicationContext(ApConfig.class);


Address address=(Address) ctx.getBean(“address”);
Q) Refer the Incomplete code given below:
Package com.accenture.lkm;
Public class job{
Private int jobId;
//getter and setter
}
……………………….

Ans: Option A
[@value(“#(myjob)”),@configuration, @Bean, @bean…..=….)]
Q) Which method is uswd to retrieve the recent access time of a request by user from session?

Ans: Option D [ GetLastAccessedTime() ]


Q) Refer the code below
Web.xml
………
<web-app>
<servlet>
<servlet-name>Book</servlet-name>
<load-on-startp>0</ load-on-startp>
………..

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>

As per web.xml file 2 servlets are configured for this application ……………….
first?
Choose below valid option:

Ans: Option A [ Book Servlet ]


Q) Komal’s task is to create a customer report on daily basis…………………..
Everyday when she generates a report. Help her to identify………………………
task.

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

ii.
<%
java.uitl.Date date=new java.util.Date();
out.print(date);
%>
<%=date;%>
iii.
<%
java.uitl.Date date=new java.util.Date();
out.print(date);
%>
<%=date%>

Ans: i & iii


Q) ………………………………… @DirtiesContext annotation.

Ans: Option B
[ It is used to close and load the application context………………]
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="library" class="com.accenture.lkm.Library">


<cons........>
<bean class............Book">
<constructor-arg value="book1"></constructor-arg>
(
</bean>
</constructor-arg>
</bean>

JSR-330 annotations JSR-330 annotations can not beuesd along with Spring framework annotations

To delete the session attribute we can call public void removeAttributes(String name) , By invoking public void
invaliddate(), In web.xml file use <session->

@RunWith(Spring.Junit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile") Public class TestSpringCustomClass{
public class TestSpringCustomClass{ @Autowired private Employee employee; } ___
___
}
Choose from below a valid combination to complete the above code____

@Component class Customer{----------private Cart cart; } @Value

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


_____Line 1_____
class Customer{
private int customerId;
_____Line 2_____
private Address address;
}
______Line 3_____ @Component,@Autowied,@Coponent,@Configuration,AnnottionConfigApplicationContext
class Address{
public Address(){
------
------
-------
}
@Entity class BookEntity{ @Id private int bookId; private String authorName; private String publisherType; //getter and setters }

DriverManageDataSource , LocalContainerEntityManagerFactoryBean,@Respository ,Autowired

@Respository, @PersistenceContext , @Transactional(value="Manager")


Which of the following is correct statement with respect to Spring test @DirtiesContext

@Configuration public class AppConfig { @Bean("address") public Address creatAddress() { Adsress address= new Address(); ApplicatonContext ctx=new AnnotationConfigApplicationContext(AppConfig.class); Address address=(Address)
return Address; }} ctx.getBean("addres");

Refer the incomplete code given below:

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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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
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


Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
Already Repeated Question
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) Session scope variable will be available in all JSP files if it is accessed in a single session both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
Already Repeated Question
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked

When servlet destroy() method is invoked by servlet container?


Which of the following is correct statement with respect to Spring test @DirtiesContext

RegistrationServlet extends HTTPServlet


From the following identify the correct hierarchy of servlets assuming you are required to create a registration servlet to
HttPServlet extends GenericServlet
process registration request.
GenericServlet implements Servlets

Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.
When you want to remove the user data from session, what all the various options available in JSP? All option, other than Perform log out ...
From the following tables match the jsp implicit objects given in table A with Api's in servlets package given in table B
Table A Table B
1.out 1.Servlet c 1. OUT - JSPWRITER 2. APPLICATION- SERVLETCONFIG 3.
2.application 2.JSPWriter EXCEPTION . THROWABLE 4. PAGE - OBJECT
3.exception 3. Object
4.page 4.Throwable
which provides the basic implementation of Servlet interface except Generic Servlet
Which is an abstract class which provides the basic implementation of servlet interface except service() method? Generic Servlet
Refer the code given below
package com.model;
@component("prodObject")
@Profile("myProdProfile")
public classs Product
{
private int productid;
private String productName;
}
@ActiveProfiles(profiles="myorderProfile")
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 ....


Refer the code given below
@Entity
public class EmployeeEntity{
@Id @Modyfying
private int empId; @Query("update EmployeeEntity
private String name;
private double salary; Options are not clear
//getter and setter methods
}
Choose the valid implementation of the Update query to update employee salary, using Spring JPA Data.
From the following identify TWO INCORRECT statements about ServletCoding objects.
i) It is not created for each servlet dusring servlet initialization.
ii) It will be available to all servletsof an application. i and ii only
iii) Its lifetime is until the servlet class object is destroyed.
iv) One object per servlet class
Raghav must pre populate doctor's names from doctors table in a drop down list when patient is booking appointment online.
. He has written required method implementation in DAO and service layer.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Raghav added following query in orm.xml file

<named-query name="getPatientsData">
@Query(name="getPatientData")
<query>select p.pName,p.appointmentDate from patients p </query>
List<String> getPatientsData();
</named-query>

Select the correct methid declaration in DAO interface. Refer the patients class and patients table.
Raghav has added a method to update the details of the patients as below
public interface PatientsDAO
{
@Query(name="updateQuery1") @Modifying is not used on the method output should return the string data which i.. the updated
int updateAppointmentSlot(Patients patients, String new Appointment(Time); appointment time.
}
But he getting exception as "DML operation is not supported".What went wrong?

Raghav added the following methods in Service and DAO implementation classes to add paitent's information in db.
//service implementation
@transactional(propagation=Propagation.REQUIRED)
Integer addPatientInService(Patients patient)
{
//calling DAO method
}
addPatientInDAO() method always exceutes in a new transaction rather than the interface started in service
//DAO implementation layer of addPatientInService() method.
@transactional(propagation=Propagation.REQUIRES_NEW)
Integer addPatientInService(Patients patient)
{
//implementation
}

what is the behaviour of the addPatientInDAO() method?


Which of the following is/are correct statement(s) with respect to spring test?
(i) @DirtiesContest is used to mark the context dirty so that it can be closed
only (i)
(ii) @ContextConfiguration can only point to Spring XML.....
Choose the most appropriate option.
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;

refer the code given below


@Component
@Profile("myprofile")
System.setproperty("springprofiles active","myprofile").
class Product{
}
choose from below option to activate the profile"myprofile"

DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
Which of the following is correct statement with respect to Spring test @DirtiesContext

_____ the incomplete code given below:


<beans>
<!--Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager____->
-----
-----
</bean>
@Repository,@PersostenceContext@Transactional(value="tx.Manager")
</beans>
____LIne 1____
public class EmployeeDAOlmpl implements____{
____Line 2_____
-------
____Line 3_____

<web-app>
--------------
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a serviet filter to log IP addresses of the requesis originate. help him from the following
options to identify meant for serviet filters in web.xmi file.
<web-mapping>
<filter-name>...</filter-name>
<urt-pattern>...</urt-pattern>
</filter-mapping>
----------
</web-app>

consider the code given below:


package com.accenture.ikm;
public class Employee(
private List<String>hobbies;
)
<beans>
<bean id="employee"class="com.accenture.ikm.Employee">
<property name="hobbies">
Employee 2 Hobbies : [Playing Cricket Watching Movies]
<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
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code below


package com.accenture.ikm;
public class job{
private int jobid;
//getter and setter
}
public class person{
@Value("(myjob)").@Configuration @bean
private String[] skills;
--------Line1-----------
private job job;
Person(String[]Skills){
this.skills=skills;
}
}
Refer the Spring configuration code given below:
@Configuration
public class AppConfig {
ApplicationContext.ctx=
@bean("address")
new AnnotationConfigurationApplicationContext AppConfig .....
public address createAddress(){
Address address= (Address) ctx get....("address")
Address address = new Address();
return address;
}
Refer the code given below:
@Entity
class BookEntity{
@id
private int bookid; findByPublisherType(String p Type)
private String title;
private String authorName;
private String publisherType;
}
public Integer addEmployee
employeeBean,DepartmentBean
int result= 0;
int
deptId=employeeDepartment
@Transaction(value = "txManager",Propagation.REQUIRED_NEW)
employeeBean.setDepartmentCode
result =
deptId+employeeDepartment
return result;
}
which of the following statements are correct:
(i)Default scope of a veriable is page.
(i) & (ii)
(ii) Session scope veriable will be availabe in all JSP filesif it is accessed in a single session.
(iii) JSTL codes placed inside service() method of translated serviet.
Which method is used to retrieve the recent access time of a request by user by session? getLastAccessedTime()
Which of the following is correct statement with respect to Spring test @DirtiesContext

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>
Book Servlet
</servlet>

<servlet>
<servlet-name>Magazine</servlet-name>
<servlet-class>com.accenture.MagazineServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
Choose from below valid options which provides complete support for creation of JPA specific EntityManagerFactory and
LocalContainerEntityManagerFactoryBean
Transaction Management.
Please Refer the following JSP pages Header.jsp <h1> This is Content of Header</h1> 1
<web-app>

<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the </filter>
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.(Option is not Visible but answer is correct. just cross check in exam) <filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>

</web-app>
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile")
Option 1(options not visible)
public class TestSpringCustomClass{ @Autowired private Employee employee; }
Which is an Abstract class which provides the basic implementation of Sevlet interface except Service method? Generic Servlet
Consider the code below package com.accenture.lkm @Component("address") public class Address @Value("Hyderabad-
Employee Address Banglore,Maharashtra
Telangana")
Refer the code given below @Component @Profile("myProfile") class Product{} Choose from below a valid option to activate
System.setProperty("spring.profiles.active", "myProfile");
the profile "myprofile"
@Componet public class Customer{ @Value("${customerID}")
John has created properties file as below config properties CustomerName: James,CustomerID:1009090(Once Verify once.
private int customerID; @Value("${customerName}")
As options are not visible.Go with the Syntax)
private int customerName;
which of the following statements are correct? 1.JVM supports IOC 2. Spring Container manages the instance of the beans
only II
mentioned in the configuration and provides them back to code when needed.
which of the following statements are correct? 1. @Configuration is used to declare a XML file as a Spring configuration 2.
only II
@ComponentScan is used to scan stereotype annotation.
(i) To delete the session...........
want to remove user data from session, what all various options available in (ii) by invoking public void invalidate().
(iii) in web.xml file use<session-timeout>15</session-timeout>
Which of the following is correct statement with respect to Spring test @DirtiesContext

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.uti.Date();
out.print(date);
%>
ii.
<% i & iii
java.uti.Date date =new java.uti.Date();
%>
<%=date;%>
iii.
<%
java.uti.Date date =new java.uti.Date();
out.print(date);
%>
<%date%>

about @DirtiesContext annotation it is used to closed and load the application context.......
to retrieve the recent access times of a request by user from session? getLastAccessedTime()
(i)When you makes any changes in the...........
When Servlet destroy() method will be invoked by servlet container?
(ii)Whwn you stop the server, Destroy method of the.....
Refer the incomplete code given below:
<beans>
<!--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>
____Line1_______ @Repository,@PersistenceContext,@Transactional(value="txManager")
public class EmployeeDAolmpl implements EmployeeDAO{
_____Line2______
private EntityManager entityManager;
____Line3_______
public Integer addEmployee(EmployeeBean employeeBean)
Integer employeeID = 0;
return employeeID;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<jsp include page="Header.jsp">


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

which of the followign os CORRECT with respect to spring transection propogation


1)propogation typr Ptopogation REQUIRED starts a new transection ,it a method is involved another method and a
transection does not required.
both(1) and (2)
2) propogation type Propogation.REQUIRED_NEW start a new transection.if a method is involvedfrom another method and a
transection already exists
choose most appropriate option

Refer the incomplete code given below: package com.accenture.lkm;


class House{
private String houseNum;
--------------Line1-----------
--------------line2------------
private Rooom room; @Autowired,@Qualifier("room")
//setter and getter}
class Room{
private int roomNum;
//setter and getter}
[further question not visible in mcq3(c) pdf]

Assume that class "Employee" is created with property 'empid" and its setter metod
Refer teh spring configuration below
<bean id="emp" class ='com.Employee">
<property name="empID' value ="john">
</bean>
How many Emplotyees objects will be created if the below code executes successfully?
1
public static void main(String[] arg){
Employee emp1 =(Employee) context.getBean("emp");
Employee emp2 =(Employee) context.getBean("emp");
Employee emp3 = emp1;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____________(profiles="myProfile")
classes, @ActiveProfile
public class TestSpringCustomClass{
@Autowired
(Option was not visible properly spelling may be different)
private Employee employee;
Test cases goes here
}
@Entity
public class CustomerEntity{
@Id @Modifying
private int cid; @Query("delete from CustomerEntity k where ......0
private String cname; int delete(@Param("cpoint") double ....
private double credit;
??getter and setter (the words which are not visible is marked as dots)
}

refer the code given below


@Entity
class BookEntity{
@Id
private int bookId;
private String title; findByPublisherType(String pType)
private String authorName;
private String publishertype;
//getter and setters
}
choose from below the valid option to retrieve the books based on the given publisher type by using query method approach
Refer the JSP coide given below and predict the output
<body>
<h3>
<%!
int bookId=1;
int publishYear = 2000; Book Id :2
public int incrementBookId(int bookId){ Publish Year :2001
return bookId++;
}
%>

Which of the fopllowing is CORRECT with respect to propogation type


propogation.REQUIRES_NEW?
option(!!) only
(!) For a method, begin a new transaction always
(!!) if a method is invokes from another method and a transaction exists, then the same transaction is used
choose the most appropriate
Line-X
public integer addEmployeeAndDepartment(EmployeeBean employeeBean,
Departmentbean departmentbean) throws Exception {
int result = 0;
int deptId = employeeDepartmentDAO.addDepartment(departmentBean); @Transaction(value="txmanager",propogation = Propogation.REQUIRES_NEW)
employee.Bean.setDepartmentCode(deptId);
result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

Which of the following statement are CORRECT with resepect to jsP


(!) Default scope of a variable is page
(!!) Session scope variable will be available in all JSP files if it is accessed in a single session both (!) and (!!)
(!!!) JSTL codes are placed insideservice() method of translater servlet
choose the most appropriate option
From the following identify the correct hierarchy of servelets assuming you are required to
Option not visible
create a registration servlet to process registration request
(!) When you make any changes in the servlet class and save
When Servlet destroy() method will be invoked by servlet Container?
(!!) When you stop the server, destroy method of all existing servlet objects will be mo...
John has created a properties file below: @C... (line not visible)

config.properties public class Customer{


customerName: James @Value("..........");
CustomerId: 1009090 ..........not visible.......
Choose from below a valid option to inject values in Customer bean from confiig.properties file }
Which of the following are correct with respect to Spring:

(i) @Configuration is used to declare an XML file as Spring configuration


option (ii) is correct
(ii) @CompensationScan is used to scan stereotype annotation

Choose most appropriate option


Which of the following statement(s) is/are CORRECT?
option (ii) is correct
(i) JVM Supports IOC
(ii) Spring container manages the instance of the beans mentioned in configuration and provides them back to code when needed.
(Not visible) is a web developer wants to create a web page which always lands in portal.accenture.com, whenever user hits on welcome button in index.html given below:

index.html
-----------------------
<form action="MyServelet" method="POST">
<input type="submit" value="welcome">
</form>

Now Blessie started writing the code, all of a sudden, she handed over the job of completing it to you due to unavoidable reasons. Incomplete code is attached below for your reference.

MyServlet.java
--------------------------- response.sendRedirect("https:/portal.accenture.com");
@WebServlet(urlPatterns="/MyServlet)
public class MyServlet extends HttpServlet{
public static final long serialVersionUID = 1L;

public myServlet(){
super();
}

..........................................
Which of the following is correct statement with respect to Spring test @DirtiesContext

@Entity

public class EmployeeEntity{


@Id;
private int employeeId;
List<EmployeeEntity> findBySalaryBetweenOrderBySalaryDesc(Double param1, Double param2))
private String employeeName;
private Double salary;
//Getters and Setters are coded
}

Which of the following are with respect to Spring transaction 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.
both (i) and (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 option.


Choose from below the CORRECT statement about Autowiring. Autowiring requires setters or constructors in bean classes
Consider a web application is created with a welcome index.html mapped with a Servlet class to process the response.

Refer the code below:

index.html
.......................................

<form action="LanguagesServelet" method = "POST">


<input type="checkbox" name="language" value="english"/> English
<input type="checkbox" name="language" value="hindi"/> Hindi
<input type="checkbox" name="language" value="tamil"/> Tamil
<input type="checkbox" name="language" value="malayalam"/> Malayalam
<input type="checkbox" name="language" value="telegu"/> Telegu
<input type="checkbox" name="language" value="kannada"/> Kannada
<input type="checkbox" name="language" value="french"/> French
<input type="checkbox" name="language" value="spanish"/> Spanish
<input type="submit" value="Select...........................Languages"/>
</form>

..................Not Visible....................................
when you want to remove the user data from the session,what all the various options available in JSP option starting with(to,by,in)
mr.john has been assigned the task of creating a servlet filter to log IP addresses.......................web.xml file answer not clear but i guess <web>(option 1)
Refer the following JSP pages,
Header.jsp:
<% @ page language="java" content type="text/html:charset=ISO-8859-1" 1

From the following table match the JSP implicit objects given in tabe A with APIs in servlet package given in table B 1-ii,2-i,3-iv,4-iii
.....which provide the basic implementation of servlet interface except GenericServlet
choose from the below the INCORRECT statement about JSR-300 annotation JSR-300 annotation.....
which of the following is/are CORRECT statement with respect to "spring Test" @DirtiesContext is used to mark the context dirty....
which is an abstract class which provide the basic implementation of servlet interface except service() method GenericServlet
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the code given below


package com.model;
@component("prodObject")
@profile("myProdProfile")
@ActiveProfiles(profiles="myOrderProfile")
public class Product{
private int productId'
private String productName;
}
Class Library{
private Book book;
Public Library(Book book){ <bean id="library" class="com.accenture.lkm.Library
this.book=book; <constructor-arg>
} <bean class="com.accenture.lkm.Book">
}

Class Book{ </bean>


private string bookName; </constructor-arg>
public Book(String bookName){ </bean>
this.bookName= bookName;
}
}
Refer the below incomplete code for a test class
classes, @ActiveProfiles
@RunWith(SpringJUnit4ClassRunner.class)
<%!
Peter wants a method to add 2 numbers and return the result. He also wanted to place it
public int add(int num1, int num2) {
inside the service method. Help him to select the appropriate JSP scripting.
return num1 + num2;
}
%>
<%
Sadana wants to share the common database data throughtout the application.
String userName = (String)application.getAttribute("dbname")
Help her to identify the appropriate code to achieve the task.
%>
<%@page language="java" contextType = "text/html:charset=ISO-8859-1"
pageEncoding = "ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<%
<meta charset="ISO-8859-1">
String companyName = "Accenture";
<title>Sample</title>
String projectName = "ABC";
</head>
String location = "HYD";
<body>
%>
<%--Add JSP Script here-->
<%= companyName %>
</body>
<%= projectName %>
</html>
<%= location %>
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.

Identify the CORRECT script


Miss Monica has given login request to 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 Translation, Compilation, Instantiation, Service and Destroy
right order
Which of the following is correct statement with respect to Spring test @DirtiesContext

<web-app>
........
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
Mr John has been assigned the task of creating a servlet flter to log IP addresses
of the computers from which the requests originate. Help him to identify the correct snippet
<filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>
..........
</web-app>
Which of the following is CORRECT with respect to spring transaction propogation ?

i)propogation type: Propogation.REQUIRED starts a new transaction.


another method and a transaction does not exist.
i and ii both are correct
ii)propogation type: Propogation.REQUIRED_NEW starts a new transaction.
from another method and a transaction already exist.

Choose appropriate option.


Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) JSTL codes are placed inside service() method of translated servlet only 3 is correct
(iii) page scope variable is available only on the page where it is declared
Choose the most appropriate option.
_____ the incomplete code given below:
<beans.....>
<!--Assume dataSource, EntityManagerFactory, configuration are provided>
_______Line1______

<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>

</beans>

Choose from below the valid option to enable declaration of transaction


Management using annotations.

<web-app>
<filter>
<filter-name>....</filter-name>
<filter-class>...</filter-class>
</filter>
Shed the task of creating a servlet filter to log IP addressess of the requests originate.help him from the following options
<filter-mapping>
to identify meant for servelet filters on web.xml file
<filter-name>....</filter-name>
<uri-pattern>...<uri-pattern>
</filter-mapping>
.....
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code given below:


package com.accenture.lkm;
Class House{
Private String houseNum;
_____Line1____
_____Line2____
private Room room; @Autowired,@Qualifier("room1"),com
//setter and getter
}
class Room{
private int roomNum;
//setter and getter
}
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("com/accenture/lkm/resource/my_springbean.xml");
Select correct options to refer a Spring configuration file inside aa package? Choose2
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("classpath:com/accenture/lkm/resource/my_springbean.xml");
Which of the following is/are CORRECT with respect to Spring transaction methods?
(i) If a method throws runtime/unchecked exception, then rollback will be triggered implicity
only (i)
(ii) If a method throws checked exception, then rollback will be triggered implicitly
Choose the most appropriate option
@Transactiona(value="txManager",rollbackFor=InvalidDummyException.class)
public Integer addEmployeeAndDepartment(EmployeeBean employeeBean, DeaprtmentBean departmentBean) throws Exception{
int result=0;
int
deptId=employeeDepartmentDAO.addDepartment(deprtmentBean):employeeBean.setDepartmentCode(deptId); @Transactional(value="txManager",propogation=Propagtion Requires_NEW)
result=
deptId+employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which object is creared by web container for each Servlet during servlet initilization ServletConfig

Refer the incomplete code given below:


package com.model;
public class Author{
public Authore(){
System.out.println("author");
}
}
Below configuration is available in the file located at /com/resources/my_springbean.xml
<bean id="authorobj" class="com.model.Author"></bean>
package come.test; @ContextCOnfiguration(locations="/com/resources/my_springbean.xml")@Test
@Runwith(SpringJUnit4ClassRunner.class)
____Line1____
piblic class TestAuthorClass{
@Autowired
private Author author;
____Line2___
public void testAuthor(){
Assert.assertTrue(author!=null);
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="messageSource"
rohit wants to externalize the validation error messages. So, he defined the messages in
class="org springframework.support
'com/accenture/lkm/resoruces/messages_en.properties files'.Help rohit to configure the MesageSource beam in the context file
<property name="name" value="classpath\com\accenture\lkm\resources/messages_en.properties"/>
by choosing a valid option from beiow
</bean>

Rohit deployed the application in the Apache Tomcat Server. But he got an exception as "org.springframework.beans.factory. A) Configure<context:component-scan base-package="com.accenture.lkm.dao"/> in the root context
NoSuchBeanDefinitionException:No qualifying vean of type [com.accenture.lkm.dao.PruchaseDAO]". Choose from below valid confifuration
options to succesfully execute his application C) Configure <mvc:annotation-driven/> in the child context configuration

Rohit wants to display all the validation error messages in purchase jsp. <form:form method="POST" modelAttribute="bean" action="store.html">
Help him to display those messages at the bottom of the page. <table border="3">
Choose from below a valid option. Asssume the below taglib <!--Assume form elements are mentioned appropriately -->
directives are added in the jSP. </table>
<%@taglib url="http://springframework.org/tags/form" prefix="form"%> <spring:hasBindErrors name="bean">
<%@taglib
Consider theurl="http://springframework.org/tags"
code given below: prefix="spring"%> <h3>All Errors</h3>
package com.accenture.lkm; <form:errors path="*" cssClass="error"/>
public class Employee { </spring:hasBindErrors>
private list<String>hobbies: </form:form>
//Getters and Setters are already coded
}
<beans>
<bean id ="employee" class="com.accenture.lkm.Employees">
<property name="hobbies">
<list> Employee 2 hobbies [Playing Cricket Watching Movies]
<value Playing Cricket </value>
<value Watching Movies </value>
<list>
</property>
</bean>
</beans>
public class UIT Tester {
public static void main(String

<web-app>
.......
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a servlet filter to log IP addresses of the request originate. Help him from the following options to identify
meant forservlet filters in web.xml file.
<filter-mapping>
<filter-name>....</filter-name>
<urf-pattern>....</urf-pattern>
</filter mapping>
.......
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the Spring configuration code gievn below:


1 @Configuration
2 public class AppConfig {
3 @Bean("address")
4 public address createAddress( ) { ApplicationContext ctx =
5 Address address = new Address( ) : new annotationConfigApplicationcontextAppConfig
6 return address ; Address address=(Address)ctx
7 }
8 }
Identifybthe correct code to create spring container object and get the address object injected
Choose the most appropriate option.
Refer the incomplete code given below:
package com.accenture.lkm;
public class Job {
private int jobId:
//getter and setter
}
public class Preson {
private String[] skills;
-----------line1--------------
@Value("=(myjob)"1 @configuration @Bean @Beanvalue ="myjob")
private Job job;
person(String[] skills){
}
//getter and setter
}
Refer the Springconfig java class below
------------------Line2--------------------
public class Springconfig(

Which method is used to retrieve the recent access time of a equeste by user from session?
getLastAccessedTime()
choose from below valid option.
Rohit wants to validate the quantity entered by the customer as mentioned in requirement 2. Choose from the below valid Add @Range(min=1, max=10)anotation in the Bean class
option.[Choose 2] The request handler method should include @Valid to @ModelAnnotation parameter
Rohit wants to receive the requests from customers and forward those request to other components of the application for
further processing . Choose from the most appropriate option, which Rohit performs as his first step as per Spring-MVC
workflow.
A
<bean class="org.springframework>
<property name="prefix">
Rohit wants to navigate to success.jsp page on successful submission. Assume he wrote a handler method to return <value>/WEB-INF/jspViews/</value>
ModelAndView with logical view name as success. He needs to configure a View Resolver bean in child configuration file to </property>
resolve the logical view name.Choose from below a valid option <property name="suffix">
<value>jsp</value>
</property>
</bean>
Rohit wants to create a request handler method in controller that can handle customer request and send the response back to Create a request handler method in the controller to map the request using @RequestMapping annotation and
the response back to the customer. Help rohit to achieve this with a valid option given below. return the ModelAndView object.
Rohit wants to auto populate the items available for the selected SportsType to the respective drop-down box. Assume he A
defined the respective method in the controller which can return Map<String,Double>. Rohit is supposed to bind the key as OPTION NOT VISIBLE
label attribute, value as value attribute in the drop-down box. Choose from below a valid option.
Rohit wants to create an auto populated drop-down box in purchase.jsp page. Help Rohit to implement a proper handler Create a method in the controller to invoke DAO layer method which returns the Map of SportsType with
method in controller that can retrieve sportsType defined in DAO layer. Choose from below a valid option. @ModelAttribute annotation.
Which of the following is correct statement with respect to Spring test @DirtiesContext

From the following tables match the JSP implicit objects given in table A with APIs in
sevlets package given in table B. 1 - ii
Table A Table B 2-i
1) out i) ServletContext
2) application ii) JSPWriter 3 - iv
3) exception
4) page
iii) Object
iv) Threwable
4 - iii
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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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


1
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


Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(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 both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked
MCQ3

Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="library" class="com.accenture.lkm.Library">


<cons........>
<bean class............Book">
<constructor-arg value="book1"></constructor-arg>
(
</bean>
</constructor-arg>
</bean>

JSR-330 annotations JSR-330 annotations can not beuesd along with Spring framework annotations

To delete the session attribute we can call public void removeAttributes(String name) , By invoking public void
invaliddate(), In web.xml file use <session->

@RunWith(Spring.Junit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile") Public class TestSpringCustomClass{
classes, @ActiveProfiles
public class TestSpringCustomClass{ @Autowired private Employee employee; } ___
___
}
Choose from below a valid combination to complete the above code____

classes , @ActivePy

@Component class Customer{----------private Cart cart; } @Value

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


_____Line 1_____
class Customer{
private int customerId;
_____Line 2_____
private Address address;
}
______Line 3_____ @Component,@Autowied,@Coponent,@Configuration,AnnottionConfigApplicationContext
class Address{
public Address(){
------
------
-------
}
findByPublisherType(String p
@Entity class BookEntity{ @Id private int bookId; private String authorName; private String publisherType; //getter and setters }
Type)

DriverManageDataSource , LocalContainerEntityManagerFactoryBean,@Respository ,Autowired

@Respository, @PersistenceContext , @Transactional(value="Manager")

@Configuration public class AppConfig { @Bean("address") public Address creatAddress() { Adsress address= new Address(); ApplicatonContext ctx=new AnnotationConfigApplicationContext(AppConfig.class); Address address=(Address)
return Address; }} ctx.getBean("addres");

Refer the incomplete code given below:

1
MCQ3

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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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
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


Already Repeated Question
Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
Already Repeated Question
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.

2
MCQ3

Already Repeated Question


Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) Session scope variable will be available in all JSP files if it is accessed in a single session both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
Already Repeated Question
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked

When servlet destroy() method is invoked by servlet container?

RegistrationServlet extends HTTPServlet


From the following identify the correct hierarchy of servlets assuming you are required to create a registration servlet to
HttPServlet extends GenericServlet
process registration request.
GenericServlet implements Servlets

Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.
When you want to remove the user data from session, what all the various options available in JSP? All option, other than Perform log out ...
From the following tables match the jsp implicit objects given in table A with Api's in servlets package given in table B
Table A Table B
1.out 1.Servlet c 1. OUT - JSPWRITER 2. APPLICATION- SERVLETCONFIG 3.
2.application 2.JSPWriter EXCEPTION . THROWABLE 4. PAGE - OBJECT
3.exception 3. Object
4.page 4.Throwable
which provides the basic implementation of Servlet interface except Generic Servlet
Which is an abstract class which provides the basic implementation of servlet interface except service() method? Generic Servlet

3
MCQ3

Refer the code given below


package com.model;
@component("prodObject")
@Profile("myProdProfile")
public classs Product
{
private int productid;
private String productName;
}
@ActiveProfiles(profiles="myorderProfile")
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 ....


Refer the code given below
@Entity
public class EmployeeEntity{
@Id @Modyfying
private int empId; @Query("update EmployeeEntity
private String name;
private double salary; Options are not clear
//getter and setter methods
}
Choose the valid implementation of the Update query to update employee salary, using Spring JPA Data.
From the following identify TWO INCORRECT statements about ServletCoding objects.
i) It is not created for each servlet dusring servlet initialization.
ii) It will be available to all servletsof an application. i and ii only
iii) Its lifetime is until the servlet class object is destroyed.
iv) One object per servlet class
Raghav must pre populate doctor's names from doctors table in a drop down list when patient is booking appointment online.
. He has written required method implementation in DAO and service layer.
Raghav added following query in orm.xml file

<named-query name="getPatientsData">
@Query(name="getPatientData")
<query>select p.pName,p.appointmentDate from patients p </query>
List<String> getPatientsData();
</named-query>

Select the correct methid declaration in DAO interface. Refer the patients class and patients table.
Raghav has added a method to update the details of the patients as below
public interface PatientsDAO
{
@Query(name="updateQuery1") @Modifying is not used on the method output should return the string data which i.. the updated
int updateAppointmentSlot(Patients patients, String new Appointment(Time); appointment time.
}
But he getting exception as "DML operation is not supported".What went wrong?

Raghav added the following methods in Service and DAO implementation classes to add paitent's information in db.
//service implementation
@transactional(propagation=Propagation.REQUIRED)
Integer addPatientInService(Patients patient)
{
//calling DAO method
}
addPatientInDAO() method always exceutes in a new transaction rather than the interface started in service
//DAO implementation layer of addPatientInService() method.
@transactional(propagation=Propagation.REQUIRES_NEW)
Integer addPatientInService(Patients patient)
{
//implementation
}

what is the behaviour of the addPatientInDAO() method?


Which of the following is/are correct statement(s) with respect to spring test?
(i) @DirtiesContest is used to mark the context dirty so that it can be closed
only (i)
(ii) @ContextConfiguration can only point to Spring XML.....
Choose the most appropriate option.

4
MCQ3

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;

refer the code given below


@Component
@Profile("myprofile")
System.setproperty("springprofiles active","myprofile").
class Product{
}
choose from below option to activate the profile"myprofile"

DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
_____ the incomplete code given below:
<beans>
<!--Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager____->
-----
-----
</bean>
@Repository,@PersostenceContext@Transactional(value="tx.Manager")
</beans>
____LIne 1____
public class EmployeeDAOlmpl implements____{
____Line 2_____
-------
____Line 3_____

<web-app>
--------------
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a serviet filter to log IP addresses of the requesis originate. help him from the following
options to identify meant for serviet filters in web.xmi file.
<web-mapping>
<filter-name>...</filter-name>
<urt-pattern>...</urt-pattern>
</filter-mapping>
----------
</web-app>

consider the code given below:


package com.accenture.ikm;
public class Employee(
private List<String>hobbies;
)
<beans>
<bean id="employee"class="com.accenture.ikm.Employee">
<property name="hobbies">
Employee 2 Hobbies : [Playing Cricket Watching Movies]
<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

Refer the incomplete code below


package com.accenture.ikm;
public class job{
private int jobid;
//getter and setter
}
public class person{
@Value("(myjob)").@Configuration @bean
private String[] skills;
--------Line1-----------
private job job;
Person(String[]Skills){
this.skills=skills;
}
}

5
MCQ3

Refer the Spring configuration code given below:


@Configuration
public class AppConfig {
ApplicationContext.ctx=
@bean("address")
new AnnotationConfigurationApplicationContext AppConfig .....
public address createAddress(){
Address address= (Address) ctx get....("address")
Address address = new Address();
return address;
}
Refer the code given below:
@Entity
class BookEntity{
@id
private int bookid; findByPublisherType(String p Type)
private String title;
private String authorName;
private String publisherType;
}
public Integer addEmployee
employeeBean,DepartmentBean
int result= 0;
int
deptId=employeeDepartment
@Transaction(value = "txManager",Propagation.REQUIRED_NEW)
employeeBean.setDepartmentCode
result =
deptId+employeeDepartment
return result;
}
which of the following statements are correct:
(i)Default scope of a veriable is page.
(i) & (ii)
(ii) Session scope veriable will be availabe in all JSP filesif it is accessed in a single session.
(iii) JSTL codes placed inside service() method of translated serviet.
Which method is used to retrieve the recent access time of a request by user by session? getLastAccessedTime()
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>
Book Servlet
</servlet>

<servlet>
<servlet-name>Magazine</servlet-name>
<servlet-class>com.accenture.MagazineServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
Choose from below valid options which provides complete support for creation of JPA specific EntityManagerFactory and
LocalContainerEntityManagerFactoryBean
Transaction Management.
Please Refer the following JSP pages Header.jsp <h1> This is Content of Header</h1> 1
<web-app>

<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the </filter>
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.(Option is not Visible but answer is correct. just cross check in exam) <filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>

</web-app>
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile")
Option 1(options not visible)
public class TestSpringCustomClass{ @Autowired private Employee employee; }
Which is an Abstract class which provides the basic implementation of Sevlet interface except Service method? Generic Servlet
Consider the code below package com.accenture.lkm @Component("address") public class Address @Value("Hyderabad-
Employee Address Banglore,Maharashtra
Telangana")
Refer the code given below @Component @Profile("myProfile") class Product{} Choose from below a valid option to activate
System.setProperty("spring.profiles.active", "myProfile");
the profile "myprofile"

6
MCQ3

@Componet public class Customer{ @Value("${customerID}")


John has created properties file as below config properties CustomerName: James,CustomerID:1009090(Once Verify once.
private int customerID; @Value("${customerName}")
As options are not visible.Go with the Syntax)
private int customerName;
which of the following statements are correct? 1.JVM supports IOC 2. Spring Container manages the instance of the beans
only II
mentioned in the configuration and provides them back to code when needed.
which of the following statements are correct? 1. @Configuration is used to declare a XML file as a Spring configuration 2.
only II
@ComponentScan is used to scan stereotype annotation.
(i) To delete the session...........
want to remove user data from session, what all various options available in (ii) by invoking public void invalidate().
(iii) in web.xml file use<session-timeout>15</session-timeout>
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.uti.Date();
out.print(date);
%>
ii.
<% i & iii
java.uti.Date date =new java.uti.Date();
%>
<%=date;%>
iii.
<%
java.uti.Date date =new java.uti.Date();
out.print(date);
%>
<%date%>

about @DirtiesContext annotation it is used to closed and load the application context.......
to retrieve the recent access times of a request by user from session? getLastAccessedTime()
(i)When you makes any changes in the...........
When Servlet destroy() method will be invoked by servlet container?
(ii)Whwn you stop the server, Destroy method of the.....
Refer the incomplete code given below:
<beans>
<!--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>
____Line1_______ @Repository,@PersistenceContext,@Transactional(value="txManager")
public class EmployeeDAolmpl implements EmployeeDAO{
_____Line2______
private EntityManager entityManager;
____Line3_______
public Integer addEmployee(EmployeeBean employeeBean)
Integer employeeID = 0;
return employeeID;
}

<jsp include page="Header.jsp">


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

7
MCQ3

which of the followign os CORRECT with respect to spring transection propogation


1)propogation typr Ptopogation REQUIRED starts a new transection ,it a method is involved another method and a
transection does not required.
both(1) and (2)
2) propogation type Propogation.REQUIRED_NEW start a new transection.if a method is involvedfrom another method and a
transection already exists
choose most appropriate option

Refer the incomplete code given below: package com.accenture.lkm;


class House{
private String houseNum;
--------------Line1-----------
--------------line2------------
private Rooom room; @Autowired,@Qualifier("room")
//setter and getter}
class Room{
private int roomNum;
//setter and getter}
[further question not visible in mcq3(c) pdf]

Assume that class "Employee" is created with property 'empid" and its setter metod
Refer teh spring configuration below
<bean id="emp" class ='com.Employee">
<property name="empID' value ="john">
</bean>
How many Emplotyees objects will be created if the below code executes successfully?
1
public static void main(String[] arg){
Employee emp1 =(Employee) context.getBean("emp");
Employee emp2 =(Employee) context.getBean("emp");
Employee emp3 = emp1;
}

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____________(profiles="myProfile")
classes, @ActiveProfile
public class TestSpringCustomClass{
@Autowired
(Option was not visible properly spelling may be different)
private Employee employee;
Test cases goes here
}
@Entity
public class CustomerEntity{
@Id @Modifying
private int cid; @Query("delete from CustomerEntity k where ......0
private String cname; int delete(@Param("cpoint") double ....
private double credit;
??getter and setter (the words which are not visible is marked as dots)
}

refer the code given below


@Entity
class BookEntity{
@Id
private int bookId;
private String title; findByPublisherType(String pType)
private String authorName;
private String publishertype;
//getter and setters
}
choose from below the valid option to retrieve the books based on the given publisher type by using query method approach

8
MCQ3

Refer the JSP coide given below and predict the output
<body>
<h3>
<%!
int bookId=1;
int publishYear = 2000; Book Id :2
public int incrementBookId(int bookId){ Publish Year :2001
return bookId++;
}
%>

Which of the fopllowing is CORRECT with respect to propogation type


propogation.REQUIRES_NEW?
option(!!) only
(!) For a method, begin a new transaction always
(!!) if a method is invokes from another method and a transaction exists, then the same transaction is used
choose the most appropriate
Line-X
public integer addEmployeeAndDepartment(EmployeeBean employeeBean,
Departmentbean departmentbean) throws Exception {
int result = 0;
int deptId = employeeDepartmentDAO.addDepartment(departmentBean); @Transaction(value="txmanager",propogation = Propogation.REQUIRES_NEW)
employee.Bean.setDepartmentCode(deptId);
result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which of the following statement are CORRECT with resepect to jsP
(!) Default scope of a variable is page
(!!) Session scope variable will be available in all JSP files if it is accessed in a single session both (!) and (!!)
(!!!) JSTL codes are placed insideservice() method of translater servlet
choose the most appropriate option
From the following identify the correct hierarchy of servelets assuming you are required to
Option not visible
create a registration servlet to process registration request
(!) When you make any changes in the servlet class and save
When Servlet destroy() method will be invoked by servlet Container?
(!!) When you stop the server, destroy method of all existing servlet objects will be mo...
John has created a properties file below: @C... (line not visible)

config.properties public class Customer{


customerName: James @Value("..........");
CustomerId: 1009090 ..........not visible.......
Choose from below a valid option to inject values in Customer bean from confiig.properties file }
Which of the following are correct with respect to Spring:

(i) @Configuration is used to declare an XML file as Spring configuration


option (ii) is correct
(ii) @CompensationScan is used to scan stereotype annotation

Choose most appropriate option


Which of the following statement(s) is/are CORRECT?
option (ii) is correct
(i) JVM Supports IOC
(ii) Spring container manages the instance of the beans mentioned in configuration and provides them back to code when needed.

9
MCQ3

(Not visible) is a web developer wants to create a web page which always lands in portal.accenture.com, whenever user hits on welcome button in index.html given below:

index.html
-----------------------
<form action="MyServelet" method="POST">
<input type="submit" value="welcome">
</form>

Now Blessie started writing the code, all of a sudden, she handed over the job of completing it to you due to unavoidable reasons. Incomplete code is attached below for your reference.

MyServlet.java
--------------------------- response.sendRedirect("https:/portal.accenture.com");
@WebServlet(urlPatterns="/MyServlet)
public class MyServlet extends HttpServlet{
public static final long serialVersionUID = 1L;

public myServlet(){
super();
}

..........................................

@Entity

public class EmployeeEntity{


@Id;
private int employeeId;
List<EmployeeEntity> findBySalaryBetweenOrderBySalaryDesc(Double param1, Double param2))
private String employeeName;
private Double salary;
//Getters and Setters are coded
}

Which of the following are with respect to Spring transaction 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.
both (i) and (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 option.


Choose from below the CORRECT statement about Autowiring. Autowiring requires setters or constructors in bean classes
Consider a web application is created with a welcome index.html mapped with a Servlet class to process the response.

Refer the code below:

index.html
.......................................

<form action="LanguagesServelet" method = "POST">


<input type="checkbox" name="language" value="english"/> English
<input type="checkbox" name="language" value="hindi"/> Hindi
<input type="checkbox" name="language" value="tamil"/> Tamil
<input type="checkbox" name="language" value="malayalam"/> Malayalam
<input type="checkbox" name="language" value="telegu"/> Telegu
<input type="checkbox" name="language" value="kannada"/> Kannada
<input type="checkbox" name="language" value="french"/> French
<input type="checkbox" name="language" value="spanish"/> Spanish
<input type="submit" value="Select...........................Languages"/>
</form>

..................Not Visible....................................
when you want to remove the user data from the session,what all the various options available in JSP option starting with(to,by,in)
mr.john has been assigned the task of creating a servlet filter to log IP addresses.......................web.xml file answer not clear but i guess <web>(option 1)
Refer the following JSP pages,
Header.jsp:
<% @ page language="java" content type="text/html:charset=ISO-8859-1" 1

From the following table match the JSP implicit objects given in tabe A with APIs in servlet package given in table B 1-ii,2-i,3-iv,4-iii
.....which provide the basic implementation of servlet interface except GenericServlet
choose from the below the INCORRECT statement about JSR-300 annotation JSR-300 annotation.....
which of the following is/are CORRECT statement with respect to "spring Test" @DirtiesContext is used to mark the context dirty....
which is an abstract class which provide the basic implementation of servlet interface except service() method GenericServlet

10
MCQ3

Refer the code given below


package com.model;
@component("prodObject")
@profile("myProdProfile")
@ActiveProfiles(profiles="myOrderProfile")
public class Product{
private int productId'
private String productName;
}
Class Library{
private Book book;
Public Library(Book book){ <bean id="library" class="com.accenture.lkm.Library
this.book=book; <constructor-arg>
} <bean class="com.accenture.lkm.Book">
}

Class Book{ </bean>


private string bookName; </constructor-arg>
public Book(String bookName){ </bean>
this.bookName= bookName;
}
}
Refer the below incomplete code for a test class
classes, @ActiveProfiles
@RunWith(SpringJUnit4ClassRunner.class)
<%!
Peter wants a method to add 2 numbers and return the result. He also wanted to place it
public int add(int num1, int num2) {
inside the service method. Help him to select the appropriate JSP scripting.
return num1 + num2;
}
%>
<%
Sadana wants to share the common database data throughtout the application.
String userName = (String)application.getAttribute("dbname")
Help her to identify the appropriate code to achieve the task.
%>
<%@page language="java" contextType = "text/html:charset=ISO-8859-1"
pageEncoding = "ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<%
<meta charset="ISO-8859-1">
String companyName = "Accenture";
<title>Sample</title>
String projectName = "ABC";
</head>
String location = "HYD";
<body>
%>
<%--Add JSP Script here-->
<%= companyName %>
</body>
<%= projectName %>
</html>
<%= location %>
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.

Identify the CORRECT script


Miss Monica has given login request to 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 Translation, Compilation, Instantiation, Service and Destroy
right order
<web-app>
........
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
Mr John has been assigned the task of creating a servlet flter to log IP addresses
of the computers from which the requests originate. Help him to identify the correct snippet
<filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>
..........
</web-app>
Which of the following is CORRECT with respect to spring transaction propogation ?

i)propogation type: Propogation.REQUIRED starts a new transaction.


another method and a transaction does not exist.
i and ii both are correct
ii)propogation type: Propogation.REQUIRED_NEW starts a new transaction.
from another method and a transaction already exist.

Choose appropriate option.

11
MCQ3

Which of the following statements is/are CORRECT with respect to JSP?


(i) Default scope of a variable is application
(ii) JSTL codes are placed inside service() method of translated servlet only 3 is correct
(iii) page scope variable is available only on the page where it is declared
Choose the most appropriate option.
_____ the incomplete code given below:
<beans.....>
<!--Assume dataSource, EntityManagerFactory, configuration are provided>
_______Line1______

<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>

</beans>

Choose from below the valid option to enable declaration of transaction


Management using annotations.

<web-app>
<filter>
<filter-name>....</filter-name>
<filter-class>...</filter-class>
</filter>
Shed the task of creating a servlet filter to log IP addressess of the requests originate.help him from the following options
<filter-mapping>
to identify meant for servelet filters on web.xml file
<filter-name>....</filter-name>
<uri-pattern>...<uri-pattern>
</filter-mapping>
.....
</web-app>

Refer the incomplete code given below:


package com.accenture.lkm;
Class House{
Private String houseNum;
_____Line1____
_____Line2____
private Room room; @Autowired,@Qualifier("room1"),com
//setter and getter
}
class Room{
private int roomNum;
//setter and getter
}
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("com/accenture/lkm/resource/my_springbean.xml");
Select correct options to refer a Spring configuration file inside aa package? Choose2
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("classpath:com/accenture/lkm/resource/my_springbean.xml");
Which of the following is/are CORRECT with respect to Spring transaction methods?
(i) If a method throws runtime/unchecked exception, then rollback will be triggered implicity
only (i)
(ii) If a method throws checked exception, then rollback will be triggered implicitly
Choose the most appropriate option
@Transactiona(value="txManager",rollbackFor=InvalidDummyException.class)
public Integer addEmployeeAndDepartment(EmployeeBean employeeBean, DeaprtmentBean departmentBean) throws Exception{
int result=0;
int
deptId=employeeDepartmentDAO.addDepartment(deprtmentBean):employeeBean.setDepartmentCode(deptId); @Transactional(value="txManager",propogation=Propagtion Requires_NEW)
result=
deptId+employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which object is creared by web container for each Servlet during servlet initilization ServletConfig

12
MCQ3

Refer the incomplete code given below:


package com.model;
public class Author{
public Authore(){
System.out.println("author");
}
}
Below configuration is available in the file located at /com/resources/my_springbean.xml
<bean id="authorobj" class="com.model.Author"></bean>
package come.test; @ContextCOnfiguration(locations="/com/resources/my_springbean.xml")@Test
@Runwith(SpringJUnit4ClassRunner.class)
____Line1____
piblic class TestAuthorClass{
@Autowired
private Author author;
____Line2___
public void testAuthor(){
Assert.assertTrue(author!=null);
}

<bean id="messageSource"
rohit wants to externalize the validation error messages. So, he defined the messages in
class="org springframework.support
'com/accenture/lkm/resoruces/messages_en.properties files'.Help rohit to configure the MesageSource beam in the context file
<property name="name" value="classpath\com\accenture\lkm\resources/messages_en.properties"/>
by choosing a valid option from beiow
</bean>

Rohit deployed the application in the Apache Tomcat Server. But he got an exception as "org.springframework.beans.factory. A) Configure<context:component-scan base-package="com.accenture.lkm.dao"/> in the root context
NoSuchBeanDefinitionException:No qualifying vean of type [com.accenture.lkm.dao.PruchaseDAO]". Choose from below valid confifuration
options to succesfully execute his application C) Configure <mvc:annotation-driven/> in the child context configuration

Rohit wants to display all the validation error messages in purchase jsp. <form:form method="POST" modelAttribute="bean" action="store.html">
Help him to display those messages at the bottom of the page. <table border="3">
Choose from below a valid option. Asssume the below taglib <!--Assume form elements are mentioned appropriately -->
directives are added in the jSP. </table>
<%@taglib url="http://springframework.org/tags/form" prefix="form"%> <spring:hasBindErrors name="bean">
<%@taglib
Consider theurl="http://springframework.org/tags"
code given below: prefix="spring"%> <h3>All Errors</h3>
package com.accenture.lkm; <form:errors path="*" cssClass="error"/>
public class Employee { </spring:hasBindErrors>
private list<String>hobbies: </form:form>
//Getters and Setters are already coded
}
<beans>
<bean id ="employee" class="com.accenture.lkm.Employees">
<property name="hobbies">
<list> Employee 2 hobbies [Playing Cricket Watching Movies]
<value Playing Cricket </value>
<value Watching Movies </value>
<list>
</property>
</bean>
</beans>
public class UIT Tester {
public static void main(String

<web-app>
.......
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a servlet filter to log IP addresses of the request originate. Help him from the following options to identify
meant forservlet filters in web.xml file.
<filter-mapping>
<filter-name>....</filter-name>
<urf-pattern>....</urf-pattern>
</filter mapping>
.......
</web-app>

13
MCQ3

Refer the Spring configuration code gievn below:


1 @Configuration
2 public class AppConfig {
3 @Bean("address")
4 public address createAddress( ) { ApplicationContext ctx =
5 Address address = new Address( ) : new annotationConfigApplicationcontextAppConfig
6 return address ; Address address=(Address)ctx
7 }
8 }
Identifybthe correct code to create spring container object and get the address object injected
Choose the most appropriate option.
Refer the incomplete code given below:
package com.accenture.lkm;
public class Job {
private int jobId:
//getter and setter
}
public class Preson {
private String[] skills;
-----------line1--------------
@Value("=(myjob)"1 @configuration @Bean @Beanvalue ="myjob")
private Job job;
person(String[] skills){
}
//getter and setter
}
Refer the Springconfig java class below
------------------Line2--------------------
public class Springconfig(

Which method is used to retrieve the recent access time of a equeste by user from session?
getLastAccessedTime()
choose from below valid option.
Rohit wants to validate the quantity entered by the customer as mentioned in requirement 2. Choose from the below valid Add @Range(min=1, max=10)anotation in the Bean class
option.[Choose 2] The request handler method should include @Valid to @ModelAnnotation parameter
Rohit wants to receive the requests from customers and forward those request to other components of the application for
further processing . Choose from the most appropriate option, which Rohit performs as his first step as per Spring-MVC
workflow.
A
<bean class="org.springframework>
<property name="prefix">
Rohit wants to navigate to success.jsp page on successful submission. Assume he wrote a handler method to return <value>/WEB-INF/jspViews/</value>
ModelAndView with logical view name as success. He needs to configure a View Resolver bean in child configuration file to </property>
resolve the logical view name.Choose from below a valid option <property name="suffix">
<value>jsp</value>
</property>
</bean>
Rohit wants to create a request handler method in controller that can handle customer request and send the response back to Create a request handler method in the controller to map the request using @RequestMapping annotation and
the response back to the customer. Help rohit to achieve this with a valid option given below. return the ModelAndView object.
Rohit wants to auto populate the items available for the selected SportsType to the respective drop-down box. Assume he A
defined the respective method in the controller which can return Map<String,Double>. Rohit is supposed to bind the key as OPTION NOT VISIBLE
label attribute, value as value attribute in the drop-down box. Choose from below a valid option.
Rohit wants to create an auto populated drop-down box in purchase.jsp page. Help Rohit to implement a proper handler Create a method in the controller to invoke DAO layer method which returns the Map of SportsType with
method in controller that can retrieve sportsType defined in DAO layer. Choose from below a valid option. @ModelAttribute annotation.
From the following tables match the JSP implicit objects given in table A with APIs in
sevlets package given in table B. 1 - ii
Table A Table B 2-i
1) out i) ServletContext
2) application ii) JSPWriter 3 - iv
3) exception
4) page
iii) Object
iv) Threwable
4 - iii

14
MCQ3

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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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


1
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


Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.

15
MCQ3

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(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 both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked

16
Question-wise Details

Section #1

Question 1: Time: 24 Sec Marks: 1 / 1

Choose from below the CORRECT statement about Collection Injection in a bean.

Options Response Answer

<props> element to inject a collection of key-

value pairs, where both key and value are

always of String type.

<props> and <map> elements to inject a

collection of key-value pairs, where both key

and value can be of any type.

<props> element to inject a collection of key-

value pairs, where both key and value can be

of any type.

<map> element to inject a collection of key-

value pairs, where both the key and value are

always of String type.

Question 2: Time: 27 Sec Marks: 1 / 1

Joy is building a web application using servlet. He decided to use servlet filter for intercepting the request and response. Help him
to select the appropriate code from the below options to create a filter

Options Response Answer

public class MyFilter implements Filter {

public void init(FilterConfig fConfig)

throws ServletException {

// TODO Auto-generated method

stub

public void destroy() {

// TODO Auto-generated method

2/19
stub

public void doFilter(ServletRequest

request, ServletResponse response,

FilterChain chain) throws IOException,

ServletException {

PrintWriter out=response.getWriter();

out.print("Before service method

execution<br>");

chain.doFilter(request, response);

out.print("After service method

execution");

public class MyFilter implements Filter {

public void init(FilterConfig fConfig)

throws ServletException {

// TODO Auto-generated method

stub

public void destroy() {

// TODO Auto-generated method

stub

public void doFilter(ServletRequest

request, ServletResponse response) throws

IOException, ServletException {

PrintWriter out=response.getWriter();

out.print("Before service method

execution<br>");

chain.doFilter(request, response);

out.print("After service method

execution");

public class MyFilter implements Filter {

public void init(FilterConfig fConfig)

throws ServletException {

// TODO Auto-generated method

stub

public void destroy() {

// TODO Auto-generated method

stub

3/19
public void doFilter(ServletRequest

request, ServletResponse response,

FilterChain chain) throws IOException,

ServletException {

PrintWriter out=response.getWriter();

out.print("Before service method

execution<br>");

chain.forward(request, response);

out.print("After service method

execution");

public class MyFilter implements Filter {

public void init(FilterConfig fConfig)

throws ServletException {

// TODO Auto-generated method

stub

public void destroy() {

// TODO Auto-generated method

stub

public void doFilter(FilterChain chain)

throws IOException, ServletException {

PrintWriter out=response.getWriter();

out.print("Before service method

execution<br>");

chain.doFilter(request, response);

out.print("After service method

execution");

Question 3: Time: 21 Sec Marks: 1 / 1

4/19
index.jsp
-----------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<jsp:include page="display.jsp">
<jsp:param value="John" name="userName"/>
<jsp:param value="John@accenture.com" name="email"/>
</jsp:include>

display.jsp
-----------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

Username : __________Line1___________
<br/>
Email :__________Line2___________

Choose from below the valid options [Choose 2], in the order as it appears, to print the values of userName and email.

Options Response Answer

<%=request.getParameter("userName") %>

<%=request.getParameter("email") %>

out.println(request.getParameter("userName"))

out.println(request.getParameter("email"));

<@request.getParameter("userName") %>

<%@request.getParameter("email") %>

<c:out value="${param.userName}"></c:out>

<c:out value="${param.email}"></c:out>

Question 4: Time: 20 Sec Marks: 1 / 1

5/19
Refer the incomplete code given below:
package com.accenture.lkm.entity;
@Entity
@Table(name="Doctor")
public class DoctorEntity {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String firstName;
private String lastName;
//setters and getters
}
package com.accenture.lkm.dao;
public interface DoctorDAO extends __________Line1___________{
List<DoctorEntity> __________Line2________________(String firstName);
}
Choose from below the valid option, in the order as it appears, to get doctors details, whose first name starts with 'J' by using
Query Method Approach.

Options Response Answer

CrudRepository<DoctorEntity, Integer>,

findByFirstNameLike

CurdRepository<DoctorEntity, Integer>,

searchByFirstNameLike

CrudRepository<Integer, DoctorEntity>,

getByFirstNameLike

CrudRepository<DoctorEntity, int>,

selectByFirstNameLike

Question 5: Time: 21 Sec Marks: 1 / 1

BookMyBus application allows users to search for bus services in a route. It has a servlet by name SearchBus to respond to such
requests. Given that it is likely to recieve 100 or more requests simultaneously. How likely the web container would respond?

6/19
Options Response Answer

Web container process each request by

spawning threads.

Web container process each request by

creating multiple servlet instances.

Web container process each request by

forwarding it to another web container.

Question 6: Time: 34 Sec Marks: 1 / 1

7/19
Refer the incomplete code given below:
package com.accenture.lkm;
public class Product {
private int productNum;
private String name;
private int barCode;
// Assume setter and getter are generated
}
Below configuration is available in the file located at /com/accenture/lkm/resources/my_springbean.xml
<bean class="com.accenture.lkm.Product" id="prodobj">
<property name="productNum" value="100"></property>
<property name="name" value="Laptop"></property>
<property name="barCode" value="200000"></property>
</bean>
package com.accenture.lkm.test;
@RunWith(SpringJUnit4ClassRunner.class)
_______________1_____________________
public class TestProductClass {
@Autowired
private Product product;
@Test
public void testProduct(){
System.out.println("prod");
Assert.assertTrue(product!=null);
}
____________________2_______________________
@Test
public void testProductBarCode(){
Assert._______3________(product.getBarCode()!=200000);

}
}
Choose from below a valid option to complete the above code, in order to load ApplicationContext for every test method and to
complete the test

8/19
Options Response Answer

@Configuration(locations="/com/accenture/lkm

/resources/my_springbean.xml"),

@DirtiesContext(methodMode=MethodMode.B

EFORE_METHOD), assertFalse

@TestConfiguration(locations="/com/accentur

e/lkm/resources/my_springbean.xml"),

@DirtiesContext, assertFalse

@Configuration(locations="/com/accenture/lkm

/resources/my_springbean.xml"),

@CreateContext(methodMode=MethodMode.

BEFORE_METHOD), assertFalse

@ContextConfiguration(locations="/com/accen

ture/lkm/resources/my_springbean.xml"),

@DirtiesContext(methodMode=MethodMode.B

EFORE_METHOD), assertFalse

Question 7: Time: 40 Sec Marks: 1 / 1

Refer the following table.


MovieName Genre Language
Spartans 300 History English
Dunkirk War film English

From the following help Miss.Nancy to identify CORRECT JSTL tags for creating such table in a JSP page.MovieBean is a bean
with fields movieName, genre and language with getters and setters.

Options Response Answer

<%@page

import="com.accenture.lkm.business.bean.Mo

vieBean"%>

<%@page import="java.util.ArrayList"%>

<%@ page language="java"

contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<%@taglib

uri="http://java.sun.com/jsp/jstl/core" prefix="c"

%>

9/19
<!DOCTYPE html>

<html>

<head>

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

<title>Sample</title>

</head>

<body>

<%

ArrayList<MovieBean> list= new ArrayList();

MovieBean one= new MovieBean();

one.setMovieName("Dunkirk");

one.setGenre("History");

one.setLanguage("English");

MovieBean two= new MovieBean();

two.setMovieName("Spartans 300");

two.setGenre("War film");

two.setLanguage("English");

list.add(one);

list.add(two);

request.setAttribute("movieList", list);

%>

<table>

<tr>

<th>Movie Name</th><th>Genre</th>

<th>Language</th></tr>

<c:forEach items="${movieList}" var="movie">

<tr><td>${movie.movieName }</td>

<td>${movie.genre}</td>

<td>${movie.language}</td></tr>

</c:forEach>

</table>

</body>

</html>

<%@page

import="com.accenture.lkm.business.bean.Mo

vieBean"%>

<%@page import="java.util.ArrayList"%>

<%@ page language="java"

contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<%@taglib

uri="http://java.sun.com/jsp/jstl/core" prefix="c"

%>

10/19
<!DOCTYPE html>

<html>

<head>

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

<title>Sample</title>

</head>

<body>

<%

ArrayList<MovieBean> list= new ArrayList();

MovieBean one= new MovieBean();

one.setMovieName("Dunkirk");

one.setGenre("History");

one.setLanguage("English");

MovieBean two= new MovieBean();

two.setMovieName("Spartans 300");

two.setGenre("War film");

two.setLanguage("English");

list.add(one);

list.add(two);

requestScope.setAttribute("movieList", list);

%>

<table>

<tr>

<th>Movie Name</th><th>Genre</th>

<th>Language</th></tr>

<c:forEach var="${movieList}" items="movie">

<tr><td>${movie.movieName }</td>

<td>${movie.genre}</td>

<td>${movie.language}</td></tr>

</c:forEach>

</table>

</body>

</html>

<%@page

import="com.accenture.lkm.business.bean.Mo

vieBean"%>

<%@page import="java.util.ArrayList"%>

<%@ page language="java"

contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<!DOCTYPE html>

<html>

<head>

11/19
<meta charset="ISO-8859-1">

<title>Sample</title>

</head>

<body>

<%

ArrayList<MovieBean> list= new ArrayList();

MovieBean one= new MovieBean();

one.setMovieName("Dunkirk");

one.setGenre("History");

one.setLanguage("English");

MovieBean two= new MovieBean();

two.setMovieName("Spartans 300");

two.setGenre("War film");

two.setLanguage("English");

list.add(one);

list.add(two);

request.setAttribute("movieList", list);

%>

<table>

<tr>

<th>Movie Name</th><th>Genre</th>

<th>Language</th></tr>

<c:forEach var="movieList" items="movie">

<tr><td>${movie.movieName }</td>

<td>${movie.genre}</td>

<td>${movie.language}</td></tr>

</c:forEach>

</table>

</body>

</html>

Question 8: Time: 23 Sec Marks: 1 / 1

Refer the following code


CustomerBean.java:
package com.accenture.lkm;
public class CustomerBean {
private Integer customerId;
private String customerName;
//code for getters and setters
}

12/19
Utility.java:
package com.accenture.lkm;
import java.util.*;
public class Utility {
public List<CustomerBean>getCustomerDetails(){
List<CustomerBean> cList=new ArrayList<CustomerBean>();
CustomerBean c1=new CustomerBean();
c1.setCustomerId(1000);
c1.setCustomerName("John");
CustomerBean c2=new CustomerBean();
c2.setCustomerId(1001);
c2.setCustomerName("Mark");
cList.add(c1);
cList.add(c2);
return cList;
}
}

JSTLDemo.jsp:
<html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page import="com.accenture.lkm.Utility" %>
<%@page import="com.accenture.lkm.CustomerBean" %>
<%@page import="java.util.List" %>
<body>
<%
Utility u=new Utility();
List<CustomerBean> customerList=u.getCustomerDetails();
request.setAttribute("custList",customerList);
%>
<table border="1">
<c:forEach var="index" items="${custList}">
<tr> <td><c:out value="${index.customerId}"></c:out></td>
<td><c:out value="${index.customerName}"></c:out></td>
</tr>
</c:forEach>
</table>
</body>
</html>

What will be outcome when executing the above code?

13/19
Options Response Answer

1000 John

1001 Mark

1000 Mark

1001 John

1001 Mark

1002 John

1001 John

1002 Mark

Question 9: Time: 22 Sec Marks: 1 / 1

14/19
Refer the following code
LoginForm.html:
<html>
<body>
<form action="Login.jsp">
<table border="1">
<tr> <td> User Name </td><td> <input type="text" name="uname"> </td></tr>
<tr> <td> Password </td><td> <input type="password" name="pwd"> </td>
</table>
<input type="submit" value="submit" />
</form>
</body>
</html>

Login.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>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<body>
<c:if test="${param.uname=='System' and param.pwd=='admin'}">
<jsp:forward page="Success.jsp">
<jsp:param value="${param.uname}" name="share"/>
</jsp:forward>
</c:if>
</body>
</html>

Success.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>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<body>
<h2> Login Success, Welcome <c:out value="${param.share}"></c:out> </h2>
</body>
</html>

What will be the outcome if the user is entering the following data in LoginForm.html?
uname: System
pwd: admin

15/19
Options Response Answer

Login Success, Welcome System

Login Success, Welcome null

No output

Login Success, Welcome admin

Question 10: Time: 22 Sec Marks: 1 / 1

Assume that you are creating a web app to get book details from the user and to display it in the response page using Servlet,
JSP and JSTL

Refer below BookForm.jsp - is used to get book details from the user

<form action="book" method="POST">


<table>
<tr><td> Book Id</td><td> <input type="text" name="bookId"/></td></tr>
<tr><td> Book Name</td><td> <input type="text" name="bookName"/></td></tr>
<tr><td> Author</td><td> <input type="text" name="author"/></td></tr>
<tr><td> Price</td><td> <input type="text" name="price"/></td></tr>
</table>
<br>
<input type="submit" value="Submit" />
</form>

Refer below BookServlet.java is used to set the book details in the session so that it can be displayed in Book.jsp page

@WebServlet(value="/book")
public class BookServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public BookServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().append("Served at: ").append(request.getContextPath());
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out=response.getWriter();
HttpSession session=request.getSession();
Book book=new Book();
book.setBookId(Integer.parseInt(request.getParameter("bookId")));

16/19
book.setBookName(request.getParameter("bookName"));
book.setAuthor(request.getParameter("author"));
book.setPrice(Double.parseDouble(request.getParameter("price")));
session.setAttribute("bookBean", book);
RequestDispatcher rd=request.getRequestDispatcher("/Book.jsp");
rd.forward(request, response);
}
}

Check below in Book.jsp jsp comment line is added , we must fill code in it to display the book details added in session from
BookServlet using JSTL. Assume that jstl core library is added in the application.

Book.jsp
--------
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<body>
<%@ page import="com.accenture.bean.Book" %>

<%-- JSTL code goes here --%>

</body>

Choose from the below a valid code to be filled

17/19
Options Response Answer

<c:set var="bean"

value="${requestScope.bookBean}"/>

<c:out value="Book Details"/><br>

<c:out value="Book Id: ${bean.bookId}"/>

<br>

<c:out value="Book Name:

${bean.bookName}"/><br>

<c:out value="Author: ${bean.author}"/>

<br>

<c:out value="Price: ${bean.price}"/><br>

<c:set var="bean"

value="${sessionScope.bookBean}"/>

<c:out value="Book Details"/><br>

<c:out value="Book Id: ${bean.bookId}"/>

<br>

<c:out value="Book Name:

${bean.bookName}"/><br>

<c:out value="Author: ${bean.author}"/>

<br>

<c:out value="Price: ${bean.price}"/><br>

<c:set var="bean" value="${bookBean}"/>

<c:out value="Book Details"/><br>

<c:out value="Book Id: ${bean.bookId}"/>

<br>

<c:out value="Book Name:

${bean.bookName}"/><br>

<c:out value="Author: ${bean.author}"/>

<br>

<c:out value="Price: ${bean.price}"/><br>

<c:set var="bean" value="bookBean"/>

<c:out value="Book Details"/><br>

<c:out value="Book Id:

${bean.getBookId}"/><br>

<c:out value="Book Name:

${bean.getBookName}"/><br>

<c:out value="Author:

${bean.getAuthor}"/><br>

<c:out value="Price: ${bean.getPrice}"/>

<br>

18/19
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="library" class="com.accenture.lkm.Library">


<cons........>
<bean class............Book">
<constructor-arg value="book1"></constructor-arg>
(
</bean>
</constructor-arg>
</bean>

JSR-330 annotations JSR-330 annotations can not beuesd along with Spring framework annotations

To delete the session attribute we can call public void removeAttributes(String name) , By invoking public void
invaliddate(), In web.xml file use <session->

@RunWith(Spring.Junit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile") Public class TestSpringCustomClass{
public class TestSpringCustomClass{ @Autowired private Employee employee; } ___
___
}
Choose from below a valid combination to complete the above code____

@Component class Customer{----------private Cart cart; } @Value

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


_____Line 1_____
class Customer{
private int customerId;
_____Line 2_____
private Address address;
}
______Line 3_____ @Component,@Autowied,@Coponent,@Configuration,AnnottionConfigApplicationContext
class Address{
public Address(){
------
------
-------
}
@Entity class BookEntity{ @Id private int bookId; private String authorName; private String publisherType; //getter and setters }

DriverManageDataSource , LocalContainerEntityManagerFactoryBean,@Respository ,Autowired

@Respository, @PersistenceContext , @Transactional(value="Manager")


Which of the following is correct statement with respect to Spring test @DirtiesContext

@Configuration public class AppConfig { @Bean("address") public Address creatAddress() { Adsress address= new Address(); ApplicatonContext ctx=new AnnotationConfigApplicationContext(AppConfig.class); Address address=(Address)
return Address; }} ctx.getBean("addres");

Refer the incomplete code given below:

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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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
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


Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
Already Repeated Question
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) Session scope variable will be available in all JSP files if it is accessed in a single session both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
Already Repeated Question
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked

When servlet destroy() method is invoked by servlet container?


Which of the following is correct statement with respect to Spring test @DirtiesContext

RegistrationServlet extends HTTPServlet


From the following identify the correct hierarchy of servlets assuming you are required to create a registration servlet to
HttPServlet extends GenericServlet
process registration request.
GenericServlet implements Servlets

Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.
When you want to remove the user data from session, what all the various options available in JSP? All option, other than Perform log out ...
From the following tables match the jsp implicit objects given in table A with Api's in servlets package given in table B
Table A Table B
1.out 1.Servlet c 1. OUT - JSPWRITER 2. APPLICATION- SERVLETCONFIG 3.
2.application 2.JSPWriter EXCEPTION . THROWABLE 4. PAGE - OBJECT
3.exception 3. Object
4.page 4.Throwable
which provides the basic implementation of Servlet interface except Generic Servlet
Which is an abstract class which provides the basic implementation of servlet interface except service() method? Generic Servlet
Refer the code given below
package com.model;
@component("prodObject")
@Profile("myProdProfile")
public classs Product
{
private int productid;
private String productName;
}
@ActiveProfiles(profiles="myorderProfile")
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 ....


Refer the code given below
@Entity
public class EmployeeEntity{
@Id @Modyfying
private int empId; @Query("update EmployeeEntity
private String name;
private double salary; Options are not clear
//getter and setter methods
}
Choose the valid implementation of the Update query to update employee salary, using Spring JPA Data.
From the following identify TWO INCORRECT statements about ServletCoding objects.
i) It is not created for each servlet dusring servlet initialization.
ii) It will be available to all servletsof an application. i and ii only
iii) Its lifetime is until the servlet class object is destroyed.
iv) One object per servlet class
Raghav must pre populate doctor's names from doctors table in a drop down list when patient is booking appointment online.
. He has written required method implementation in DAO and service layer.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Raghav added following query in orm.xml file

<named-query name="getPatientsData">
@Query(name="getPatientData")
<query>select p.pName,p.appointmentDate from patients p </query>
List<String> getPatientsData();
</named-query>

Select the correct methid declaration in DAO interface. Refer the patients class and patients table.
Raghav has added a method to update the details of the patients as below
public interface PatientsDAO
{
@Query(name="updateQuery1") @Modifying is not used on the method output should return the string data which i.. the updated
int updateAppointmentSlot(Patients patients, String new Appointment(Time); appointment time.
}
But he getting exception as "DML operation is not supported".What went wrong?

Raghav added the following methods in Service and DAO implementation classes to add paitent's information in db.
//service implementation
@transactional(propagation=Propagation.REQUIRED)
Integer addPatientInService(Patients patient)
{
//calling DAO method
}
addPatientInDAO() method always exceutes in a new transaction rather than the interface started in service
//DAO implementation layer of addPatientInService() method.
@transactional(propagation=Propagation.REQUIRES_NEW)
Integer addPatientInService(Patients patient)
{
//implementation
}

what is the behaviour of the addPatientInDAO() method?


Which of the following is/are correct statement(s) with respect to spring test?
(i) @DirtiesContest is used to mark the context dirty so that it can be closed
only (i)
(ii) @ContextConfiguration can only point to Spring XML.....
Choose the most appropriate option.
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;

refer the code given below


@Component
@Profile("myprofile")
System.setproperty("springprofiles active","myprofile").
class Product{
}
choose from below option to activate the profile"myprofile"

DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
Which of the following is correct statement with respect to Spring test @DirtiesContext

_____ the incomplete code given below:


<beans>
<!--Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager____->
-----
-----
</bean>
@Repository,@PersostenceContext@Transactional(value="tx.Manager")
</beans>
____LIne 1____
public class EmployeeDAOlmpl implements____{
____Line 2_____
-------
____Line 3_____

<web-app>
--------------
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a serviet filter to log IP addresses of the requesis originate. help him from the following
options to identify meant for serviet filters in web.xmi file.
<web-mapping>
<filter-name>...</filter-name>
<urt-pattern>...</urt-pattern>
</filter-mapping>
----------
</web-app>

consider the code given below:


package com.accenture.ikm;
public class Employee(
private List<String>hobbies;
)
<beans>
<bean id="employee"class="com.accenture.ikm.Employee">
<property name="hobbies">
Employee 2 Hobbies : [Playing Cricket Watching Movies]
<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
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code below


package com.accenture.ikm;
public class job{
private int jobid;
//getter and setter
}
public class person{
@Value("(myjob)").@Configuration @bean
private String[] skills;
--------Line1-----------
private job job;
Person(String[]Skills){
this.skills=skills;
}
}
Refer the Spring configuration code given below:
@Configuration
public class AppConfig {
ApplicationContext.ctx=
@bean("address")
new AnnotationConfigurationApplicationContext AppConfig .....
public address createAddress(){
Address address= (Address) ctx get....("address")
Address address = new Address();
return address;
}
Refer the code given below:
@Entity
class BookEntity{
@id
private int bookid; findByPublisherType(String p Type)
private String title;
private String authorName;
private String publisherType;
}
public Integer addEmployee
employeeBean,DepartmentBean
int result= 0;
int
deptId=employeeDepartment
@Transaction(value = "txManager",Propagation.REQUIRED_NEW)
employeeBean.setDepartmentCode
result =
deptId+employeeDepartment
return result;
}
which of the following statements are correct:
(i)Default scope of a veriable is page.
(i) & (ii)
(ii) Session scope veriable will be availabe in all JSP filesif it is accessed in a single session.
(iii) JSTL codes placed inside service() method of translated serviet.
Which method is used to retrieve the recent access time of a request by user by session? getLastAccessedTime()
Which of the following is correct statement with respect to Spring test @DirtiesContext

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>
Book Servlet
</servlet>

<servlet>
<servlet-name>Magazine</servlet-name>
<servlet-class>com.accenture.MagazineServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
Choose from below valid options which provides complete support for creation of JPA specific EntityManagerFactory and
LocalContainerEntityManagerFactoryBean
Transaction Management.
Please Refer the following JSP pages Header.jsp <h1> This is Content of Header</h1> 1
<web-app>

<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the </filter>
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.(Option is not Visible but answer is correct. just cross check in exam) <filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>

</web-app>
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile")
Option 1(options not visible)
public class TestSpringCustomClass{ @Autowired private Employee employee; }
Which is an Abstract class which provides the basic implementation of Sevlet interface except Service method? Generic Servlet
Consider the code below package com.accenture.lkm @Component("address") public class Address @Value("Hyderabad-
Employee Address Banglore,Maharashtra
Telangana")
Refer the code given below @Component @Profile("myProfile") class Product{} Choose from below a valid option to activate
System.setProperty("spring.profiles.active", "myProfile");
the profile "myprofile"
@Componet public class Customer{ @Value("${customerID}")
John has created properties file as below config properties CustomerName: James,CustomerID:1009090(Once Verify once.
private int customerID; @Value("${customerName}")
As options are not visible.Go with the Syntax)
private int customerName;
which of the following statements are correct? 1.JVM supports IOC 2. Spring Container manages the instance of the beans
only II
mentioned in the configuration and provides them back to code when needed.
which of the following statements are correct? 1. @Configuration is used to declare a XML file as a Spring configuration 2.
only II
@ComponentScan is used to scan stereotype annotation.
(i) To delete the session...........
want to remove user data from session, what all various options available in (ii) by invoking public void invalidate().
(iii) in web.xml file use<session-timeout>15</session-timeout>
Which of the following is correct statement with respect to Spring test @DirtiesContext

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.uti.Date();
out.print(date);
%>
ii.
<% i & iii
java.uti.Date date =new java.uti.Date();
%>
<%=date;%>
iii.
<%
java.uti.Date date =new java.uti.Date();
out.print(date);
%>
<%date%>

about @DirtiesContext annotation it is used to closed and load the application context.......
to retrieve the recent access times of a request by user from session? getLastAccessedTime()
(i)When you makes any changes in the...........
When Servlet destroy() method will be invoked by servlet container?
(ii)Whwn you stop the server, Destroy method of the.....
Refer the incomplete code given below:
<beans>
<!--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>
____Line1_______ @Repository,@PersistenceContext,@Transactional(value="txManager")
public class EmployeeDAolmpl implements EmployeeDAO{
_____Line2______
private EntityManager entityManager;
____Line3_______
public Integer addEmployee(EmployeeBean employeeBean)
Integer employeeID = 0;
return employeeID;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<jsp include page="Header.jsp">


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

which of the followign os CORRECT with respect to spring transection propogation


1)propogation typr Ptopogation REQUIRED starts a new transection ,it a method is involved another method and a
transection does not required.
both(1) and (2)
2) propogation type Propogation.REQUIRED_NEW start a new transection.if a method is involvedfrom another method and a
transection already exists
choose most appropriate option

Refer the incomplete code given below: package com.accenture.lkm;


class House{
private String houseNum;
--------------Line1-----------
--------------line2------------
private Rooom room; @Autowired,@Qualifier("room")
//setter and getter}
class Room{
private int roomNum;
//setter and getter}
[further question not visible in mcq3(c) pdf]

Assume that class "Employee" is created with property 'empid" and its setter metod
Refer teh spring configuration below
<bean id="emp" class ='com.Employee">
<property name="empID' value ="john">
</bean>
How many Emplotyees objects will be created if the below code executes successfully?
1
public static void main(String[] arg){
Employee emp1 =(Employee) context.getBean("emp");
Employee emp2 =(Employee) context.getBean("emp");
Employee emp3 = emp1;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____________(profiles="myProfile")
classes, @ActiveProfile
public class TestSpringCustomClass{
@Autowired
(Option was not visible properly spelling may be different)
private Employee employee;
Test cases goes here
}
@Entity
public class CustomerEntity{
@Id @Modifying
private int cid; @Query("delete from CustomerEntity k where ......0
private String cname; int delete(@Param("cpoint") double ....
private double credit;
??getter and setter (the words which are not visible is marked as dots)
}

refer the code given below


@Entity
class BookEntity{
@Id
private int bookId;
private String title; findByPublisherType(String pType)
private String authorName;
private String publishertype;
//getter and setters
}
choose from below the valid option to retrieve the books based on the given publisher type by using query method approach
Refer the JSP coide given below and predict the output
<body>
<h3>
<%!
int bookId=1;
int publishYear = 2000; Book Id :2
public int incrementBookId(int bookId){ Publish Year :2001
return bookId++;
}
%>

Which of the fopllowing is CORRECT with respect to propogation type


propogation.REQUIRES_NEW?
option(!!) only
(!) For a method, begin a new transaction always
(!!) if a method is invokes from another method and a transaction exists, then the same transaction is used
choose the most appropriate
Line-X
public integer addEmployeeAndDepartment(EmployeeBean employeeBean,
Departmentbean departmentbean) throws Exception {
int result = 0;
int deptId = employeeDepartmentDAO.addDepartment(departmentBean); @Transaction(value="txmanager",propogation = Propogation.REQUIRES_NEW)
employee.Bean.setDepartmentCode(deptId);
result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

Which of the following statement are CORRECT with resepect to jsP


(!) Default scope of a variable is page
(!!) Session scope variable will be available in all JSP files if it is accessed in a single session both (!) and (!!)
(!!!) JSTL codes are placed insideservice() method of translater servlet
choose the most appropriate option
From the following identify the correct hierarchy of servelets assuming you are required to
Option not visible
create a registration servlet to process registration request
(!) When you make any changes in the servlet class and save
When Servlet destroy() method will be invoked by servlet Container?
(!!) When you stop the server, destroy method of all existing servlet objects will be mo...
John has created a properties file below: @C... (line not visible)

config.properties public class Customer{


customerName: James @Value("..........");
CustomerId: 1009090 ..........not visible.......
Choose from below a valid option to inject values in Customer bean from confiig.properties file }
Which of the following are correct with respect to Spring:

(i) @Configuration is used to declare an XML file as Spring configuration


option (ii) is correct
(ii) @CompensationScan is used to scan stereotype annotation

Choose most appropriate option


Which of the following statement(s) is/are CORRECT?
option (ii) is correct
(i) JVM Supports IOC
(ii) Spring container manages the instance of the beans mentioned in configuration and provides them back to code when needed.
(Not visible) is a web developer wants to create a web page which always lands in portal.accenture.com, whenever user hits on welcome button in index.html given below:

index.html
-----------------------
<form action="MyServelet" method="POST">
<input type="submit" value="welcome">
</form>

Now Blessie started writing the code, all of a sudden, she handed over the job of completing it to you due to unavoidable reasons. Incomplete code is attached below for your reference.

MyServlet.java
--------------------------- response.sendRedirect("https:/portal.accenture.com");
@WebServlet(urlPatterns="/MyServlet)
public class MyServlet extends HttpServlet{
public static final long serialVersionUID = 1L;

public myServlet(){
super();
}

..........................................
Which of the following is correct statement with respect to Spring test @DirtiesContext

@Entity

public class EmployeeEntity{


@Id;
private int employeeId;
List<EmployeeEntity> findBySalaryBetweenOrderBySalaryDesc(Double param1, Double param2))
private String employeeName;
private Double salary;
//Getters and Setters are coded
}

Which of the following are with respect to Spring transaction 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.
both (i) and (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 option.


Choose from below the CORRECT statement about Autowiring. Autowiring requires setters or constructors in bean classes
Consider a web application is created with a welcome index.html mapped with a Servlet class to process the response.

Refer the code below:

index.html
.......................................

<form action="LanguagesServelet" method = "POST">


<input type="checkbox" name="language" value="english"/> English
<input type="checkbox" name="language" value="hindi"/> Hindi
<input type="checkbox" name="language" value="tamil"/> Tamil
<input type="checkbox" name="language" value="malayalam"/> Malayalam
<input type="checkbox" name="language" value="telegu"/> Telegu
<input type="checkbox" name="language" value="kannada"/> Kannada
<input type="checkbox" name="language" value="french"/> French
<input type="checkbox" name="language" value="spanish"/> Spanish
<input type="submit" value="Select...........................Languages"/>
</form>

..................Not Visible....................................
when you want to remove the user data from the session,what all the various options available in JSP option starting with(to,by,in)
mr.john has been assigned the task of creating a servlet filter to log IP addresses.......................web.xml file answer not clear but i guess <web>(option 1)
Refer the following JSP pages,
Header.jsp:
<% @ page language="java" content type="text/html:charset=ISO-8859-1" 1

From the following table match the JSP implicit objects given in tabe A with APIs in servlet package given in table B 1-ii,2-i,3-iv,4-iii
.....which provide the basic implementation of servlet interface except GenericServlet
choose from the below the INCORRECT statement about JSR-300 annotation JSR-300 annotation.....
which of the following is/are CORRECT statement with respect to "spring Test" @DirtiesContext is used to mark the context dirty....
which is an abstract class which provide the basic implementation of servlet interface except service() method GenericServlet
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the code given below


package com.model;
@component("prodObject")
@profile("myProdProfile")
@ActiveProfiles(profiles="myOrderProfile")
public class Product{
private int productId'
private String productName;
}
Class Library{
private Book book;
Public Library(Book book){ <bean id="library" class="com.accenture.lkm.Library
this.book=book; <constructor-arg>
} <bean class="com.accenture.lkm.Book">
}

Class Book{ </bean>


private string bookName; </constructor-arg>
public Book(String bookName){ </bean>
this.bookName= bookName;
}
}
Refer the below incomplete code for a test class
classes, @ActiveProfiles
@RunWith(SpringJUnit4ClassRunner.class)
<%!
Peter wants a method to add 2 numbers and return the result. He also wanted to place it
public int add(int num1, int num2) {
inside the service method. Help him to select the appropriate JSP scripting.
return num1 + num2;
}
%>
<%
Sadana wants to share the common database data throughtout the application.
String userName = (String)application.getAttribute("dbname")
Help her to identify the appropriate code to achieve the task.
%>
<%@page language="java" contextType = "text/html:charset=ISO-8859-1"
pageEncoding = "ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<%
<meta charset="ISO-8859-1">
String companyName = "Accenture";
<title>Sample</title>
String projectName = "ABC";
</head>
String location = "HYD";
<body>
%>
<%--Add JSP Script here-->
<%= companyName %>
</body>
<%= projectName %>
</html>
<%= location %>
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.

Identify the CORRECT script


Miss Monica has given login request to 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 Translation, Compilation, Instantiation, Service and Destroy
right order
Which of the following is correct statement with respect to Spring test @DirtiesContext

<web-app>
........
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
Mr John has been assigned the task of creating a servlet flter to log IP addresses
of the computers from which the requests originate. Help him to identify the correct snippet
<filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>
..........
</web-app>
Which of the following is CORRECT with respect to spring transaction propogation ?

i)propogation type: Propogation.REQUIRED starts a new transaction.


another method and a transaction does not exist.
i and ii both are correct
ii)propogation type: Propogation.REQUIRED_NEW starts a new transaction.
from another method and a transaction already exist.

Choose appropriate option.


Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) JSTL codes are placed inside service() method of translated servlet only 3 is correct
(iii) page scope variable is available only on the page where it is declared
Choose the most appropriate option.
_____ the incomplete code given below:
<beans.....>
<!--Assume dataSource, EntityManagerFactory, configuration are provided>
_______Line1______

<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>

</beans>

Choose from below the valid option to enable declaration of transaction


Management using annotations.

<web-app>
<filter>
<filter-name>....</filter-name>
<filter-class>...</filter-class>
</filter>
Shed the task of creating a servlet filter to log IP addressess of the requests originate.help him from the following options
<filter-mapping>
to identify meant for servelet filters on web.xml file
<filter-name>....</filter-name>
<uri-pattern>...<uri-pattern>
</filter-mapping>
.....
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code given below:


package com.accenture.lkm;
Class House{
Private String houseNum;
_____Line1____
_____Line2____
private Room room; @Autowired,@Qualifier("room1"),com
//setter and getter
}
class Room{
private int roomNum;
//setter and getter
}
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("com/accenture/lkm/resource/my_springbean.xml");
Select correct options to refer a Spring configuration file inside aa package? Choose2
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("classpath:com/accenture/lkm/resource/my_springbean.xml");
Which of the following is/are CORRECT with respect to Spring transaction methods?
(i) If a method throws runtime/unchecked exception, then rollback will be triggered implicity
only (i)
(ii) If a method throws checked exception, then rollback will be triggered implicitly
Choose the most appropriate option
@Transactiona(value="txManager",rollbackFor=InvalidDummyException.class)
public Integer addEmployeeAndDepartment(EmployeeBean employeeBean, DeaprtmentBean departmentBean) throws Exception{
int result=0;
int
deptId=employeeDepartmentDAO.addDepartment(deprtmentBean):employeeBean.setDepartmentCode(deptId); @Transactional(value="txManager",propogation=Propagtion Requires_NEW)
result=
deptId+employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which object is creared by web container for each Servlet during servlet initilization ServletConfig

Refer the incomplete code given below:


package com.model;
public class Author{
public Authore(){
System.out.println("author");
}
}
Below configuration is available in the file located at /com/resources/my_springbean.xml
<bean id="authorobj" class="com.model.Author"></bean>
package come.test; @ContextCOnfiguration(locations="/com/resources/my_springbean.xml")@Test
@Runwith(SpringJUnit4ClassRunner.class)
____Line1____
piblic class TestAuthorClass{
@Autowired
private Author author;
____Line2___
public void testAuthor(){
Assert.assertTrue(author!=null);
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="messageSource"
rohit wants to externalize the validation error messages. So, he defined the messages in
class="org springframework.support
'com/accenture/lkm/resoruces/messages_en.properties files'.Help rohit to configure the MesageSource beam in the context file
<property name="name" value="classpath\com\accenture\lkm\resources/messages_en.properties"/>
by choosing a valid option from beiow
</bean>

Rohit deployed the application in the Apache Tomcat Server. But he got an exception as "org.springframework.beans.factory. A) Configure<context:component-scan base-package="com.accenture.lkm.dao"/> in the root context
NoSuchBeanDefinitionException:No qualifying vean of type [com.accenture.lkm.dao.PruchaseDAO]". Choose from below valid confifuration
options to succesfully execute his application C) Configure <mvc:annotation-driven/> in the child context configuration

Rohit wants to display all the validation error messages in purchase jsp. <form:form method="POST" modelAttribute="bean" action="store.html">
Help him to display those messages at the bottom of the page. <table border="3">
Choose from below a valid option. Asssume the below taglib <!--Assume form elements are mentioned appropriately -->
directives are added in the jSP. </table>
<%@taglib url="http://springframework.org/tags/form" prefix="form"%> <spring:hasBindErrors name="bean">
<%@taglib
Consider theurl="http://springframework.org/tags"
code given below: prefix="spring"%> <h3>All Errors</h3>
package com.accenture.lkm; <form:errors path="*" cssClass="error"/>
public class Employee { </spring:hasBindErrors>
private list<String>hobbies: </form:form>
//Getters and Setters are already coded
}
<beans>
<bean id ="employee" class="com.accenture.lkm.Employees">
<property name="hobbies">
<list> Employee 2 hobbies [Playing Cricket Watching Movies]
<value Playing Cricket </value>
<value Watching Movies </value>
<list>
</property>
</bean>
</beans>
public class UIT Tester {
public static void main(String

<web-app>
.......
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a servlet filter to log IP addresses of the request originate. Help him from the following options to identify
meant forservlet filters in web.xml file.
<filter-mapping>
<filter-name>....</filter-name>
<urf-pattern>....</urf-pattern>
</filter mapping>
.......
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the Spring configuration code gievn below:


1 @Configuration
2 public class AppConfig {
3 @Bean("address")
4 public address createAddress( ) { ApplicationContext ctx =
5 Address address = new Address( ) : new annotationConfigApplicationcontextAppConfig
6 return address ; Address address=(Address)ctx
7 }
8 }
Identifybthe correct code to create spring container object and get the address object injected
Choose the most appropriate option.
Refer the incomplete code given below:
package com.accenture.lkm;
public class Job {
private int jobId:
//getter and setter
}
public class Preson {
private String[] skills;
-----------line1--------------
@Value("=(myjob)"1 @configuration @Bean @Beanvalue ="myjob")
private Job job;
person(String[] skills){
}
//getter and setter
}
Refer the Springconfig java class below
------------------Line2--------------------
public class Springconfig(

Which method is used to retrieve the recent access time of a equeste by user from session?
getLastAccessedTime()
choose from below valid option.
Rohit wants to validate the quantity entered by the customer as mentioned in requirement 2. Choose from the below valid Add @Range(min=1, max=10)anotation in the Bean class
option.[Choose 2] The request handler method should include @Valid to @ModelAnnotation parameter
Rohit wants to receive the requests from customers and forward those request to other components of the application for
further processing . Choose from the most appropriate option, which Rohit performs as his first step as per Spring-MVC
workflow.
A
<bean class="org.springframework>
<property name="prefix">
Rohit wants to navigate to success.jsp page on successful submission. Assume he wrote a handler method to return <value>/WEB-INF/jspViews/</value>
ModelAndView with logical view name as success. He needs to configure a View Resolver bean in child configuration file to </property>
resolve the logical view name.Choose from below a valid option <property name="suffix">
<value>jsp</value>
</property>
</bean>
Rohit wants to create a request handler method in controller that can handle customer request and send the response back to Create a request handler method in the controller to map the request using @RequestMapping annotation and
the response back to the customer. Help rohit to achieve this with a valid option given below. return the ModelAndView object.
Rohit wants to auto populate the items available for the selected SportsType to the respective drop-down box. Assume he A
defined the respective method in the controller which can return Map<String,Double>. Rohit is supposed to bind the key as OPTION NOT VISIBLE
label attribute, value as value attribute in the drop-down box. Choose from below a valid option.
Rohit wants to create an auto populated drop-down box in purchase.jsp page. Help Rohit to implement a proper handler Create a method in the controller to invoke DAO layer method which returns the Map of SportsType with
method in controller that can retrieve sportsType defined in DAO layer. Choose from below a valid option. @ModelAttribute annotation.
Which of the following is correct statement with respect to Spring test @DirtiesContext

From the following tables match the JSP implicit objects given in table A with APIs in
sevlets package given in table B. 1 - ii
Table A Table B 2-i
1) out i) ServletContext
2) application ii) JSPWriter 3 - iv
3) exception
4) page
iii) Object
iv) Threwable
4 - iii
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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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


1
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


Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(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 both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked
1. Refer the code given below.
Class Library{
Private Book book ;
Public Library(Book book){
This.book = book;}
}

ANS: B
<bean id=”library” class=”com.accenture.lkm.library”>
<constructor-arg>
<bean class=”com.accenture.lkmBook”>
<constructor-arg value=”book1”>< constructor-arg>
</bean>
</constructor-arg>
</bean>

2. Consider the code


Package com.accenture.lkm:
@Component(“address”)
Public class Address{
//common word (“Hyderabad- Telangana”)//
//common word (“Bangalore-Maharasthra”)//

ANS:B
Employee Address:Bangalore-Maharasthra

3. Package com.accenture.lkm:
@Component(“employee”)
/// common word(@Autowired,Gettors and Setters,UITester
Line1
Line2
Line3
House,room1,room2

ANS:A
@Autowired,@Qualifier(“room1”),com

4. Spring configuration file inside a package? Choose2


ANS:A,D
….
ClassPathXmlApplicationContext(“com/Accenture/lkm/resourse… .... ”);
….
ClassPathXmlApplicationContext(“classpath:com/accenture/lkm/resourse/my_springbean.xml”)
;
5. create spring container object…
Spring configuration code
Code:
@Configuration
Public class Appconfig
@bean
Public Address createAddress(){….

ANS:A
Address address= (Address ) ctx.getBean(“createAddress”);
OR
ANS:B
……
Address address= (Address ) ctx.getBean(“Address”);

6. Choose from below…..specific EntityManagerFactory and Transaction Management


ANS:B
LocalContainerEntityManagerFactoryBean

7. Valid implementation of the delete query to delete customers….than a particular value


Code:
@Entity
Public class CustomerEntity
@Id
Private int cid;

Private double credit;
// getter and setter methods}
ANS:A
@Modifiying
@Query(“delete from CustomerEntity k where k.credit<cpoint”)
…..Int delete(….

8. Spring transaction method?


(i)…
(ii)…
common word(“
///Triggered implicitly,methods?///
ANS:B
Only(i)

9. Assume Invalid DummyException is checked exception,


////Common word(“employeeBean
Line-x, addEmployee, addDepartment,DAO Class(Logical Transactions),@transactional”)
ANS:A
@transactional(value=”txManager”,propagation=Propagation,REQUIRES_NEW

10. Following statements correct with respect to JSP?


(i) Default scope….
(ii) JSTL codes….
(iii) Page scope
ANS:C
ONLY (iii)

11. From the Following identify two INCORRECT statements about 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
ANS:A
I and ii only

12. Which object is created by web container for each Servlet during servlet initialization?
ANS:B
ServletConfig

13. Mr.john has been assigned the task of creating a servlet filter to log IP address of the
computers ……servlet filters in web.xml file
ANS: A
<web-app>
..
<filter>
<filter-name>..</filter-name>
<filter-class>..</filter-class>
</filter>
….
14. Blessie is a web developer wants to create a web page which always lands in
portal.accenture.com..
Common word(“ index.html,Blessie,unavoidable reasons,MyServlet.java
@WebServlet(urlPatterns=”/MyServlet”),
serialVersionUID=1L;
/**code is missing**/
ANS:B
Response.sentRedirect(http://portal.accenture.com);
15. When you want to remove the user data from session, what all the various options available
in JSP?(choose 3)?
ANS:A,B,C
(i)To delete the session..
(ii)by invoking public..
(iii)in web.xml file use<session-timeout>…
16. Sadana wants to share the common database data throughout the application,Help her to
identify the appropriate code to achieve this task?
ANS:C
<%
String username = (String)application.getAttribute(“dbname”);
%>

17. Refer the following Miss.Linda


///Common word(“<%@page language=”java”...
“ISO-8859-1”%>, meta charset=”iso-8859-1>
Add JSP script here…
ANS:A
<% String companyName=”Accenture”;
String projectName=”XYZ”;
String location=”MDC”;
%>
<%=companyName%><br>
<%=projectName%><br>
<%=location%><br>

18. Refer the following JSP pages


///Common word(“ Header.jsp:
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01
Transitional/EN”http://WWW.w3.org/TR/html4/loose.dtd>
Blue, red, page Encoding=”ISO-8859-1%>
Home.jsp: , Footer.jsp
ANS:A
1

19. refer the incomplete code given below


//Common word(“ Author , authorobj
@RunWith(springJUnit4ClassRunner.class
Line1
@Autowired
ANS:C
@ContextConfiguration…

20. Correct statement(s) with respect to spring test?


(i) @DirtiesCOntext…
(ii)@ContextConfiuration…
ANS:B
Only(i)

21. Refer the code


@component
@Profile(“myprofile”)
classProduct{}
Common word//(“myprofile”)
ANS:B
System.setProperty(“….”);

22. John has created a properties file like below


Config.properties
Common Word(“james,1009090,inject values in customer
ANS:A
@Component
Public…
@Value…
Private int customer;
@Value(…”)
Private String Coustomer Name}

23. Which of the following is correct with respect to spring?


(i)@Configuration…XML files Spring configuration
(ii)@componentScan is used to scan stereotype annotation
ANS:Only (ii)
@componentScan

24. which of the following is correct


(i)JVM Support IOC
(ii) Spring Container Manages the instance of …
ANS : Only(ii)
25. Refer the Below Entity class
@Entity
Public Class EmployeeEntity{
@Id
Private int employeeId;
Private String employeeName;
……. Double salary;
//Getters and Setters are coded}
ANS: A
List<EmployeeEntity>findBySalaryBetweenOrderBySalary…param2)

26. Correct with respect to spring transaction propagation types?


(i) propagation type Propagation.REQUIRED starts a new transaction ,if a method …
(ii) propagation type Propagation.REQUIRED…
ANS: Both (1 and 2)

27. CORRECT with respect to JSP?


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

28. CORRECT statement about autowiring


ANS: C
Autowiring requires setter or constructor in bean class

29. Identify the correct hierarchy of servlets assuming you are required to create a registration
ANS: A
RegistrationServlet,java…
HTTPServlet…..
GeneralServlet ..

30. Which is an abstract class which provides the basic implementation of Servlet interface except
Service() method?
ANS:C
Generic Servlet
31. from the following tables match the JSP implicit Objects given in table A with APIs in servlets
package given in table B.
Table A Table B
1) Out i)ServletContext,
//Common word(“application,JSPWriter,exception,Object,page,throwable.
ANS: A
1-ii,2-I,3-iv,4-iii

32. Incorrect statement about JSR-330 annotation


ANS: C
JSR-330……

33. Assume that class “Employee” is created with property “empid” and its setter method.
Refer the spring configuration given below
<bean id =”emp” class=”com.Employee”>
<property name=”empid” value=”john”>
</bean>
Employee object ///applicationContext///
ANS: A
1

34. Refer the below incomplete code for a test class


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( =MyConfig.class)
..
Public class TestSpringCustomClass {
@AutoWired
Private Employee employee
//Test cases goes here}
ANS: A
Classes , @ActivePro....

35. Refer the code below


@Entity
Class BookEntity{
@Id
Private int…;
///Common word(“authorName, publisherType;,getters and setters}
Choose from the below to retrieve the books using Query method approach
ANS:A
findByPublisherType(String pType)
36. Refer the JSP code below
<body>
<h3>
<%!
Int bookId=1;
Int publishYear =2000;
Public int incrementBookId(int bookId){
Return bookid==;
…….
Predict the output
ANS:B
BookId:2
PublishYear:2001

37. which of the following ..are correct with respect to JSP


(i) default scope of a variable is page
(ii) session scope variable will be available in all jsp files …
(iii)JSTL codes are placed inside service() method
ANS:B
Both(i) and(ii)

38. When servlet destroy() method will be invoked by servlet container?


ANS:A ,C
When you male any change in the servlet class and same
When you stop the server, destroy method of all existing servlet objects will ne molded

39. refer the code


Package com.model;
@component(“prodObject”)
@profile(“myProdProfile”)
Public class product {
Private int productid;
Private string product Name;
}
….

..
///Common word(“ activate”)
ANS:A
@ActiveProfiles(profiles=”myOrderProfile”)
40. Refer the incomplete code
@Component
Class customer{
….
Private Cart cart ;
}
Assume instance of the cart is managed by Spring Container by the name “cartObj” and all the
Commonword//(“SpEL to inject the cart object in customer bean
ANS:A
@Value(“#(cartOBJ”)

41. refer to the incomplete code


Package com.accenture.lkm;
line1
Class customer{
Private int customerId;
Line2
Private address address;
Line3
Line4
……Common word///(“address”, @ComponentScan(basePackage =”com”)
Public class SpringConfig{
}
Public class Tester{
ANS: A;
@Component, @Autowired, @Component,@Configuration,annotationConfigApplicationContext.
42. Type annotations? Choose 2
ANS: A,B
@component
@service

43. /springormdemos”/>
<property name =”username” value….;
<property name=”password” value….;
</bean>
<bean>
Id-“cst_entityManagerFactory” class=*org.springframework.com…
/// dataSource , JpaVendorAdapter”
Class=”org.springframework.orm.jpa.vendor.hibernate.jpavendoradapter
<property name=”showSql”….
<property name=”generate..
Value=”org.hibernate.dialect.MySQL5Dialect”/>
ANS: A
driverManagerDatasource,LocalCOntainerEntityManagerFactoryBean,@Repository,@Auto f

44. incomplete code given below


<bean>
<!—Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager=”txManager”/>
<bean id=”txManager” class=”org.springframework.com.jpa…..
<property name=”entityManagerFactory” ref


----Line1
Common word///(“ EmployeeDAOImpl implements EmployeeDAO{
addEmployee,integer employee
ANS: C
@Repository,@persistenceContext,@Transaction(value=”txManager”)

45. Consider the code given below


Package com.accenture.lkm;
Public class Employee {
Private List<String>hobbies;
//getters and setters are already codede
Common word //(“playing cricket , Watching Movies, Ui teater……’”);
ANS: B
Employee 2 Hobbies: [playing cricket ,Watching Amovie]

46. Refer the code


Package com.accenture.lkm;
Public class job {
Private int jobId;
//getters and setter
}
Public class person{
Private String[] skills;
Line1
Private Job job;
This skill = skill,
….
//// Spring config java class below…
..
ANS: A
@value(“#(myjob)”).@configuration, @Bean, @beanname = “my…”);

47. Service class (Physical transaction)


/line-x
Public integer addEmployee….
Employeebean , DepartmentBean
Int result=0;
Int

..
deptId+employeeDepartmentDAO.addEmployee..
return result;
// DAO Class( logical Transactions)
//
Code for creating employee
ANS: A
@Transaction(“value =”txManager”,rollback=NullPointerException.class)

48. Which method is used to retrieve the recent access time of a request by user from session?
ANS:D
getLastAccessedTime().

49. refer the code below


Web.xml
<web-app>
<servlet>
Common word//(“Magazine , com.accnture.magazine.servlet,book, load-on-startup”)
ANS: A
Book servlet

50. Komal’s task is to create a customer report on daily…


Everyday when she generates a report … task
ANS: i & iii

i.
<% java.util.Data date = new java.util.Date():
out.print(data);
%>
iii.
<%
Java.util.Data data = new java.utilDate():
%>
<%=data%>

51…… about @ DiritesContext annotation.


ANS: B
It is used to close and Load the application context once again for other ….

52. refer the code given below


@Component
@Profile(“myprodfile”)
Class product{
}
Choose from the below a valid option toactivate the profile “myprodfile”
ANS: B
System.setProperty(“spring.profiles.active”,”myprofile”);

53. which of the following are stereotype annotation?(choose 2)


ANS: A,B
@component, @service
54. login.html;
<html>
<body>
<h2>Login Page</h2>
<form action=”sessionServlet1”>
<table>
<tr><td>UserName</td><td>…..
<tr><td>Password</td><td>……
</table>
…..John, admin.
ANS: B
page2…..null

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

56. farhan wants to write a code to add 2 number and return the result…..
ANS:B

57. Miss.Ashrey has been asked to add headers and footers…..JSP….


Header.JSP and footer.JSP
ANS: A
<…
<….
<…

<..
<..

58. refer code


@entity
Public class EmployeeEntity
@Id
Private int empId;
…string name;
,,,,double salary ;
//getter and setter methods

Valid update query to update the JPA Data


ANS: A;
@modifiying
@query(“update EmployeeEntity k set k salary=new Sai’)
Int updateSalary(@Param(“newSai”)Double salary)
59.
Correct or not
i. Request scope variable in the page…
ii. Request Dispatcher of servlet API shares the request ,,,
ANS:B;
Both I and ii

60. ClassRunner.class
“myprofile”);
ANS: A, classes, @ActiveProfiles

61. multiple choice ANS:1,2


use@autowired at lineX
use@autowired at lineY
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="library" class="com.accenture.lkm.Library">


<cons. ...... >
<bean class. ........... Book">
<constructor-arg value="book1"></constructor-arg>
(
</bean>
</constructor-arg>
</bean>

JSR-330 annotations JSR-330 annotations can not beuesd along with Spring framework annotations

To delete the session attribute we can call public void removeAttributes(String name) , By invoking public void
invaliddate(), In web.xml file use <session->

@RunWith(Spring.Junit4ClassRunner.class)
@ContextConfiguration( =MyConfig.class)

@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ---------------- (profiles="myProfile") Public class TestSpringCustomClass{


public class TestSpringCustomClass{ @Autowired private Employee employee; }

}
Choose from below a valid combination to complete the above code

@Component class Customer{ --------- private Cart cart; } @Value

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


Line 1
class Customer{
private int customerId;
Line 2
private Address address;
}
Line 3 @Component,@Autowied,@Coponent,@Configuration,AnnottionConfigApplicationContext
class Address{
public Address(){

@Entity class BookEntity{ @Id private int bookId; private String authorName; private String publisherType; //getter and setters }

DriverManageDataSource , LocalContainerEntityManagerFactoryBean,@Respository ,Autowired

@Respository, @PersistenceContext , @Transactional(value="Manager")


Which of the following is correct statement with respect to Spring test @DirtiesContext

@Configuration public class AppConfig { @Bean("address") public Address creatAddress() { Adsress address= new Address(); ApplicatonContext ctx=new AnnotationConfigApplicationContext(AppConfig.class); Address address=(Address)
return Address; }} ctx.getBean("addres");

Refer the incomplete code given below:

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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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
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


Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
Already Repeated Question
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Excep
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) Session scope variable will be available in all JSP files if it is accessed in a single session both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
Already Repeated Question
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked

When servlet destroy() method is invoked by servlet container?


Which of the following is correct statement with respect to Spring test @DirtiesContext

RegistrationServlet extends HTTPServlet


From the following identify the correct hierarchy of servlets assuming you are required to create a registration servlet to
HttPServlet extends GenericServlet
process registration request.
GenericServlet implements Servlets

Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.
When you want to remove the user data from session, what all the various options available in JSP? All option, other than Perform log out ...
From the following tables match the jsp implicit objects given in table A with Api's in servlets package given in table B
Table A Table B
1.out 1.Servlet c 1. OUT - JSPWRITER 2. APPLICATION- SERVLETCONFIG 3.
2.application 2.JSPWriter EXCEPTION . THROWABLE 4. PAGE - OBJECT
3.exception 3. Object
4.page 4.Throwable
which provides the basic implementation of Servlet interface except Generic Servlet
Which is an abstract class which provides the basic implementation of servlet interface except service() method? Generic Servlet
Refer the code given below
package com.model;
@component("prodObject")
@Profile("myProdProfile")
public classs Product
{
private int productid;
private String productName;
}
@ActiveProfiles(profiles="myorderProfile")
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 ....


Refer the code given below
@Entity
public class EmployeeEntity{
@Id @Modyfying
private int empId; @Query("update EmployeeEntity
private String name;
private double salary; Options are not clear
//getter and setter methods
}
Choose the valid implementation of the Update query to update employee salary, using Spring JPA Data.
From the following identify TWO INCORRECT statements about ServletCoding objects.
i) It is not created for each servlet dusring servlet initialization.
ii) It will be available to all servletsof an application. i and ii only
iii) Its lifetime is until the servlet class object is destroyed.
iv) One object per servlet class
Raghav must pre populate doctor's names from doctors table in a drop down list when patient is booking appointment online.
. He has written required method implementation in DAO and service layer.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Raghav added following query in orm.xml file

<named-query name="getPatientsData">
@Query(name="getPatientData")
<query>select p.pName,p.appointmentDate from patients p </query>
List<String> getPatientsData();
</named-query>

Select the correct methid declaration in DAO interface. Refer the patients class and patients table.
Raghav has added a method to update the details of the patients as below
public interface PatientsDAO
{
@Query(name="updateQuery1") @Modifying is not used on the method output should return the string data which i.. the updated
int updateAppointmentSlot(Patients patients, String new Appointment(Time); appointment time.
}
But he getting exception as "DML operation is not supported".What went wrong?

Raghav added the following methods in Service and DAO implementation classes to add paitent's information in db.
//service implementation
@transactional(propagation=Propagation.REQUIRED)
Integer addPatientInService(Patients patient)
{
//calling DAO method
}
addPatientInDAO() method always exceutes in a new transaction rather than the interface started in service
//DAO implementation layer of addPatientInService() method.
@transactional(propagation=Propagation.REQUIRES_NEW)
Integer addPatientInService(Patients patient)
{
//implementation
}

what is the behaviour of the addPatientInDAO() method?


Which of the following is/are correct statement(s) with respect to spring test?
(i) @DirtiesContest is used to mark the context dirty so that it can be closed
only (i)
(ii) @ContextConfiguration can only point to Spring XML.....
Choose the most appropriate option.
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;

refer the code given below


@Component
@Profile("myprofile")
System.setproperty("springprofiles active","myprofile").
class Product{
}
choose from below option to activate the profile"myprofile"

DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
Which of the following is correct statement with respect to Spring test @DirtiesContext

the incomplete code given below:


<beans>
<!--Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager ->

</bean>
@Repository,@PersostenceContext@Transactional(value="tx.Manager")
</beans>
LIne 1
public class EmployeeDAOlmpl implements {
Line 2

Line 3

<web-app>

<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a serviet filter to log IP addresses of the requesis originate. help him from the following
options to identify meant for serviet filters in web.xmi file.
<web-mapping>
<filter-name>...</filter-name>
<urt-pattern>...</urt-pattern>
</filter-mapping>

</web-app>

consider the code given below:


package com.accenture.ikm;
public class Employee(
private List<String>hobbies;
)
<beans>
<bean id="employee"class="com.accenture.ikm.Employee">
<property name="hobbies">
<list> Employee 2 Hobbies : [Playing Cricket Watching Movies]
<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
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code below


package com.accenture.ikm;
public class job{
private int jobid;
//getter and setter
}
public class person{
@Value("(myjob)").@Configuration @bean
private String[] skills;
--------Line1-----------
private job job;
Person(String[]Skills){
this.skills=skills;
}
}
Refer the Spring configuration code given below:
@Configuration
public class AppConfig {
ApplicationContext.ctx=
@bean("address")
new AnnotationConfigurationApplicationContext AppConfig .....
public address createAddress(){
Address address= (Address) ctx get. .. ("address")
Address address = new Address();
return address;
}
Refer the code given below:
@Entity
class BookEntity{
@id
private int bookid; findByPublisherType(String p Type)
private String title;
private String authorName;
private String publisherType;
}
public Integer addEmployee
employeeBean,DepartmentBean
int result= 0;
int
deptId=employeeDepartment
@Transaction(value = "txManager",Propagation.REQUIRED_NEW)
employeeBean.setDepartmentCode
result =
deptId+employeeDepartment
return result;
}
which of the following statements are correct:
(i) Default scope of a veriable is page.
(i) & (ii)
(ii) Session scope veriable will be availabe in all JSP filesif it is accessed in a single session.
(iii) JSTL codes placed inside service() method of translated serviet.
Which method is used to retrieve the recent access time of a request by user by session? getLastAccessedTime()
Which of the following is correct statement with respect to Spring test @DirtiesContext

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>
Book Servlet
</servlet>

<servlet>
<servlet-name>Magazine</servlet-name>
<servlet-class>com.accenture.MagazineServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
Choose from below valid options which provides complete support for creation of JPA specific EntityManagerFactory and
LocalContainerEntityManagerFactoryBean
Transaction Management.
Please Refer the following JSP pages Header.jsp <h1> This is Content of Header</h1> 1
<web-app>

<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the </filter>
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.(Option is not Visible but answer is correct. just cross check in exam) <filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>

</web-app>
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ---------------- (profiles="myProfile")
Option 1(options not visible)
public class TestSpringCustomClass{ @Autowired private Employee employee; }
Which is an Abstract class which provides the basic implementation of Sevlet interface except Service method? Generic Servlet
Consider the code below package com.accenture.lkm @Component("address") public class Address @Value("Hyderabad-
Employee Address Banglore,Maharashtra
Telangana")
Refer the code given below @Component @Profile("myProfile") class Product{} Choose from below a valid option to activate
System.setProperty("spring.profiles.active", "myProfile");
the profile "myprofile"
@Componet public class Customer{ @Value("${customerID}")
John has created properties file as below config properties CustomerName: James,CustomerID:1009090(Once Verify once.
private int customerID; @Value("${customerName}")
As options are not visible.Go with the Syntax)
private int customerName;
which of the following statements are correct? 1.JVM supports IOC 2. Spring Container manages the instance of the beans
only II
mentioned in the configuration and provides them back to code when needed.
which of the following statements are correct? 1. @Configuration is used to declare a XML file as a Spring configuration 2.
only II
@ComponentScan is used to scan stereotype annotation.
(i) To delete the session...........
want to remove user data from session, what all various options available in (ii) by invoking public void invalidate().
(iii) in web.xml file use<session-timeout>15</session-timeout>
Which of the following is correct statement with respect to Spring test @DirtiesContext

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.uti.Date();
out.print(date);
%>
ii.
<% i & iii
java.uti.Date date =new java.uti.Date();
%>
<%=date;%>
iii.
<%
java.uti.Date date =new java.uti.Date();
out.print(date);
%>
<%date%>

about @DirtiesContext annotation it is used to closed and load the application context.......
to retrieve the recent access times of a request by user from session? getLastAccessedTime()
(i) When you makes any changes in the...........
When Servlet destroy() method will be invoked by servlet container?
(ii) Whwn you stop the server, Destroy method of the.....
Refer the incomplete code given below:
<beans>
<!--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>
Line1 @Repository,@PersistenceContext,@Transactional(value="txManager")
public class EmployeeDAolmpl implements EmployeeDAO{
Line2
private EntityManager entityManager;
Line3
public Integer addEmployee(EmployeeBean employeeBean)
Integer employeeID = 0;
return employeeID;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<jsp include page="Header.jsp">


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

which of the followign os CORRECT with respect to spring transection propogation


1) propogation typr Ptopogation REQUIRED starts a new transection ,it a method is involved another method and a
transection does not required.
both(1) and (2)
2) propogation type Propogation.REQUIRED_NEW start a new transection.if a method is involvedfrom another method and a
transection already exists
choose most appropriate option

Refer the incomplete code given below: package com.accenture.lkm;


class House{
private String houseNum;
--------------Line1-----------
--------------line2------------
private Rooom room; @Autowired,@Qualifier("room")
//setter and getter}
class Room{
private int roomNum;
//setter and getter}
[further question not visible in mcq3(c) pdf]

Assume that class "Employee" is created with property 'empid" and its setter metod
Refer teh spring configuration below
<bean id="emp" class ='com.Employee">
<property name="empID' value ="john">
</bean>
How many Emplotyees objects will be created if the below code executes successfully?
1
public static void main(String[] arg){
Employee emp1 =(Employee) context.getBean("emp");
Employee emp2 =(Employee) context.getBean("emp");
Employee emp3 = emp1;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( =MyConfig.class)
(profiles="myProfile")
classes, @ActiveProfile
public class TestSpringCustomClass{
@Autowired
(Option was not visible properly spelling may be different)
private Employee employee;
Test cases goes here
}
@Entity
public class CustomerEntity{
@Id @Modifying
private int cid; @Query("delete from CustomerEntity k where ....... 0
private String cname; int delete(@Param("cpoint") double ....
private double credit;
??getter and setter (the words which are not visible is marked as dots)
}

refer the code given below


@Entity
class BookEntity{
@Id
private int bookId;
private String title; findByPublisherType(String pType)
private String authorName;
private String publishertype;
//getter and setters
}
choose from below the valid option to retrieve the books based on the given publisher type by using query method approach
Refer the JSP coide given below and predict the output
<body>
<h3>
<%!
int bookId=1;
int publishYear = 2000; Book Id :2
public int incrementBookId(int bookId){ Publish Year :2001
return bookId++;
}
%>

Which of the fopllowing is CORRECT with respect to propogation type


propogation.REQUIRES_NEW?
option(!!) only
(!) For a method, begin a new transaction always
(!!) if a method is invokes from another method and a transaction exists, then the same transaction is used
choose the most appropriate
Line-X
public integer addEmployeeAndDepartment(EmployeeBean employeeBean,
Departmentbean departmentbean) throws Exception {
int result = 0;
int deptId = employeeDepartmentDAO.addDepartment(departmentBean); @Transaction(value="txmanager",propogation = Propogation.REQUIRES_NEW)
employee.Bean.setDepartmentCode(deptId);
result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

Which of the following statement are CORRECT with resepect to jsP


(!) Default scope of a variable is page
(!!) Session scope variable will be available in all JSP files if it is accessed in a single session both (!) and (!!)
(!!!) JSTL codes are placed insideservice() method of translater servlet
choose the most appropriate option
From the following identify the correct hierarchy of servelets assuming you are required to
Option not visible
create a registration servlet to process registration request
(!) When you make any changes in the servlet class and save
When Servlet destroy() method will be invoked by servlet Container?
(!!) When you stop the server, destroy method of all existing servlet objects will be mo...
John has created a properties file below: @C... (line not visible)

config.properties public class Customer{


customerName: James @Value(". ........ ");
CustomerId: 1009090 ..........not visible.......
Choose from below a valid option to inject values in Customer bean from confiig.properties file }
Which of the following are correct with respect to Spring:

(i) @Configuration is used to declare an XML file as Spring configuration


option (ii) is correct
(ii) @CompensationScan is used to scan stereotype annotation

Choose most appropriate option


Which of the following statement(s) is/are CORRECT?
option (ii) is correct
(i) JVM Supports IOC
(ii) Spring container manages the instance of the beans mentioned in configuration and provides them back to code when needed
(Not visible) is a web developer wants to create a web page which always lands in portal.accenture.com, whenever user hits on w

index.html

<form action="MyServelet" method="POST">


<input type="submit" value="welcome">
</form>

Now Blessie started writing the code, all of a sudden, she handed over the job of completing it to you due to unavoidable reasons

MyServlet.java
--------------------------- response.sendRedirect("https:/portal.accenture.com");
@WebServlet(urlPatterns="/MyServlet)
public class MyServlet extends HttpServlet{
public static final long serialVersionUID = 1L;

public myServlet(){
super();
}

..........................................
Which of the following is correct statement with respect to Spring test @DirtiesContext

@Entity

public class EmployeeEntity{


@Id;
private int employeeId;
List<EmployeeEntity> findBySalaryBetweenOrderBySalaryDesc(Double param1, Double param2))
private String employeeName;
private Double salary;
//Getters and Setters are coded
}

Which of the following are with respect to Spring transaction propagation types:

(i) propagation type Propagation.REQUIRED starts a new transaction, if a method is provided from another method and a transac
both (i) and (ii)
(ii) propagation type Propagation.REQUIRED_NEW starts a new transaction, if a method is invoked from another method and a t

Choose the most appropriate option.


Choose from below the CORRECT statement about Autowiring. Autowiring requires setters or constructors in bean classes
Consider a web application is created with a welcome index.html mapped with a Servlet class to process the response.

Refer the code below:

index.html
.......................................

<form action="LanguagesServelet" method = "POST">


<input type="checkbox" name="language" value="english"/> English
<input type="checkbox" name="language" value="hindi"/> Hindi
<input type="checkbox" name="language" value="tamil"/> Tamil
<input type="checkbox" name="language" value="malayalam"/> Malayalam
<input type="checkbox" name="language" value="telegu"/> Telegu
<input type="checkbox" name="language" value="kannada"/> Kannada
<input type="checkbox" name="language" value="french"/> French
<input type="checkbox" name="language" value="spanish"/> Spanish
<input type="submit" value="Select. ........................... Languages"/>
</form>

..................Not Visible....................................
when you want to remove the user data from the session,what all the various options available in JSP option starting with(to,by,in)
mr.john has been assigned the task of creating a servlet filter to log IP addresses. ....................... web.xml file answer not clear but i guess <web>(option 1)
Refer the following JSP pages,
Header.jsp:
<% @ page language="java" content type="text/html:charset=ISO-8859-1" 1

From the following table match the JSP implicit objects given in tabe A with APIs in servlet package given in table B 1-ii,2-i,3-iv,4-iii
.....which provide the basic implementation of servlet interface except GenericServlet
choose from the below the INCORRECT statement about JSR-300 annotation JSR-300 annotation.....
which of the following is/are CORRECT statement with respect to "spring Test" @DirtiesContext is used to mark the context dirty....
which is an abstract class which provide the basic implementation of servlet interface except service() method GenericServlet
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the code given below


package com.model;
@component("prodObject")
@profile("myProdProfile")
@ActiveProfiles(profiles="myOrderProfile")
public class Product{
private int productId'
private String productName;
}
Class Library{
private Book book;
Public Library(Book book){ <bean id="library" class="com.accenture.lkm.Library
this.book=book; <constructor-arg>
} <bean class="com.accenture.lkm.Book">
}

Class Book{ </bean>


private string bookName; </constructor-arg>
public Book(String bookName){ </bean>
this.bookName= bookName;
}
}
Refer the below incomplete code for a test class
classes, @ActiveProfiles
@RunWith(SpringJUnit4ClassRunner.class)
<%!
Peter wants a method to add 2 numbers and return the result. He also wanted to place it
public int add(int num1, int num2) {
inside the service method. Help him to select the appropriate JSP scripting.
return num1 + num2;
}
%>
<%
Sadana wants to share the common database data throughtout the application.
String userName = (String)application.getAttribute("dbname")
Help her to identify the appropriate code to achieve the task.
%>
<%@page language="java" contextType = "text/html:charset=ISO-8859-1"
pageEncoding = "ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<%
<meta charset="ISO-8859-1">
String companyName = "Accenture";
<title>Sample</title>
String projectName = "ABC";
</head>
String location = "HYD";
<body>
%>
<%--Add JSP Script here-->
<%= companyName %>
</body>
<%= projectName %>
</html>
<%= location %>
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.

Identify the CORRECT script


Miss Monica has given login request to 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 Translation, Compilation, Instantiation, Service and Destroy
right order
Which of the following is correct statement with respect to Spring test @DirtiesContext

<web-app>
........
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
Mr John has been assigned the task of creating a servlet flter to log IP addresses
of the computers from which the requests originate. Help him to identify the correct snippet
<filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>
..........
</web-app>
Which of the following is CORRECT with respect to spring transaction propogation ?

i) propogation type: Propogation.REQUIRED starts a new transaction.


another method and a transaction does not exist.
i and ii both are correct
ii) propogation type: Propogation.REQUIRED_NEW starts a new transaction.
from another method and a transaction already exist.

Choose appropriate option.


Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) JSTL codes are placed inside service() method of translated servlet only 3 is correct
(iii) page scope variable is available only on the page where it is declared
Choose the most appropriate option.
the incomplete code given below:
<beans. ....>
<!--Assume dataSource, EntityManagerFactory, configuration are provided>
Line1

<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>

</beans>

Choose from below the valid option to enable declaration of transaction


Management using annotations.

<web-app>
<filter>
<filter-name>. .. </filter-name>
<filter-class>. </filter-class>
</filter>
Shed the task of creating a servlet filter to log IP addressess of the requests originate.help him from the following options
<filter-mapping>
to identify meant for servelet filters on web.xml file
<filter-name>. .. </filter-name>
<uri-pattern>. <uri-pattern>
</filter-mapping>
.....
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code given below:


package com.accenture.lkm;
Class House{
Private String houseNum;
Line1
Line2
private Room room; @Autowired,@Qualifier("room1"),com
//setter and getter
}
class Room{
private int roomNum;
//setter and getter
}
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("com/accenture/lkm/resource/my_springbean.xml");
Select correct options to refer a Spring configuration file inside aa package? Choose2
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("classpath:com/accenture/lkm/resource/my_springbean.xml");
Which of the following is/are CORRECT with respect to Spring transaction methods?
(i) If a method throws runtime/unchecked exception, then rollback will be triggered implicity
only (i)
(ii) If a method throws checked exception, then rollback will be triggered implicitly
Choose the most appropriate option
@Transactiona(value="txManager",rollbackFor=InvalidDummyException.class)
public Integer addEmployeeAndDepartment(EmployeeBean employeeBean, DeaprtmentBean departmentBean) throws Exceptio
int result=0;
int
deptId=employeeDepartmentDAO.addDepartment(deprtmentBean):employeeBean.setDepartmentCode(deptId); @Transactional(value="txManager",propogation=Propagtion Requires_NEW)
result=
deptId+employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which object is creared by web container for each Servlet during servlet initilization ServletConfig

Refer the incomplete code given below:


package com.model;
public class Author{
public Authore(){
System.out.println("author");
}
}
Below configuration is available in the file located at /com/resources/my_springbean.xml
<bean id="authorobj" class="com.model.Author"></bean>
package come.test; @ContextCOnfiguration(locations="/com/resources/my_springbean.xml")@Test
@Runwith(SpringJUnit4ClassRunner.class)
Line1
piblic class TestAuthorClass{
@Autowired
private Author author;
Line2
public void testAuthor(){
Assert.assertTrue(author!=null);
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="messageSource"
rohit wants to externalize the validation error messages. So, he defined the messages in
class="org springframework.support
'com/accenture/lkm/resoruces/messages_en.properties files'.Help rohit to configure the MesageSource beam in the context file
<property name="name" value="classpath\com\accenture\lkm\resources/messages_en.properties"/>
by choosing a valid option from beiow
</bean>

Rohit deployed the application in the Apache Tomcat Server. But he got an exception as "org.springframework.beans.factory. A) Configure<context:component-scan base-package="com.accenture.lkm.dao"/> in the root context
NoSuchBeanDefinitionException:No qualifying vean of type [com.accenture.lkm.dao.PruchaseDAO]". Choose from below valid confifuration
options to succesfully execute his application C) Configure <mvc:annotation-driven/> in the child context configuration

Rohit wants to display all the validation error messages in purchase jsp. <form:form method="POST" modelAttribute="bean" action="store.html">
Help him to display those messages at the bottom of the page. <table border="3">
Choose from below a valid option. Asssume the below taglib <!--Assume form elements are mentioned appropriately -->
directives are added in the jSP. </table>
<%@taglib url="http://springframework.org/tags/form" prefix="form"%> <spring:hasBindErrors name="bean">
Consider the code given below:
package com.accenture.lkm;
public class Employee {
private list<String>hobbies:
//Getters and Setters are already coded
}
<beans>
<bean id ="employee" class="com.accenture.lkm.Employees">
<property name="hobbies">
<list> Employee 2 hobbies [Playing Cricket Watching Movies]
<value Playing Cricket </value>
<value Watching Movies </value>
<list>
</property>
</bean>
</beans>
public class UIT Tester {
public static void main(String

<web-app>
.......
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a servlet filter to log IP addresses of the request originate. Help him from the following options to identify
meant forservlet filters in web.xml file.
<filter-mapping>
<filter-name>. .. </filter-name>
<urf-pattern>. . </urf-pattern>
</filter mapping>
.......
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the Spring configuration code gievn below:


1 @Configuration
2 public class AppConfig {
3 @Bean("address")
4 public address createAddress( ) { ApplicationContext ctx =
5 Address address = new Address( ) : new annotationConfigApplicationcontextAppConfig
6 return address ;7 Address address=(Address)ctx
}
8 }
Identifybthe correct code to create spring container object and get the address object injected
Choose the most appropriate option.
Refer the incomplete code given below:
package com.accenture.lkm;
public class Job {
private int jobId:
//getter and setter
}
public class Preson {
private String[] skills;
-----------line1--------------
private Job job; @Value("=(myjob)"1 @configuration @Bean @Beanvalue ="myjob")
person(String[] skills){
}
//getter and setter
}
Refer the Springconfig java class below
------------------Line2--------------------
public class Springconfig(

Which method is used to retrieve the recent access time of a equeste by user from session?
getLastAccessedTime()
choose from below valid option.
Rohit wants to validate the quantity entered by the customer as mentioned in requirement 2. Choose from the below valid Add @Range(min=1, max=10)anotation in the Bean class
option.[Choose 2] The request handler method should include @Valid to @ModelAnnotation parameter
Rohit wants to receive the requests from customers and forward those request to other components of the application for
further processing . Choose from the most appropriate option, which Rohit performs as his first step as per Spring-MVC
workflow.
A
<bean class="org.springframework>
<property name="prefix">
Rohit wants to navigate to success.jsp page on successful submission. Assume he wrote a handler method to return <value>/WEB-INF/jspViews/</value>
ModelAndView with logical view name as success. He needs to configure a View Resolver bean in child configuration file to </property>
resolve the logical view name.Choose from below a valid option <property name="suffix">
<value>jsp</value>
</property>
</bean>
Rohit wants to create a request handler method in controller that can handle customer request and send the response back to Create a request handler method in the controller to map the request using @RequestMapping annotation and
the response back to the customer. Help rohit to achieve this with a valid option given below. return the ModelAndView object.
Rohit wants to auto populate the items available for the selected SportsType to the respective drop-down box. Assume he A
defined the respective method in the controller which can return Map<String,Double>. Rohit is supposed to bind the key as OPTION NOT VISIBLE
label attribute, value as value attribute in the drop-down box. Choose from below a valid option.
Rohit wants to create an auto populated drop-down box in purchase.jsp page. Help Rohit to implement a proper handler Create a method in the controller to invoke DAO layer method which returns the Map of SportsType with
method in controller that can retrieve sportsType defined in DAO layer. Choose from below a valid option. @ModelAttribute annotation.
Which of the following is correct statement with respect to Spring test @DirtiesContext

From the following tables match the JSP implicit objects given in table A with APIs in
sevlets package given in table B. 1 - ii
Table A Table B 2-i
1) out i) ServletContext
2) application ii) JSPWriter 3 - iv
3) exception
4) page
iii) Object
iv) Threwable
4 - iii
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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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


1
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


Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Excep
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(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 both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked
1 Refer the incomplete code given below

Answer : A) @Value(“#{cartObj}”)
2 Consider the code given below:

Package com.accenture.lkm;

Public class Employee{

Answer :
3 Refer the incomplete code given below

Package com.accenture.lkm;

Public class Job{

Answer : A) Line 1= @value("#jobObjects")


line 2= @configuration
line 3= @bean ................................ etc

4 Which of the following are Stereotype annotations? [Choose 2]

Answer :- A and B (component and service)


5 Assume that class “Employee” is created with property “empid” and its setter
method. Refer the spring configuration given below

Answer : A) 1

6 Refer below incomplete code

Answer : A) @Transaction(value="txManager",propogation.REQUIRED_NEW)
7 From the following identify which is NOT a session management technique?

Answer:- A) Request…………

8 Consider the following code


Login.html:

Answer :- B) Page2 welcomes null(check once).


9 Which lifecycle method of JSP is invoked by the container to perform the………
…………………………….each time when trhe request is received?

Answer :- B) _jsp service

10 Farhan wants to write a code to add 2 numbers and return the result……….
……………………………………….. JSP scripting element.

Answer :- B
11 Miss Ashrey has beed asked to add headers and footers while designing login
and home page ..............................................................Header.jsp and footer.jsp

Answer :- A

12 Which of the following is/are CORECT statement(S) with respect to spring Test?

Answer :- A) Both (i) and (ii).


13 Refer the JSP code below and predict the output.

Answer :- B) Book id :2 Publish year :2001

14 Refer the Spring configuration code given below.

Answer :- B
15 Refer the code given below.
@Entity
Public class EmployeeEntity{

Answer:- A
16 Refer the incomplete code given below:
<beans>
<!..

Answer :- C) @Repository, @PersistenceContext,


@Transactionl(value=”txtManager”).
17 Which of the following statements(s) is/are CORRECT with respect to JSP?

i. Request Scope variable………………………………………


ii. RequestDispatcher…………………………………………..

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

18 Choose from below the INCORRECT statement about JSR-330 ………

Answer:- C) JSR 330……………………………………………………………………………..


19 Refer the code given below.

Answer : A & B (A) Use @Autowired at LineX and (B) Use @Autowired at LineY

20 Refer the below incomplete code for a test class.

Answer : (A)
21 Refer the incomplete code

Answer :- C) @Transactional(value=”txManager”,propagation=propagation REQUIRES_NEW)


22 When Servlet destroy() method will be invoked by Servlet Contsiner?[choose 2]

Answer :- A) When you make any change in the servlet class and save

C) When you stop the server, destroy method of all existing servlet objects………

23 Which is an abstract class which provides the basic implementation of Servlet interface except

Service() method ?

Answer :- C) GenericServlet
24 Refer the Below Entity class.

Answer : (A)
25 Which method is used to retrive the recent access time of a request by user from session?

Chosse from below a valid option.

Answer : D) getLastAccessedTime()
1 Refer the code given below:

Class Library{

Answer: B) <bean id=”library” class=”com.accenture.lkm.library”>

<constructor-arg>

<bean class=”com.accenture.lkm.Book”>

<constructor-arg value=”book1”></constructor=ard>

</bean>

</constructor-arg>

</bean>
2 Refer the incomplete code given below:

Package com.accenture.lkm;

Class House{

Answer :- A) @Autowired, @Qualifier(“room1”).com


3 Select correct options to refer a Spring configuration file inside a package? Choose 2

Answer :- A and D
4 Refer the Spring configuration code given below.

Identify the correct code to create spring container object and get the address object

Injected. Choose the ,ost appropriate option.

Answer :- A
5 Choose from below the valid option which provides the complete support for creation of JPA
specific EntityManagerFactory and Transaction Management.

Answer : B) LocalContainerEntityManageFactoryBean

6 Which of the following is/are Correct with respect to spring transaction methods?

Answer : b) only (i)


7 Refer the code given below.

Choose the valid implementation of the delete query to delete customers who has credit less

Than a particular value.

Answer : A
8 Which of the following statement(s) is/are CORRECT with respect to JSP?

Answer : - C) Only (iii)

9 From the following identify TWO INCORRECT statements about ServletConfig object.

Answer : A) I and ii only


10 Which object is created by web container for each Servlet during servlet initialization?

Answer :- b) ServletConfig
11 Mr.John has been assigned the task of creaing servlet filter to log IP address of the computers

……………………………………………………………………….for servlet filters in web.xml file.

Answer : A
12 Blessie is a web developer wants to create a wep page… ................ whenever user hits on
welcome button on index.html given below

Answer :- B) response.sendRedirect(“https://portal.accenture.com”);
1 Sadana wants to share the common database date throughout the application. Help her to identify
the appropriate code to achieve thi task.

Answer : C) <%

String username=(String)application.getAttribute(“dbname”);

%>
2 Refer the following code:

Answer : (A)
3) Refer the following JSP Pages.

Header.jsp:
4) Refer the incomplete code given below.

Package com.model;

Public class Author{

Answer : C) @ContextConfiguration(locations=”/com/resources/my_springbeam_xml”),@test
5) Which of the following is/are CORECT statement(S) with respect to spring Test?

Answer :- B) Only (i)


1. Refer the code given below.

Answer :- B) system.setProperty("spring.profiles.active","myprofile");
2 Consider the code given below

Package com.accenture.lkm;

@component(“address”)

Public class Address{

Answer :- B)Employee Address : Bangalore-Maharashtra


3 John has created a properties file like below

Answer :- A

4. Which of the following is correct with respect to spring?

Answer : - Only 2
5 Which of the following statement(S) is/are correct.

Answer :- Only (ii) is correct.

6 Which of the following is CORRECT with respect to spring transaction pro… types ?

Answer :- A) Both (i) and (ii).


7 Which of the following statements(s) is/are CORRECT with respect to JSP?

Answer : (ii and iii ) 2 and 3 is correct.

8 Choose from below the CORRECT statement about Autowriting.

Answer :- C) Autowriting requires setters or Constructor in bean class.


9 From the following identify the correct hierarchy of servlets assuming you are
request ................................................................... registration request.

Answer :- A

10 Which is an abstract class which provides the basic implementation of servlet interface except
service() method?

Answer :- C) GenericServlet
11 Mr.john has been assigned the task of creating a servlet After to log IP…………………………………………

The correct order of tags meant for servlet filters in web.xml file.

Answer :- A) <web-app>

12 Consider a web application is created with a welcome file index.html mapped with a servlet class

To process the response.

Refer the code below:

Answer :- B
13 When you want to remove the user data from sessions, what all the various options available in
JSP? [Choose 3].

Answer : A) To delete the session attribute we can call public void removeAttribute(String Name)

B) By invoking public void invalidate()

C) In web.xml file use <session-timeout>15</session-timeout>


14 From the following tables match the JSP implicit objects given in table A with API’s in servlets
package given in table B.

Answer :- A) 1.ii 2.i 3.iv 4.iii


16 Refer the code Given Below:

@Entity

Class BookEntity

Answer :- A) findByPublisherType(String p Type)


S.N QUESTIONS ANSWERS
O
1 Refer the incomplete code given below. @Value("#cartObj}")

1.Component
2.Class customer{
3. -----------
private Cart cart; Option:1
}

Assume instance of the Cart is managed


by Spring Container by the name
"cartObj" and all the classes and
configuration are coded property om
below a valid SpEL to inject the cart
object in Customer bean.
2 Refer the code given below: system.setProperty("spring.profiles.active","myprofile”);
@Component
@Profile("myprodfile")
class Product {

} option:2

Choose from below a valid option to


activate the profile "myprofile”

3 Which of the following are steractype component


annotations? Choose 2] service

option:1&2

4 Assume that class "Employee" is created 1


with property "empld" and its setter me
Refer the spring configuration given
below

1 <bean id='emp" class con Employee'> 2 Option:1


<property name "espid" value John

How many Employee objects will be


created if the below code execudes
successfu method? Assume that "context
referes to spring container
ApplicationContext
1 public static void main(String[] args) {

2 7/ code for ApplicationContext creation

goes here

Employee emp1 (Employee)


context.getBean(""); Employee emp2
(Employne) context.getBean("empl

Employee emp3 - emp1;


5 Refer the code given below:
findByPublisherType(String p type)
@Entity

class BookEntity{

@ld
Option:1
private int bookid,

private String title,

private String authorName

private String publisherType

//getters and setters


}

Choose from below the valid option to


retrieve the books based on using Query
Method Approach

6 Choose from below the valid option (LocalContainerEntityManagerFactoryBean)


which provides the complete support for
creation of JPA specific Option:2
EntityManagerFactory and Transaction
Management

7 Refer the code given below @Modifying

@Entity @Query("update fromEmployeeEntity k where k credits point) int


public class EmployeeEntity{ update(@Param("cpoint") double credit)
@Id

private int empld, Option:1


private String name;
private double salary;
// getter and setter methods
}

Choose the valid implementation of the


Update query to update employee salary
ng Saring JPA Data

8 Which of the following is CORRECT with both i and ii


respect to Spring transaction
propogation types?

(i)propogation type Propogation


REQUIRED starts action amo from option:1
another method and a transation does
not exists (ii)propobation type
Propogation REQUIRED NEW starts
invoked from another method and a
transation steady s

Choose the most appropriate option

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


class Library (
<constructor-arg>
private Book book;
<bean class="com.accenture.km Book”>
public Library(Book book) {
this book= book; <constructor-arg value-book"><stutup

} </bean>

} /constructor-arg>

class Book { </bean>

private String bookName;

public Book(String bookName) { this Option:b


bookName = bookName;
}

Choose from below a valid option to


define Book as a inner beam of library
10 Consider the code given below. Employee Address: Bangalore-Maharashtra
package com.accenture.lkm,

@Component("address")
public class Address (

@Value("Hyderabad-Telangana")
Option:b
private String addressLine1;
//Getters and Setters are already coded

package com.accenture.lkm;

@Component("employee") public class


Employee {

@Autowired

private Address address;

Getters and Setters are already coded


11 Refer the incomplete code given below. @Autowired, @Qualifier("room1),com
package com.accenture.lkm,

class House (

private String houseNum,


Option:b
______Line1______

______Line2______

private Room room;


//setter and getter

class Room { private int roomNum;


//setter and getter

}
De here to search

Refer beans.xml given below:

id="house" class="com.accen
12 Select correct options to refer a Spring 1. ApplicationContext application Context=new
configuration file inside a package?
Choose 2 ClassPathXmlApplicationContext("com/accenture/km/resource/m
springbean.xml");

4. ApplicationContext applicationContext = new

ClassPathXmlApplicationContext("classpath.com/accenture/km/resou
/my_springbean.xml");

Option:1&4
13 Refer the Spring configuration code given ApplicationContext ctx =
below.
new AnnotationConfigApplicationContext(AppConfig.class
1 @Configuration Address address (Address) ctx.getBean(createAddress”)

2 public class AppConfig

3 @Bean

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 hea injected.
Choose the most appropriate option.

14 Choose from below the valid option LocalContainerEntityManagerFactorBean


which provides the complete support for
creation of JPA specific
EntityManagerFactory and Transaction
Management Option:2
15 Refer the code given below. @Modifying

1 @Entity @Query("delete from CustomerEntity k where k credits point) int


delete(@Param("cpoint") double credit)
2 public class CustomerEntity

3 @Id

4 private int cid;

5 private String cname;

6 private double credit;

7 //getter and setter methods

8 }

Choose the valid implementation of the


delete query to delete customers who
than a particular value.
16 Which of the following is/are CORRECT Only (i)
with respect to Spring transaction
methods?

(i)If a method throws runtime/unchecked Option:2


exception, then rollback will be biggered
imploty () (i)If a method throws checked
exception, then rollback will be triggered
implicity

Choose the most appropriate option.


17 Which of the following statement(s) Only(iii)
is/are CORRECT with respect to JSP

(1) Default scope of a variable is


application

(ii) JSTL codes are placed inside service() …… doubt ( 1&2) option 1
method of translated served.
(iii) Page scope variable is available only
on the page where it is declared

Choose the most appropriate option.

18 Refer below incomplete code: @Transactional(value="txManager" Propagation=Propagation


REQUIRES_NEW
//Service class (Physical Transaction)
// ============================

@Transactional(value="txManager,
rollbackFor Invalidumyt

ion.class)

public Integer addEmployee


AndDepartment (Employees
employeeBean, Department Bean
departmentBean) throws E

int result = 0;

7 dentId-employee
DepartmentDAO.addDepartment(depairs
Department Code (deptId);

int
19 From the following identify TWO (i) and (ii) only
INCORRECT statements about Servlet
config object
i) It is not created for each servlet during
serviet initialization.

(ii) It will be available to allservlets of an


application.
iii)Its lifetime is until the servlet class
object is destroyed.
iv) One object per servlet class.
20 Which object is created by web container ServletConfig
for each Servlet during servlet
initialization?
21 Mr. John has been assigned the task of <web-app>
creating a servlet filter to log IP address …………….
computers from which the requests
originate. Help him from the following <filter>
options to identify the correct order of <filter-name></filter-name> <filter-class></filter-class>
tags meant for servlet filters in web.xml
file. </filter>

<filter-mapping

<filter-name></filter-name>

<url-pattern>...</url-pattern>

</filter-mapping>
</web-app>

Ooption:1
22 Blessie is a web developer wants to create response.sendRedirect(“https://portal.accenture.com”);
a web page which always lands in
portal.accenture.com, whenever user hits
on welcome button in index.html given
below
option:2
index.html
……………….
<form action="MyServlet"
method="POST"> <input type="submit"
value="welcome">

</form>

Now Blessie started writing the code, all


of sudden she handed over the job of
cuming to unavoidable reasons.
Incomplete code is attached
23 When you want to remove the user data To delete the session attribute we can call public void
from session, what all the various options removeAtribute (stringname)
available in JSP?[choose 3]
By invoking public void invalidate()

In web.xml file use <session-timeout>15</session-timeout>

24 Sadana wants to share the common <%


database data throughout the application
Help her identify the appropriate code to String userName = (String)application.getAttribute('dbname");
achieve this task
%>

Option:3
25 Refer the following code. <%

<%@ page language="java" String companyName="Accenture"


contentType="text/html; charset 150 aass
pageEncoding="ISO-8859-1"%> String projectName="XYZ";

<!DOCTYPE html> String location="MDC";

<html> %>
<head> <%=companyName %><br>

<meta charset="ISO-8859-1"> <%-projectName %><br>

<title>Sample</title> <%=location %><br>

</head>

<body> Option:1

Miss Linda has been asked to design a JSP


page to display company name, project
me location using JSP scripting elements
such as expression and scriplet tags

From the following identify CORRECT


script to be added in the JSP body section
26 Refer the following JSP pages, 1
Header.jsp:

<%@page language="java" OPTION:1


contentType="text/html; charset-150-
8859-1 pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD


HTML 4.01 Transitional/EN"
"http://www.w3.org

/TR/htm/4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type"
content="text/html; charset-ISO-8859-1

<title>Insert title here</title>


How many servlets would be created
while executing Home JSP?
27 Refer the incomplete code given below. @ContextConfiguration(locations="/com/resources/my_
Package com.model; springbean.xml”),@Test
public class Author{

public Author() {

System.out.println("author"), Option:3
Below configuration is available in the file
located at /com/resources/mypl <bean
id="authorobj" class="com.model
Author></bean>

Choose from below a valid option to


complete the above code, in order to
complete the test
28 Which of the following is/are CORECT Only(i)
statement(s) LKM Test?

(i)@DirtiesContext is used to mark the


context dirty so that it can be closed

(ii) @ContextConfiguration can only point


to Spring XML configuration but not java
configuration

Choose the most appropriate option.


29 Which of the following is CORRECT with Only(ii)
respect to Spring?

(i)@Configuration is used to declare a


XML file as Spring configuration
(ii) @Component Scan is used to scan
stereotype annotation

Choose the most appropiate option


30 Choose from below the CORRECT Autowiring requires ………
statement about Autowiring
Option:c
31 Which of the following statement(s) is/are Only(ii)
CORRECT?

(i)JVM Supports IOC Option:2

(ii) Spring Container manages the instance


of the beans mentioned in configuration
and provides them back to code when
needed
32 Refer the incomplete code given below: @Value(“#myjob)”), @Configuration, @Bean,
package com.accenture.lkm; @Bean(name="myjob")

public class Job {

private int jobld; Option:1


//getter and setter

public class Person ( private String[] skills;

Line1

private Job job;

Person(String[] skills){

this skills skills;

//getter and setter

Spring Config java class below:


33 Which of the following are stereotype (i)@Component
annotations? [Choose 2] (ii)@Service

Option:1&2
34 Which of the following is CORRECT with Only(i)
respect to propogation type
propogation.REQUIRES NEW?

(i) For a method, begin a new transaction


always

(ii) If a method is invoked from another


method and a transaction exists, then the
transaction is used

Choose the most appropriate option.


35 From the following identify the correct RegistrationServiet.java extends HttpServlet
hierarchy of servlets assuming you are HttpServlet extends GenericServlet.
required to create a registration servlet to GenercServlet impleants Servlet.
process registration request

Option:1
36 John has created a properties file like @Component
below.
public class Customer {

@Value("$(Customerid))
private int Customerid,

@Value(“$(CustomerName)”)
private String CustomerName:
}
Option:1
37 Choose from below the CORRECT It is used to close and load the application content once again for
statement about @Dirties Context other
annotation
Option:2
38 Which is an abstract class which provides GenericServlet
the basic implementation of Serviet
interface except service() method? Option:3

39 Choose from below the INCORRECT JSR-330 annotations can not be used along with Spring framework
statement about JSR-330 annotations

Option:3
40 Refer the below incomplete code for a Classes . @ActiveProfiles
test class

1
@RunWith(SpringJUnit4ClassRunner.class
) 2 @ContextConfiguration
(MyConfig.class)

3………………….. (profiles-myProfile)
4 public class Test SpringCustomClass (

Autowired

private Employee employee:

//Test cases goes here

Choose from below a valid combination to


complete the above
41 Refer the JSP code below and predict the Bookld-2
outpu PublishYear-2001

<body>

<h3>

<%!

int bookld=1;

int publish Year-2000;


public int incrementBookld(int bookld)
return bookld++;
42 When Servlet destroy() method will be (i)When you make any change in the servlet class and save
invoked by Serviet Container? [choose 2]

(ii)When you stop the server, destroy method of all existing serviat
objects would be moled

Option:1&3
43 From the following tables match the JSP A) 1-ii,2-i,3-iv,4-iii
implicit objects given in table A with APIs
in serviets package given in table B.
Option:1
Table A Table B

1) out i) ServletContext

2) application ii) JSPWriter

3) exception iii) Object

4) page iv) Throwable


44 Refer the code given below: @Active Profiles(profiles-myOrderProfile")

package com.model;

@Component("prodObject) Option:1

@Profile (my ProdProfile")

public class Product {

private int productid; private String


productName;
}

package com.model;
@Component("orderObject")

@Profile("myOrderProfile")

class Order {

45 Object Class

out JSPWriter
request HttpServletRequest

response HttpServletResponse

session HttpSession

application ServletContext

config ServletConfig

exception Throwable

page Object

pageContext PageContext

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


class Library (
<constructor-arg>
private Book book;
<bean class="com.accenture.lkm.Book">
public Library (Book book) {
this.book=book; <constructor-arg value="book1"></constructor-arg>

} </bean>

class Book { </constructor-arg

private String bookName; </bean>


public Book(String bookName) {
this.bookName = bookName,
Option:2
}

Choose from below a valid option to


define Book as a inner bean of library
47 Refer the incomplete code given below @Component, @Autowired, @Component, @Configuration,
package com.accenture.Ikm, Annotation ConfigApplicationContext

______Line1________ Option:1

class Customer { private int customerld:

______Line2________
private Address address;
________Line3_______

class Address {

public Address(){
System.out.println("addre

______Line4_______

@ComponentScan(basePackage
public class SpringConfig{
}
Public class Tester{
48 ………………………. DriverManagerDataSource,
LocalContainerEntityManagerFactoryBean,@Repository,@Autowirin
g

Option::1
49 Refer the incomplete code given below. @Repository,@PersistenceContext
@Transactional(value=”txManager”)
<beans>

<!--Assume rest of the configuration is


written->

<tx:annotation-driven transaction- Option:3


manager="bManager">

<bean id="txManager"
class="org.springframework.orm.pa pa
<property name="entityManagerFactory
ref-est_entityMag

</bean

</beans>

_____Line1_____

public class EmployeeDAOImpl


implements EmployeeDAO (
50 Consider the code given below: Employee
package com.accenture.lkm:
public class Employee {
private List<String> hobbies;
//Getters and Setters are alreally coded
<bean "amplayea" class="com.accenturm.
Ikm. Employes"> property
name="hobbies">

-value Playing Cricket /Value> valuer


Watching Movies /valuar

-/property

public class VITester (

public static void minull) {


1. Refer the code given below.
Class Library{
Private Book book ;
Public Library(Book book){
This.book = book;}
}

ANS: B
<bean id=”library” class=”com.accenture.lkm.library”>
<constructor-arg>
<bean class=”com.accenture.lkmBook”>
<constructor-arg value=”book1”>< constructor-arg>
</bean>
</constructor-arg>
</bean>

2.Consider the code


Package com.accenture.lkm:
@Component(“address”)
Public class Address{
//common word (“Hyderabad- Telangana”)//
//common word (“Bangalore-Maharasthra”)//

ANS:B
Employee Address:Bangalore-Maharasthra

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

ANS:A
@Autowired,@Qualifier(“room1”),com

4.Spring configuration file inside a package? Choose2


ANS:A,D
….
ClassPathXmlApplicationContext(“com/Accenture/lkm/resourse……..”);
….
ClassPathXmlApplicationContext(“classpath:com/accenture/lkm/resourse/my_springbean.xml”)
;
5.create spring container object…
Spring configuration code
Code:
@Configuration
Public class Appconfig
@bean
Public Address createAddress(){….

ANS:A
Address address= (Address ) ctx.getBean(“createAddress”);
OR
ANS:B
……
Address address= (Address ) ctx.getBean(“Address”);

6.Choose from below…..specific EntityManagerFactory and Transaction Management


ANS:B
LocalContainerEntityManagerFactoryBean

7.Valid implementation of the delete query to delete customers….than a particular value


Code:
@Entity
Public class CustomerEntity
@Id
Private int cid;

Private double credit;
// getter and setter methods}
ANS:A
@Modifiying
@Query(“delete from CustomerEntity k where k.credit<cpoint”)
…..Int delete(….

8.Spring transaction method?


(i)…
(ii)…
common word(“
///Triggered implicitly,methods?///
ANS:B
Only(i)

9.Assume Invalid DummyException is checked exception,


////Common word(“employeeBean
Line-x, addEmployee, addDepartment,DAO Class(Logical Transactions),@transactional”)
ANS:A
@transactional(value=”txManager”,propagation=Propagation,REQUIRES_NEW

10.Following statements correct with respect to JSP?


(i) Default scope….
(ii) JSTL codes….
(iii) Page scope
ANS:C
ONLY (iii)

11.From the Following identify two INCORRECT statements about 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
ANS:A
I and ii only

12.Which object is created by web container for each Servlet during servlet initialization?
ANS:B
ServletConfig

13.Mr.john has been assigned the task of creating a servlet filter to log IP address of the
computers ……servlet filters in web.xml file
ANS: A
<web-app>
..
<filter>
<filter-name>..</filter-name>
<filter-class>..</filter-class>
</filter>
….
14.Blessie is a web developer wants to create a web page which always lands in
portal.accenture.com..
Common word(“ index.html,Blessie,unavoidable reasons,MyServlet.java
@WebServlet(urlPatterns=”/MyServlet”),
serialVersionUID=1L;
/**code is missing**/
ANS:B
Response.sentRedirect(http://portal.accenture.com);
15.When you want to remove the user data from session, what all the various options available
in JSP?(choose 3)?
ANS:A,B,C
(i)To delete the session..
(ii)by invoking public..
(iii)in web.xml file use<session-timeout>…
16.Sadana wants to share the common database data throughout the application,Help her to
identify the appropriate code to achieve this task?
ANS:C
<%
String username = (String)application.getAttribute(“dbname”);
%>

17.Refer the following Miss.Linda


///Common word(“<%@page language=”java”...
“ISO-8859-1”%>, meta charset=”iso-8859-1>
Add JSP script here…
ANS:A
<% String companyName=”Accenture”;
String projectName=”XYZ”;
String location=”MDC”;
%>
<%=companyName%><br>
<%=projectName%><br>
<%=location%><br>

18.Refer the following JSP pages


///Common word(“ Header.jsp:
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01
Transitional/EN”http://WWW.w3.org/TR/html4/loose.dtd>
Blue, red, page Encoding=”ISO-8859-1%>
Home.jsp: , Footer.jsp
ANS:A
1

19.refer the incomplete code given below


//Common word(“ Author , authorobj
@RunWith(springJUnit4ClassRunner.class
____Line1_____
@Autowired
ANS:C
@ContextConfiguration…

20.Correct statement(s) with respect to spring test?


(i)@DirtiesCOntext…
(ii)@ContextConfiuration…
ANS:B
Only(i)

21.Refer the code


@component
@Profile(“myprofile”)
classProduct{}
Common word//(“myprofile”)
ANS:B
System.setProperty(“….”);

22.John has created a properties file like below


Config.properties
Common Word(“james,1009090,inject values in customer
ANS:A
@Component
Public…
@Value…
Private int customer;
@Value(…”)
Private String Coustomer Name}

23.Which of the following is correct with respect to spring?


(i)@Configuration…XML files Spring configuration
(ii)@componentScan is used to scan stereotype annotation
ANS:Only (ii)
@componentScan

24.which of the following is correct


(i)JVM Support IOC
(ii)Spring Container Manages the instance of …
ANS : Only(ii)
25.Refer the Below Entity class
@Entity
Public Class EmployeeEntity{
@Id
Private int employeeId;
Private String employeeName;
……. Double salary;
//Getters and Setters are coded}
ANS: A
List<EmployeeEntity>findBySalaryBetweenOrderBySalary…param2)

26.Correct with respect to spring transaction propagation types?


(i)propagation type Propagation.REQUIRED starts a new transaction ,if a method …
(ii) propagation type Propagation.REQUIRED…
ANS: Both (1 and 2)

27. CORRECT with respect to JSP?


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

28.CORRECT statement about autowiring


ANS: C
Autowiring requires setter or constructor in bean class

29.Identify the correct hierarchy of servlets assuming you are required to create a registration
ANS: A
RegistrationServlet,java…
HTTPServlet…..
GeneralServlet ..

30.Which is an abstract class which provides the basic implementation of Servlet interface except
Service() method?
ANS:C
Generic Servlet
31.from the following tables match the JSP implicit Objects given in table A with APIs in servlets
package given in table B.
Table A Table B
1) Out i)ServletContext,
//Common word(“application,JSPWriter,exception,Object,page,throwable.
ANS: A
1-ii,2-I,3-iv,4-iii

32.Incorrect statement about JSR-330 annotation


ANS: C
JSR-330……

33.Assume that class “Employee” is created with property “empid” and its setter method.
Refer the spring configuration given below
<bean id =”emp” class=”com.Employee”>
<property name=”empid” value=”john”>
</bean>
Employee object ///applicationContext///
ANS: A
1

34.Refer the below incomplete code for a test class


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(____=MyConfig.class)
..
Public class TestSpringCustomClass {
@AutoWired
Private Employee employee
//Test cases goes here}
ANS: A
Classes , @ActivePro....

35.Refer the code below


@Entity
Class BookEntity{
@Id
Private int…;
///Common word(“authorName, publisherType;,getters and setters}
Choose from the below to retrieve the books using Query method approach
ANS:A
findByPublisherType(String pType)
36.Refer the JSP code below
<body>
<h3>
<%!
Int bookId=1;
Int publishYear =2000;
Public int incrementBookId(int bookId){
Return bookid==;
…….
Predict the output
ANS:B
BookId:2
PublishYear:2001

37.which of the following ..are correct with respect to JSP


(i) default scope of a variable is page
(ii) session scope variable will be available in all jsp files …
(iii)JSTL codes are placed inside service() method
ANS:B
Both(i) and(ii)

38.When servlet destroy() method will be invoked by servlet container?


ANS:A ,C
When you male any change in the servlet class and same
When you stop the server, destroy method of all existing servlet objects will ne molded

39.refer the code


Package com.model;
@component(“prodObject”)
@profile(“myProdProfile”)
Public class product {
Private int productid;
Private string product Name;
}
….

..
///Common word(“ activate”)
ANS:A
@ActiveProfiles(profiles=”myOrderProfile”)
40.Refer the incomplete code
@Component
Class customer{
….
Private Cart cart ;
}
Assume instance of the cart is managed by Spring Container by the name “cartObj” and all the
Commonword//(“SpEL to inject the cart object in customer bean
ANS:A
@Value(“#(cartOBJ”)

41.refer to the incomplete code


Package com.accenture.lkm;
___line1__
Class customer{
Private int customerId;
___Line2____
Private address address;
____Line3____
____Line4____
……Common word///(“address”, @ComponentScan(basePackage =”com”)
Public class SpringConfig{
}
Public class Tester{
ANS: A;
@Component, @Autowired, @Component,@Configuration,annotationConfigApplicationContext.
42. Type annotations? Choose 2
ANS: A,B
@component
@service

43./springormdemos”/>
<property name =”username” value….;
<property name=”password” value….;
</bean>
<bean>
Id-“cst_entityManagerFactory” class=*org.springframework.com…
/// dataSource , JpaVendorAdapter”
Class=”org.springframework.orm.jpa.vendor.hibernate.jpavendoradapter
<property name=”showSql”….
<property name=”generate..
Value=”org.hibernate.dialect.MySQL5Dialect”/>
ANS: A
driverManagerDatasource,LocalCOntainerEntityManagerFactoryBean,@Repository,@Auto f

44.incomplete code given below


<bean>
<!—Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager=”txManager”/>
<bean id=”txManager” class=”org.springframework.com.jpa…..
<property name=”entityManagerFactory” ref


----Line1___
Common word///(“ EmployeeDAOImpl implements EmployeeDAO{
addEmployee,integer employee
ANS: C
@Repository,@persistenceContext,@Transaction(value=”txManager”)

45.Consider the code given below


Package com.accenture.lkm;
Public class Employee {
Private List<String>hobbies;
//getters and setters are already codede
Common word //(“playing cricket , Watching Movies, Ui teater……’”);
ANS: B
Employee 2 Hobbies: [playing cricket ,Watching Amovie]

46.Refer the code


Package com.accenture.lkm;
Public class job {
Private int jobId;
//getters and setter
}
Public class person{
Private String[] skills;
___Line1___
Private Job job;
This skill = skill,
….
//// Spring config java class below…
..
ANS: A
@value(“#(myjob)”).@configuration, @Bean, @beanname = “my…”);

47.Service class (Physical transaction)


/line-x
Public integer addEmployee….
Employeebean , DepartmentBean
Int result=0;
Int

..
deptId+employeeDepartmentDAO.addEmployee..
return result;
// DAO Class( logical Transactions)
//
Code for creating employee
ANS: A
@Transaction(“value =”txManager”,rollback=NullPointerException.class)

48.Which method is used to retrieve the recent access time of a request by user from session?
ANS:D
getLastAccessedTime().

49.refer the code below


Web.xml
<web-app>
<servlet>
Common word//(“Magazine , com.accnture.magazine.servlet,book, load-on-startup”)
ANS: A
Book servlet

50.Komal’s task is to create a customer report on daily…


Everyday when she generates a report … task
ANS: i & iii

i.
<% java.util.Data date = new java.util.Date():
out.print(data);
%>
iii.
<%
Java.util.Data data = new java.utilDate():
%>
<%=data%>

51…… about @ DiritesContext annotation.


ANS: B
It is used to close and Load the application context once again for other ….

52.refer the code given below


@Component
@Profile(“myprodfile”)
Class product{
}
Choose from the below a valid option toactivate the profile “myprodfile”
ANS: B
System.setProperty(“spring.profiles.active”,”myprofile”);

53.which of the following are stereotype annotation?(choose 2)


ANS: A,B
@component, @service
54.login.html;
<html>
<body>
<h2>Login Page</h2>
<form action=”sessionServlet1”>
<table>
<tr><td>UserName</td><td>…..
<tr><td>Password</td><td>……
</table>
…..John, admin.
ANS: B
page2…..null

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

56.farhan wants to write a code to add 2 number and return the result…..
ANS:B

57.Miss.Ashrey has been asked to add headers and footers…..JSP….


Header.JSP and footer.JSP
ANS: A
<…
<….
<…

<..
<..

58.refer code
@entity
Public class EmployeeEntity
@Id
Private int empId;
…string name;
,,,,double salary ;
//getter and setter methods

Valid update query to update the JPA Data


ANS: A;
@modifiying
@query(“update EmployeeEntity k set k salary=new Sai’)
Int updateSalary(@Param(“newSai”)Double salary)
59.
Correct or not
i. Request scope variable in the page…
ii. Request Dispatcher of servlet API shares the request ,,,
ANS:B;
Both I and ii

60.ClassRunner.class
“myprofile”);
ANS: A, classes, @ActiveProfiles

61.multiple choice ANS:1,2


use@autowired at lineX
use@autowired at lineY
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="library" class="com.accenture.lkm.Library">


<cons........>
<bean class............Book">
<constructor-arg value="book1"></constructor-arg>
(
</bean>
</constructor-arg>
</bean>

JSR-330 annotations JSR-330 annotations can not beuesd along with Spring framework annotations

To delete the session attribute we can call public void removeAttributes(String name) , By invoking public void
invaliddate(), In web.xml file use <session->

@RunWith(Spring.Junit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile") Public class TestSpringCustomClass{
public class TestSpringCustomClass{ @Autowired private Employee employee; } ___
___
}
Choose from below a valid combination to complete the above code____

@Component class Customer{----------private Cart cart; } @Value

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


_____Line 1_____
class Customer{
private int customerId;
_____Line 2_____
private Address address;
}
______Line 3_____ @Component,@Autowied,@Coponent,@Configuration,AnnottionConfigApplicationContext
class Address{
public Address(){
------
------
-------
}
@Entity class BookEntity{ @Id private int bookId; private String authorName; private String publisherType; //getter and setters }

DriverManageDataSource , LocalContainerEntityManagerFactoryBean,@Respository ,Autowired

@Respository, @PersistenceContext , @Transactional(value="Manager")


Which of the following is correct statement with respect to Spring test @DirtiesContext

@Configuration public class AppConfig { @Bean("address") public Address creatAddress() { Adsress address= new Address(); ApplicatonContext ctx=new AnnotationConfigApplicationContext(AppConfig.class); Address address=(Address)
return Address; }} ctx.getBean("addres");

Refer the incomplete code given below:

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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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
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


Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
Already Repeated Question
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) Session scope variable will be available in all JSP files if it is accessed in a single session both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
Already Repeated Question
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked

When servlet destroy() method is invoked by servlet container?


Which of the following is correct statement with respect to Spring test @DirtiesContext

RegistrationServlet extends HTTPServlet


From the following identify the correct hierarchy of servlets assuming you are required to create a registration servlet to
HttPServlet extends GenericServlet
process registration request.
GenericServlet implements Servlets

Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.
When you want to remove the user data from session, what all the various options available in JSP? All option, other than Perform log out ...
From the following tables match the jsp implicit objects given in table A with Api's in servlets package given in table B
Table A Table B
1.out 1.Servlet c 1. OUT - JSPWRITER 2. APPLICATION- SERVLETCONFIG 3.
2.application 2.JSPWriter EXCEPTION . THROWABLE 4. PAGE - OBJECT
3.exception 3. Object
4.page 4.Throwable
which provides the basic implementation of Servlet interface except Generic Servlet
Which is an abstract class which provides the basic implementation of servlet interface except service() method? Generic Servlet
Refer the code given below
package com.model;
@component("prodObject")
@Profile("myProdProfile")
public classs Product
{
private int productid;
private String productName;
}
@ActiveProfiles(profiles="myorderProfile")
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 ....


Refer the code given below
@Entity
public class EmployeeEntity{
@Id @Modyfying
private int empId; @Query("update EmployeeEntity
private String name;
private double salary; Options are not clear
//getter and setter methods
}
Choose the valid implementation of the Update query to update employee salary, using Spring JPA Data.
From the following identify TWO INCORRECT statements about ServletCoding objects.
i) It is not created for each servlet dusring servlet initialization.
ii) It will be available to all servletsof an application. i and ii only
iii) Its lifetime is until the servlet class object is destroyed.
iv) One object per servlet class
Raghav must pre populate doctor's names from doctors table in a drop down list when patient is booking appointment online.
. He has written required method implementation in DAO and service layer.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Raghav added following query in orm.xml file

<named-query name="getPatientsData">
@Query(name="getPatientData")
<query>select p.pName,p.appointmentDate from patients p </query>
List<String> getPatientsData();
</named-query>

Select the correct methid declaration in DAO interface. Refer the patients class and patients table.
Raghav has added a method to update the details of the patients as below
public interface PatientsDAO
{
@Query(name="updateQuery1") @Modifying is not used on the method output should return the string data which i.. the updated
int updateAppointmentSlot(Patients patients, String new Appointment(Time); appointment time.
}
But he getting exception as "DML operation is not supported".What went wrong?

Raghav added the following methods in Service and DAO implementation classes to add paitent's information in db.
//service implementation
@transactional(propagation=Propagation.REQUIRED)
Integer addPatientInService(Patients patient)
{
//calling DAO method
}
addPatientInDAO() method always exceutes in a new transaction rather than the interface started in service
//DAO implementation layer of addPatientInService() method.
@transactional(propagation=Propagation.REQUIRES_NEW)
Integer addPatientInService(Patients patient)
{
//implementation
}

what is the behaviour of the addPatientInDAO() method?


Which of the following is/are correct statement(s) with respect to spring test?
(i) @DirtiesContest is used to mark the context dirty so that it can be closed
only (i)
(ii) @ContextConfiguration can only point to Spring XML.....
Choose the most appropriate option.
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;

refer the code given below


@Component
@Profile("myprofile")
System.setproperty("springprofiles active","myprofile").
class Product{
}
choose from below option to activate the profile"myprofile"

DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
Which of the following is correct statement with respect to Spring test @DirtiesContext

_____ the incomplete code given below:


<beans>
<!--Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager____->
-----
-----
</bean>
@Repository,@PersostenceContext@Transactional(value="tx.Manager")
</beans>
____LIne 1____
public class EmployeeDAOlmpl implements____{
____Line 2_____
-------
____Line 3_____

<web-app>
--------------
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a serviet filter to log IP addresses of the requesis originate. help him from the following
options to identify meant for serviet filters in web.xmi file.
<web-mapping>
<filter-name>...</filter-name>
<urt-pattern>...</urt-pattern>
</filter-mapping>
----------
</web-app>

consider the code given below:


package com.accenture.ikm;
public class Employee(
private List<String>hobbies;
)
<beans>
<bean id="employee"class="com.accenture.ikm.Employee">
<property name="hobbies">
Employee 2 Hobbies : [Playing Cricket Watching Movies]
<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
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code below


package com.accenture.ikm;
public class job{
private int jobid;
//getter and setter
}
public class person{
@Value("(myjob)").@Configuration @bean
private String[] skills;
--------Line1-----------
private job job;
Person(String[]Skills){
this.skills=skills;
}
}
Refer the Spring configuration code given below:
@Configuration
public class AppConfig {
ApplicationContext.ctx=
@bean("address")
new AnnotationConfigurationApplicationContext AppConfig .....
public address createAddress(){
Address address= (Address) ctx get....("address")
Address address = new Address();
return address;
}
Refer the code given below:
@Entity
class BookEntity{
@id
private int bookid; findByPublisherType(String p Type)
private String title;
private String authorName;
private String publisherType;
}
public Integer addEmployee
employeeBean,DepartmentBean
int result= 0;
int
deptId=employeeDepartment
@Transaction(value = "txManager",Propagation.REQUIRED_NEW)
employeeBean.setDepartmentCode
result =
deptId+employeeDepartment
return result;
}
which of the following statements are correct:
(i)Default scope of a veriable is page.
(i) & (ii)
(ii) Session scope veriable will be availabe in all JSP filesif it is accessed in a single session.
(iii) JSTL codes placed inside service() method of translated serviet.
Which method is used to retrieve the recent access time of a request by user by session? getLastAccessedTime()
Which of the following is correct statement with respect to Spring test @DirtiesContext

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>
Book Servlet
</servlet>

<servlet>
<servlet-name>Magazine</servlet-name>
<servlet-class>com.accenture.MagazineServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
Choose from below valid options which provides complete support for creation of JPA specific EntityManagerFactory and
LocalContainerEntityManagerFactoryBean
Transaction Management.
Please Refer the following JSP pages Header.jsp <h1> This is Content of Header</h1> 1
<web-app>

<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the </filter>
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.(Option is not Visible but answer is correct. just cross check in exam) <filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>

</web-app>
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile")
Option 1(options not visible)
public class TestSpringCustomClass{ @Autowired private Employee employee; }
Which is an Abstract class which provides the basic implementation of Sevlet interface except Service method? Generic Servlet
Consider the code below package com.accenture.lkm @Component("address") public class Address @Value("Hyderabad-
Employee Address Banglore,Maharashtra
Telangana")
Refer the code given below @Component @Profile("myProfile") class Product{} Choose from below a valid option to activate
System.setProperty("spring.profiles.active", "myProfile");
the profile "myprofile"
@Componet public class Customer{ @Value("${customerID}")
John has created properties file as below config properties CustomerName: James,CustomerID:1009090(Once Verify once.
private int customerID; @Value("${customerName}")
As options are not visible.Go with the Syntax)
private int customerName;
which of the following statements are correct? 1.JVM supports IOC 2. Spring Container manages the instance of the beans
only II
mentioned in the configuration and provides them back to code when needed.
which of the following statements are correct? 1. @Configuration is used to declare a XML file as a Spring configuration 2.
only II
@ComponentScan is used to scan stereotype annotation.
(i) To delete the session...........
want to remove user data from session, what all various options available in (ii) by invoking public void invalidate().
(iii) in web.xml file use<session-timeout>15</session-timeout>
Which of the following is correct statement with respect to Spring test @DirtiesContext

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.uti.Date();
out.print(date);
%>
ii.
<% i & iii
java.uti.Date date =new java.uti.Date();
%>
<%=date;%>
iii.
<%
java.uti.Date date =new java.uti.Date();
out.print(date);
%>
<%date%>

about @DirtiesContext annotation it is used to closed and load the application context.......
to retrieve the recent access times of a request by user from session? getLastAccessedTime()
(i)When you makes any changes in the...........
When Servlet destroy() method will be invoked by servlet container?
(ii)Whwn you stop the server, Destroy method of the.....
Refer the incomplete code given below:
<beans>
<!--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>
____Line1_______ @Repository,@PersistenceContext,@Transactional(value="txManager")
public class EmployeeDAolmpl implements EmployeeDAO{
_____Line2______
private EntityManager entityManager;
____Line3_______
public Integer addEmployee(EmployeeBean employeeBean)
Integer employeeID = 0;
return employeeID;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<jsp include page="Header.jsp">


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

which of the followign os CORRECT with respect to spring transection propogation


1)propogation typr Ptopogation REQUIRED starts a new transection ,it a method is involved another method and a
transection does not required.
both(1) and (2)
2) propogation type Propogation.REQUIRED_NEW start a new transection.if a method is involvedfrom another method and a
transection already exists
choose most appropriate option

Refer the incomplete code given below: package com.accenture.lkm;


class House{
private String houseNum;
--------------Line1-----------
--------------line2------------
private Rooom room; @Autowired,@Qualifier("room")
//setter and getter}
class Room{
private int roomNum;
//setter and getter}
[further question not visible in mcq3(c) pdf]

Assume that class "Employee" is created with property 'empid" and its setter metod
Refer teh spring configuration below
<bean id="emp" class ='com.Employee">
<property name="empID' value ="john">
</bean>
How many Emplotyees objects will be created if the below code executes successfully?
1
public static void main(String[] arg){
Employee emp1 =(Employee) context.getBean("emp");
Employee emp2 =(Employee) context.getBean("emp");
Employee emp3 = emp1;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____________(profiles="myProfile")
classes, @ActiveProfile
public class TestSpringCustomClass{
@Autowired
(Option was not visible properly spelling may be different)
private Employee employee;
Test cases goes here
}
@Entity
public class CustomerEntity{
@Id @Modifying
private int cid; @Query("delete from CustomerEntity k where ......0
private String cname; int delete(@Param("cpoint") double ....
private double credit;
??getter and setter (the words which are not visible is marked as dots)
}

refer the code given below


@Entity
class BookEntity{
@Id
private int bookId;
private String title; findByPublisherType(String pType)
private String authorName;
private String publishertype;
//getter and setters
}
choose from below the valid option to retrieve the books based on the given publisher type by using query method approach
Refer the JSP coide given below and predict the output
<body>
<h3>
<%!
int bookId=1;
int publishYear = 2000; Book Id :2
public int incrementBookId(int bookId){ Publish Year :2001
return bookId++;
}
%>

Which of the fopllowing is CORRECT with respect to propogation type


propogation.REQUIRES_NEW?
option(!!) only
(!) For a method, begin a new transaction always
(!!) if a method is invokes from another method and a transaction exists, then the same transaction is used
choose the most appropriate
Line-X
public integer addEmployeeAndDepartment(EmployeeBean employeeBean,
Departmentbean departmentbean) throws Exception {
int result = 0;
int deptId = employeeDepartmentDAO.addDepartment(departmentBean); @Transaction(value="txmanager",propogation = Propogation.REQUIRES_NEW)
employee.Bean.setDepartmentCode(deptId);
result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

Which of the following statement are CORRECT with resepect to jsP


(!) Default scope of a variable is page
(!!) Session scope variable will be available in all JSP files if it is accessed in a single session both (!) and (!!)
(!!!) JSTL codes are placed insideservice() method of translater servlet
choose the most appropriate option
From the following identify the correct hierarchy of servelets assuming you are required to
Option not visible
create a registration servlet to process registration request
(!) When you make any changes in the servlet class and save
When Servlet destroy() method will be invoked by servlet Container?
(!!) When you stop the server, destroy method of all existing servlet objects will be mo...
John has created a properties file below: @C... (line not visible)

config.properties public class Customer{


customerName: James @Value("..........");
CustomerId: 1009090 ..........not visible.......
Choose from below a valid option to inject values in Customer bean from confiig.properties file }
Which of the following are correct with respect to Spring:

(i) @Configuration is used to declare an XML file as Spring configuration


option (ii) is correct
(ii) @CompensationScan is used to scan stereotype annotation

Choose most appropriate option


Which of the following statement(s) is/are CORRECT?
option (ii) is correct
(i) JVM Supports IOC
(ii) Spring container manages the instance of the beans mentioned in configuration and provides them back to code when needed.
(Not visible) is a web developer wants to create a web page which always lands in portal.accenture.com, whenever user hits on welcome button in index.html given below:

index.html
-----------------------
<form action="MyServelet" method="POST">
<input type="submit" value="welcome">
</form>

Now Blessie started writing the code, all of a sudden, she handed over the job of completing it to you due to unavoidable reasons. Incomplete code is attached below for your reference.

MyServlet.java
--------------------------- response.sendRedirect("https:/portal.accenture.com");
@WebServlet(urlPatterns="/MyServlet)
public class MyServlet extends HttpServlet{
public static final long serialVersionUID = 1L;

public myServlet(){
super();
}

..........................................
Which of the following is correct statement with respect to Spring test @DirtiesContext

@Entity

public class EmployeeEntity{


@Id;
private int employeeId;
List<EmployeeEntity> findBySalaryBetweenOrderBySalaryDesc(Double param1, Double param2))
private String employeeName;
private Double salary;
//Getters and Setters are coded
}

Which of the following are with respect to Spring transaction 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.
both (i) and (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 option.


Choose from below the CORRECT statement about Autowiring. Autowiring requires setters or constructors in bean classes
Consider a web application is created with a welcome index.html mapped with a Servlet class to process the response.

Refer the code below:

index.html
.......................................

<form action="LanguagesServelet" method = "POST">


<input type="checkbox" name="language" value="english"/> English
<input type="checkbox" name="language" value="hindi"/> Hindi
<input type="checkbox" name="language" value="tamil"/> Tamil
<input type="checkbox" name="language" value="malayalam"/> Malayalam
<input type="checkbox" name="language" value="telegu"/> Telegu
<input type="checkbox" name="language" value="kannada"/> Kannada
<input type="checkbox" name="language" value="french"/> French
<input type="checkbox" name="language" value="spanish"/> Spanish
<input type="submit" value="Select...........................Languages"/>
</form>

..................Not Visible....................................
when you want to remove the user data from the session,what all the various options available in JSP option starting with(to,by,in)
mr.john has been assigned the task of creating a servlet filter to log IP addresses.......................web.xml file answer not clear but i guess <web>(option 1)
Refer the following JSP pages,
Header.jsp:
<% @ page language="java" content type="text/html:charset=ISO-8859-1" 1

From the following table match the JSP implicit objects given in tabe A with APIs in servlet package given in table B 1-ii,2-i,3-iv,4-iii
.....which provide the basic implementation of servlet interface except GenericServlet
choose from the below the INCORRECT statement about JSR-300 annotation JSR-300 annotation.....
which of the following is/are CORRECT statement with respect to "spring Test" @DirtiesContext is used to mark the context dirty....
which is an abstract class which provide the basic implementation of servlet interface except service() method GenericServlet
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the code given below


package com.model;
@component("prodObject")
@profile("myProdProfile")
@ActiveProfiles(profiles="myOrderProfile")
public class Product{
private int productId'
private String productName;
}
Class Library{
private Book book;
Public Library(Book book){ <bean id="library" class="com.accenture.lkm.Library
this.book=book; <constructor-arg>
} <bean class="com.accenture.lkm.Book">
}

Class Book{ </bean>


private string bookName; </constructor-arg>
public Book(String bookName){ </bean>
this.bookName= bookName;
}
}
Refer the below incomplete code for a test class
classes, @ActiveProfiles
@RunWith(SpringJUnit4ClassRunner.class)
<%!
Peter wants a method to add 2 numbers and return the result. He also wanted to place it
public int add(int num1, int num2) {
inside the service method. Help him to select the appropriate JSP scripting.
return num1 + num2;
}
%>
<%
Sadana wants to share the common database data throughtout the application.
String userName = (String)application.getAttribute("dbname")
Help her to identify the appropriate code to achieve the task.
%>
<%@page language="java" contextType = "text/html:charset=ISO-8859-1"
pageEncoding = "ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<%
<meta charset="ISO-8859-1">
String companyName = "Accenture";
<title>Sample</title>
String projectName = "ABC";
</head>
String location = "HYD";
<body>
%>
<%--Add JSP Script here-->
<%= companyName %>
</body>
<%= projectName %>
</html>
<%= location %>
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.

Identify the CORRECT script


Miss Monica has given login request to 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 Translation, Compilation, Instantiation, Service and Destroy
right order
Which of the following is correct statement with respect to Spring test @DirtiesContext

<web-app>
........
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
Mr John has been assigned the task of creating a servlet flter to log IP addresses
of the computers from which the requests originate. Help him to identify the correct snippet
<filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>
..........
</web-app>
Which of the following is CORRECT with respect to spring transaction propogation ?

i)propogation type: Propogation.REQUIRED starts a new transaction.


another method and a transaction does not exist.
i and ii both are correct
ii)propogation type: Propogation.REQUIRED_NEW starts a new transaction.
from another method and a transaction already exist.

Choose appropriate option.


Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) JSTL codes are placed inside service() method of translated servlet only 3 is correct
(iii) page scope variable is available only on the page where it is declared
Choose the most appropriate option.
_____ the incomplete code given below:
<beans.....>
<!--Assume dataSource, EntityManagerFactory, configuration are provided>
_______Line1______

<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>

</beans>

Choose from below the valid option to enable declaration of transaction


Management using annotations.

<web-app>
<filter>
<filter-name>....</filter-name>
<filter-class>...</filter-class>
</filter>
Shed the task of creating a servlet filter to log IP addressess of the requests originate.help him from the following options
<filter-mapping>
to identify meant for servelet filters on web.xml file
<filter-name>....</filter-name>
<uri-pattern>...<uri-pattern>
</filter-mapping>
.....
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code given below:


package com.accenture.lkm;
Class House{
Private String houseNum;
_____Line1____
_____Line2____
private Room room; @Autowired,@Qualifier("room1"),com
//setter and getter
}
class Room{
private int roomNum;
//setter and getter
}
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("com/accenture/lkm/resource/my_springbean.xml");
Select correct options to refer a Spring configuration file inside aa package? Choose2
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("classpath:com/accenture/lkm/resource/my_springbean.xml");
Which of the following is/are CORRECT with respect to Spring transaction methods?
(i) If a method throws runtime/unchecked exception, then rollback will be triggered implicity
only (i)
(ii) If a method throws checked exception, then rollback will be triggered implicitly
Choose the most appropriate option
@Transactiona(value="txManager",rollbackFor=InvalidDummyException.class)
public Integer addEmployeeAndDepartment(EmployeeBean employeeBean, DeaprtmentBean departmentBean) throws Exception{
int result=0;
int
deptId=employeeDepartmentDAO.addDepartment(deprtmentBean):employeeBean.setDepartmentCode(deptId); @Transactional(value="txManager",propogation=Propagtion Requires_NEW)
result=
deptId+employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which object is creared by web container for each Servlet during servlet initilization ServletConfig

Refer the incomplete code given below:


package com.model;
public class Author{
public Authore(){
System.out.println("author");
}
}
Below configuration is available in the file located at /com/resources/my_springbean.xml
<bean id="authorobj" class="com.model.Author"></bean>
package come.test; @ContextCOnfiguration(locations="/com/resources/my_springbean.xml")@Test
@Runwith(SpringJUnit4ClassRunner.class)
____Line1____
piblic class TestAuthorClass{
@Autowired
private Author author;
____Line2___
public void testAuthor(){
Assert.assertTrue(author!=null);
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="messageSource"
rohit wants to externalize the validation error messages. So, he defined the messages in
class="org springframework.support
'com/accenture/lkm/resoruces/messages_en.properties files'.Help rohit to configure the MesageSource beam in the context file
<property name="name" value="classpath\com\accenture\lkm\resources/messages_en.properties"/>
by choosing a valid option from beiow
</bean>

Rohit deployed the application in the Apache Tomcat Server. But he got an exception as "org.springframework.beans.factory. A) Configure<context:component-scan base-package="com.accenture.lkm.dao"/> in the root context
NoSuchBeanDefinitionException:No qualifying vean of type [com.accenture.lkm.dao.PruchaseDAO]". Choose from below valid confifuration
options to succesfully execute his application C) Configure <mvc:annotation-driven/> in the child context configuration

Rohit wants to display all the validation error messages in purchase jsp. <form:form method="POST" modelAttribute="bean" action="store.html">
Help him to display those messages at the bottom of the page. <table border="3">
Choose from below a valid option. Asssume the below taglib <!--Assume form elements are mentioned appropriately -->
directives are added in the jSP. </table>
<%@taglib url="http://springframework.org/tags/form" prefix="form"%> <spring:hasBindErrors name="bean">
<%@taglib
Consider theurl="http://springframework.org/tags"
code given below: prefix="spring"%> <h3>All Errors</h3>
package com.accenture.lkm; <form:errors path="*" cssClass="error"/>
public class Employee { </spring:hasBindErrors>
private list<String>hobbies: </form:form>
//Getters and Setters are already coded
}
<beans>
<bean id ="employee" class="com.accenture.lkm.Employees">
<property name="hobbies">
<list> Employee 2 hobbies [Playing Cricket Watching Movies]
<value Playing Cricket </value>
<value Watching Movies </value>
<list>
</property>
</bean>
</beans>
public class UIT Tester {
public static void main(String

<web-app>
.......
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a servlet filter to log IP addresses of the request originate. Help him from the following options to identify
meant forservlet filters in web.xml file.
<filter-mapping>
<filter-name>....</filter-name>
<urf-pattern>....</urf-pattern>
</filter mapping>
.......
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the Spring configuration code gievn below:


1 @Configuration
2 public class AppConfig {
3 @Bean("address")
4 public address createAddress( ) { ApplicationContext ctx =
5 Address address = new Address( ) : new annotationConfigApplicationcontextAppConfig
6 return address ; Address address=(Address)ctx
7 }
8 }
Identifybthe correct code to create spring container object and get the address object injected
Choose the most appropriate option.
Refer the incomplete code given below:
package com.accenture.lkm;
public class Job {
private int jobId:
//getter and setter
}
public class Preson {
private String[] skills;
-----------line1--------------
@Value("=(myjob)"1 @configuration @Bean @Beanvalue ="myjob")
private Job job;
person(String[] skills){
}
//getter and setter
}
Refer the Springconfig java class below
------------------Line2--------------------
public class Springconfig(

Which method is used to retrieve the recent access time of a equeste by user from session?
getLastAccessedTime()
choose from below valid option.
Rohit wants to validate the quantity entered by the customer as mentioned in requirement 2. Choose from the below valid Add @Range(min=1, max=10)anotation in the Bean class
option.[Choose 2] The request handler method should include @Valid to @ModelAnnotation parameter
Rohit wants to receive the requests from customers and forward those request to other components of the application for
further processing . Choose from the most appropriate option, which Rohit performs as his first step as per Spring-MVC
workflow.
A
<bean class="org.springframework>
<property name="prefix">
Rohit wants to navigate to success.jsp page on successful submission. Assume he wrote a handler method to return <value>/WEB-INF/jspViews/</value>
ModelAndView with logical view name as success. He needs to configure a View Resolver bean in child configuration file to </property>
resolve the logical view name.Choose from below a valid option <property name="suffix">
<value>jsp</value>
</property>
</bean>
Rohit wants to create a request handler method in controller that can handle customer request and send the response back to Create a request handler method in the controller to map the request using @RequestMapping annotation and
the response back to the customer. Help rohit to achieve this with a valid option given below. return the ModelAndView object.
Rohit wants to auto populate the items available for the selected SportsType to the respective drop-down box. Assume he A
defined the respective method in the controller which can return Map<String,Double>. Rohit is supposed to bind the key as OPTION NOT VISIBLE
label attribute, value as value attribute in the drop-down box. Choose from below a valid option.
Rohit wants to create an auto populated drop-down box in purchase.jsp page. Help Rohit to implement a proper handler Create a method in the controller to invoke DAO layer method which returns the Map of SportsType with
method in controller that can retrieve sportsType defined in DAO layer. Choose from below a valid option. @ModelAttribute annotation.
Which of the following is correct statement with respect to Spring test @DirtiesContext

From the following tables match the JSP implicit objects given in table A with APIs in
sevlets package given in table B. 1 - ii
Table A Table B 2-i
1) out i) ServletContext
2) application ii) JSPWriter 3 - iv
3) exception
4) page
iii) Object
iv) Threwable
4 - iii
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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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


1
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


Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(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 both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked
1 Refer the incomplete code given below

Answer : A) @Value(“#{cartObj}”)
2 Consider the code given below:

Package com.accenture.lkm;

Public class Employee{

Answer :
3 Refer the incomplete code given below

Package com.accenture.lkm;

Public class Job{

Answer : A) Line 1= @value("#jobObjects")


line 2= @configuration
line 3= @bean ………………………etc

4 Which of the following are Stereotype annotations? [Choose 2]

Answer :- A and B (component and service)


5 Assume that class “Employee” is created with property “empid” and its setter
method. Refer the spring configuration given below

Answer : A) 1

6 Refer below incomplete code

Answer : A) @Transaction(value="txManager",propogation.REQUIRED_NEW)
7 From the following identify which is NOT a session management technique?

Answer:- A) Request…………

8 Consider the following code


Login.html:

Answer :- B) Page2 welcomes null(check once).


9 Which lifecycle method of JSP is invoked by the container to perform the………
…………………………….each time when trhe request is received?

Answer :- B) _jsp service

10 Farhan wants to write a code to add 2 numbers and return the result……….
……………………………………….. JSP scripting element.

Answer :- B
11 Miss Ashrey has beed asked to add headers and footers while designing login
and home page………………………………………..Header.jsp and footer.jsp

Answer :- A

12 Which of the following is/are CORECT statement(S) with respect to spring Test?

Answer :- A) Both (i) and (ii).


13 Refer the JSP code below and predict the output.

Answer :- B) Book id :2 Publish year :2001

14 Refer the Spring configuration code given below.

Answer :- B
15 Refer the code given below.
@Entity
Public class EmployeeEntity{

Answer:- A
16 Refer the incomplete code given below:
<beans>
<!..

Answer :- C) @Repository, @PersistenceContext,


@Transactionl(value=”txtManager”).
17 Which of the following statements(s) is/are CORRECT with respect to JSP?

i. Request Scope variable………………………………………


ii. RequestDispatcher…………………………………………..

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

18 Choose from below the INCORRECT statement about JSR-330 ………

Answer:- C) JSR 330……………………………………………………………………………..


19 Refer the code given below.

Answer : A & B (A) Use @Autowired at LineX and (B) Use @Autowired at LineY

20 Refer the below incomplete code for a test class.

Answer : (A)
21 Refer the incomplete code

Answer :- C) @Transactional(value=”txManager”,propagation=propagation REQUIRES_NEW)


22 When Servlet destroy() method will be invoked by Servlet Contsiner?[choose 2]

Answer :- A) When you make any change in the servlet class and save

C) When you stop the server, destroy method of all existing servlet objects………

23 Which is an abstract class which provides the basic implementation of Servlet interface except

Service() method ?

Answer :- C) GenericServlet
24 Refer the Below Entity class.

Answer : (A)
25 Which method is used to retrive the recent access time of a request by user from session?

Chosse from below a valid option.

Answer : D) getLastAccessedTime()
1 Refer the code given below:

Class Library{

Answer: B) <bean id=”library” class=”com.accenture.lkm.library”>

<constructor-arg>

<bean class=”com.accenture.lkm.Book”>

<constructor-arg value=”book1”></constructor=ard>

</bean>

</constructor-arg>

</bean>
2 Refer the incomplete code given below:

Package com.accenture.lkm;

Class House{

Answer :- A) @Autowired, @Qualifier(“room1”).com


3 Select correct options to refer a Spring configuration file inside a package? Choose 2

Answer :- A and D
4 Refer the Spring configuration code given below.

Identify the correct code to create spring container object and get the address object

Injected. Choose the ,ost appropriate option.

Answer :- A
5 Choose from below the valid option which provides the complete support for creation of JPA
specific EntityManagerFactory and Transaction Management.

Answer : B) LocalContainerEntityManageFactoryBean

6 Which of the following is/are Correct with respect to spring transaction methods?

Answer : b) only (i)


7 Refer the code given below.

Choose the valid implementation of the delete query to delete customers who has credit less

Than a particular value.

Answer : A
8 Which of the following statement(s) is/are CORRECT with respect to JSP?

Answer : - C) Only (iii)

9 From the following identify TWO INCORRECT statements about ServletConfig object.

Answer : A) I and ii only


10 Which object is created by web container for each Servlet during servlet initialization?

Answer :- b) ServletConfig
11 Mr.John has been assigned the task of creaing servlet filter to log IP address of the computers

……………………………………………………………………….for servlet filters in web.xml file.

Answer : A
12 Blessie is a web developer wants to create a wep page…………………whenever user hits on
welcome button on index.html given below

Answer :- B) response.sendRedirect(“https://portal.accenture.com”);
1 Sadana wants to share the common database date throughout the application. Help her to identify
the appropriate code to achieve thi task.

Answer : C) <%

String username=(String)application.getAttribute(“dbname”);

%>
2 Refer the following code:

Answer : (A)
3) Refer the following JSP Pages.

Header.jsp:
4) Refer the incomplete code given below.

Package com.model;

Public class Author{

Answer : C) @ContextConfiguration(locations=”/com/resources/my_springbeam_xml”),@test
5) Which of the following is/are CORECT statement(S) with respect to spring Test?

Answer :- B) Only (i)


1. Refer the code given below.

Answer :- B) system.setProperty("spring.profiles.active","myprofile");
2 Consider the code given below

Package com.accenture.lkm;

@component(“address”)

Public class Address{

Answer :- B)Employee Address : Bangalore-Maharashtra


3 John has created a properties file like below

Answer :- A

4. Which of the following is correct with respect to spring?

Answer : - Only 2
5 Which of the following statement(S) is/are correct.

Answer :- Only (ii) is correct.

6 Which of the following is CORRECT with respect to spring transaction pro… types ?

Answer :- A) Both (i) and (ii).


7 Which of the following statements(s) is/are CORRECT with respect to JSP?

Answer : (ii and iii ) 2 and 3 is correct.

8 Choose from below the CORRECT statement about Autowriting.

Answer :- C) Autowriting requires setters or Constructor in bean class.


9 From the following identify the correct hierarchy of servlets assuming you are
request………………………………………………………………..registration request.

Answer :- A

10 Which is an abstract class which provides the basic implementation of servlet interface except
service() method?

Answer :- C) GenericServlet
11 Mr.john has been assigned the task of creating a servlet After to log IP…………………………………………

The correct order of tags meant for servlet filters in web.xml file.

Answer :- A) <web-app>

12 Consider a web application is created with a welcome file index.html mapped with a servlet class

To process the response.

Refer the code below:

Answer :- B
13 When you want to remove the user data from sessions, what all the various options available in
JSP? [Choose 3].

Answer : A) To delete the session attribute we can call public void removeAttribute(String Name)

B) By invoking public void invalidate()

C) In web.xml file use <session-timeout>15</session-timeout>


14 From the following tables match the JSP implicit objects given in table A with API’s in servlets
package given in table B.

Answer :- A) 1.ii 2.i 3.iv 4.iii


16 Refer the code Given Below:

@Entity

Class BookEntity

Answer :- A) findByPublisherType(String p Type)


Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="library" class="com.accenture.lkm.Library">


<cons........>
<bean class............Book">
<constructor-arg value="book1"></constructor-arg>
(
</bean>
</constructor-arg>
</bean>

JSR-330 annotations JSR-330 annotations can not beuesd along with Spring framework annotations

To delete the session attribute we can call public void removeAttributes(String name) , By invoking public void
invaliddate(), In web.xml file use <session->

@RunWith(Spring.Junit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile") Public class TestSpringCustomClass{
public class TestSpringCustomClass{ @Autowired private Employee employee; } ___
___
}
Choose from below a valid combination to complete the above code____

@Component class Customer{----------private Cart cart; } @Value

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


_____Line 1_____
class Customer{
private int customerId;
_____Line 2_____
private Address address;
}
______Line 3_____ @Component,@Autowied,@Coponent,@Configuration,AnnottionConfigApplicationContext
class Address{
public Address(){
------
------
-------
}
@Entity class BookEntity{ @Id private int bookId; private String authorName; private String publisherType; //getter and setters }

DriverManageDataSource , LocalContainerEntityManagerFactoryBean,@Respository ,Autowired

@Respository, @PersistenceContext , @Transactional(value="Manager")


Which of the following is correct statement with respect to Spring test @DirtiesContext

@Configuration public class AppConfig { @Bean("address") public Address creatAddress() { Adsress address= new Address(); ApplicatonContext ctx=new AnnotationConfigApplicationContext(AppConfig.class); Address address=(Address)
return Address; }} ctx.getBean("addres");

Refer the incomplete code given below:

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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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
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


Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
Already Repeated Question
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) Session scope variable will be available in all JSP files if it is accessed in a single session both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
Already Repeated Question
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked

When servlet destroy() method is invoked by servlet container?


Which of the following is correct statement with respect to Spring test @DirtiesContext

RegistrationServlet extends HTTPServlet


From the following identify the correct hierarchy of servlets assuming you are required to create a registration servlet to
HttPServlet extends GenericServlet
process registration request.
GenericServlet implements Servlets

Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.
When you want to remove the user data from session, what all the various options available in JSP? All option, other than Perform log out ...
From the following tables match the jsp implicit objects given in table A with Api's in servlets package given in table B
Table A Table B
1.out 1.Servlet c 1. OUT - JSPWRITER 2. APPLICATION- SERVLETCONFIG 3.
2.application 2.JSPWriter EXCEPTION . THROWABLE 4. PAGE - OBJECT
3.exception 3. Object
4.page 4.Throwable
which provides the basic implementation of Servlet interface except Generic Servlet
Which is an abstract class which provides the basic implementation of servlet interface except service() method? Generic Servlet
Refer the code given below
package com.model;
@component("prodObject")
@Profile("myProdProfile")
public classs Product
{
private int productid;
private String productName;
}
@ActiveProfiles(profiles="myorderProfile")
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 ....


Refer the code given below
@Entity
public class EmployeeEntity{
@Id @Modyfying
private int empId; @Query("update EmployeeEntity
private String name;
private double salary; Options are not clear
//getter and setter methods
}
Choose the valid implementation of the Update query to update employee salary, using Spring JPA Data.
From the following identify TWO INCORRECT statements about ServletCoding objects.
i) It is not created for each servlet dusring servlet initialization.
ii) It will be available to all servletsof an application. i and ii only
iii) Its lifetime is until the servlet class object is destroyed.
iv) One object per servlet class
Raghav must pre populate doctor's names from doctors table in a drop down list when patient is booking appointment online.
. He has written required method implementation in DAO and service layer.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Raghav added following query in orm.xml file

<named-query name="getPatientsData">
@Query(name="getPatientData")
<query>select p.pName,p.appointmentDate from patients p </query>
List<String> getPatientsData();
</named-query>

Select the correct methid declaration in DAO interface. Refer the patients class and patients table.
Raghav has added a method to update the details of the patients as below
public interface PatientsDAO
{
@Query(name="updateQuery1") @Modifying is not used on the method output should return the string data which i.. the updated
int updateAppointmentSlot(Patients patients, String new Appointment(Time); appointment time.
}
But he getting exception as "DML operation is not supported".What went wrong?

Raghav added the following methods in Service and DAO implementation classes to add paitent's information in db.
//service implementation
@transactional(propagation=Propagation.REQUIRED)
Integer addPatientInService(Patients patient)
{
//calling DAO method
}
addPatientInDAO() method always exceutes in a new transaction rather than the interface started in service
//DAO implementation layer of addPatientInService() method.
@transactional(propagation=Propagation.REQUIRES_NEW)
Integer addPatientInService(Patients patient)
{
//implementation
}

what is the behaviour of the addPatientInDAO() method?


Which of the following is/are correct statement(s) with respect to spring test?
(i) @DirtiesContest is used to mark the context dirty so that it can be closed
only (i)
(ii) @ContextConfiguration can only point to Spring XML.....
Choose the most appropriate option.
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;

refer the code given below


@Component
@Profile("myprofile")
System.setproperty("springprofiles active","myprofile").
class Product{
}
choose from below option to activate the profile"myprofile"

DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
Which of the following is correct statement with respect to Spring test @DirtiesContext

_____ the incomplete code given below:


<beans>
<!--Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager____->
-----
-----
</bean>
@Repository,@PersostenceContext@Transactional(value="tx.Manager")
</beans>
____LIne 1____
public class EmployeeDAOlmpl implements____{
____Line 2_____
-------
____Line 3_____

<web-app>
--------------
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a serviet filter to log IP addresses of the requesis originate. help him from the following
options to identify meant for serviet filters in web.xmi file.
<web-mapping>
<filter-name>...</filter-name>
<urt-pattern>...</urt-pattern>
</filter-mapping>
----------
</web-app>

consider the code given below:


package com.accenture.ikm;
public class Employee(
private List<String>hobbies;
)
<beans>
<bean id="employee"class="com.accenture.ikm.Employee">
<property name="hobbies">
Employee 2 Hobbies : [Playing Cricket Watching Movies]
<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
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code below


package com.accenture.ikm;
public class job{
private int jobid;
//getter and setter
}
public class person{
@Value("(myjob)").@Configuration @bean
private String[] skills;
--------Line1-----------
private job job;
Person(String[]Skills){
this.skills=skills;
}
}
Refer the Spring configuration code given below:
@Configuration
public class AppConfig {
ApplicationContext.ctx=
@bean("address")
new AnnotationConfigurationApplicationContext AppConfig .....
public address createAddress(){
Address address= (Address) ctx get....("address")
Address address = new Address();
return address;
}
Refer the code given below:
@Entity
class BookEntity{
@id
private int bookid; findByPublisherType(String p Type)
private String title;
private String authorName;
private String publisherType;
}
public Integer addEmployee
employeeBean,DepartmentBean
int result= 0;
int
deptId=employeeDepartment
@Transaction(value = "txManager",Propagation.REQUIRED_NEW)
employeeBean.setDepartmentCode
result =
deptId+employeeDepartment
return result;
}
which of the following statements are correct:
(i)Default scope of a veriable is page.
(i) & (ii)
(ii) Session scope veriable will be availabe in all JSP filesif it is accessed in a single session.
(iii) JSTL codes placed inside service() method of translated serviet.
Which method is used to retrieve the recent access time of a request by user by session? getLastAccessedTime()
Which of the following is correct statement with respect to Spring test @DirtiesContext

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>
Book Servlet
</servlet>

<servlet>
<servlet-name>Magazine</servlet-name>
<servlet-class>com.accenture.MagazineServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
Choose from below valid options which provides complete support for creation of JPA specific EntityManagerFactory and
LocalContainerEntityManagerFactoryBean
Transaction Management.
Please Refer the following JSP pages Header.jsp <h1> This is Content of Header</h1> 1
<web-app>

<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the </filter>
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.(Option is not Visible but answer is correct. just cross check in exam) <filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>

</web-app>
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile")
Option 1(options not visible)
public class TestSpringCustomClass{ @Autowired private Employee employee; }
Which is an Abstract class which provides the basic implementation of Sevlet interface except Service method? Generic Servlet
Consider the code below package com.accenture.lkm @Component("address") public class Address @Value("Hyderabad-
Employee Address Banglore,Maharashtra
Telangana")
Refer the code given below @Component @Profile("myProfile") class Product{} Choose from below a valid option to activate
System.setProperty("spring.profiles.active", "myProfile");
the profile "myprofile"
@Componet public class Customer{ @Value("${customerID}")
John has created properties file as below config properties CustomerName: James,CustomerID:1009090(Once Verify once.
private int customerID; @Value("${customerName}")
As options are not visible.Go with the Syntax)
private int customerName;
which of the following statements are correct? 1.JVM supports IOC 2. Spring Container manages the instance of the beans
only II
mentioned in the configuration and provides them back to code when needed.
which of the following statements are correct? 1. @Configuration is used to declare a XML file as a Spring configuration 2.
only II
@ComponentScan is used to scan stereotype annotation.
(i) To delete the session...........
want to remove user data from session, what all various options available in (ii) by invoking public void invalidate().
(iii) in web.xml file use<session-timeout>15</session-timeout>
Which of the following is correct statement with respect to Spring test @DirtiesContext

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.uti.Date();
out.print(date);
%>
ii.
<% i & iii
java.uti.Date date =new java.uti.Date();
%>
<%=date;%>
iii.
<%
java.uti.Date date =new java.uti.Date();
out.print(date);
%>
<%date%>

about @DirtiesContext annotation it is used to closed and load the application context.......
to retrieve the recent access times of a request by user from session? getLastAccessedTime()
(i)When you makes any changes in the...........
When Servlet destroy() method will be invoked by servlet container?
(ii)Whwn you stop the server, Destroy method of the.....
Refer the incomplete code given below:
<beans>
<!--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>
____Line1_______ @Repository,@PersistenceContext,@Transactional(value="txManager")
public class EmployeeDAolmpl implements EmployeeDAO{
_____Line2______
private EntityManager entityManager;
____Line3_______
public Integer addEmployee(EmployeeBean employeeBean)
Integer employeeID = 0;
return employeeID;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<jsp include page="Header.jsp">


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

which of the followign os CORRECT with respect to spring transection propogation


1)propogation typr Ptopogation REQUIRED starts a new transection ,it a method is involved another method and a
transection does not required.
both(1) and (2)
2) propogation type Propogation.REQUIRED_NEW start a new transection.if a method is involvedfrom another method and a
transection already exists
choose most appropriate option

Refer the incomplete code given below: package com.accenture.lkm;


class House{
private String houseNum;
--------------Line1-----------
--------------line2------------
private Rooom room; @Autowired,@Qualifier("room")
//setter and getter}
class Room{
private int roomNum;
//setter and getter}
[further question not visible in mcq3(c) pdf]

Assume that class "Employee" is created with property 'empid" and its setter metod
Refer teh spring configuration below
<bean id="emp" class ='com.Employee">
<property name="empID' value ="john">
</bean>
How many Emplotyees objects will be created if the below code executes successfully?
1
public static void main(String[] arg){
Employee emp1 =(Employee) context.getBean("emp");
Employee emp2 =(Employee) context.getBean("emp");
Employee emp3 = emp1;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____________(profiles="myProfile")
classes, @ActiveProfile
public class TestSpringCustomClass{
@Autowired
(Option was not visible properly spelling may be different)
private Employee employee;
Test cases goes here
}
@Entity
public class CustomerEntity{
@Id @Modifying
private int cid; @Query("delete from CustomerEntity k where ......0
private String cname; int delete(@Param("cpoint") double ....
private double credit;
??getter and setter (the words which are not visible is marked as dots)
}

refer the code given below


@Entity
class BookEntity{
@Id
private int bookId;
private String title; findByPublisherType(String pType)
private String authorName;
private String publishertype;
//getter and setters
}
choose from below the valid option to retrieve the books based on the given publisher type by using query method approach
Refer the JSP coide given below and predict the output
<body>
<h3>
<%!
int bookId=1;
int publishYear = 2000; Book Id :2
public int incrementBookId(int bookId){ Publish Year :2001
return bookId++;
}
%>

Which of the fopllowing is CORRECT with respect to propogation type


propogation.REQUIRES_NEW?
option(!!) only
(!) For a method, begin a new transaction always
(!!) if a method is invokes from another method and a transaction exists, then the same transaction is used
choose the most appropriate
Line-X
public integer addEmployeeAndDepartment(EmployeeBean employeeBean,
Departmentbean departmentbean) throws Exception {
int result = 0;
int deptId = employeeDepartmentDAO.addDepartment(departmentBean); @Transaction(value="txmanager",propogation = Propogation.REQUIRES_NEW)
employee.Bean.setDepartmentCode(deptId);
result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

Which of the following statement are CORRECT with resepect to jsP


(!) Default scope of a variable is page
(!!) Session scope variable will be available in all JSP files if it is accessed in a single session both (!) and (!!)
(!!!) JSTL codes are placed insideservice() method of translater servlet
choose the most appropriate option
From the following identify the correct hierarchy of servelets assuming you are required to
Option not visible
create a registration servlet to process registration request
(!) When you make any changes in the servlet class and save
When Servlet destroy() method will be invoked by servlet Container?
(!!) When you stop the server, destroy method of all existing servlet objects will be mo...
John has created a properties file below: @C... (line not visible)

config.properties public class Customer{


customerName: James @Value("..........");
CustomerId: 1009090 ..........not visible.......
Choose from below a valid option to inject values in Customer bean from confiig.properties file }
Which of the following are correct with respect to Spring:

(i) @Configuration is used to declare an XML file as Spring configuration


option (ii) is correct
(ii) @CompensationScan is used to scan stereotype annotation

Choose most appropriate option


Which of the following statement(s) is/are CORRECT?
option (ii) is correct
(i) JVM Supports IOC
(ii) Spring container manages the instance of the beans mentioned in configuration and provides them back to code when needed.
(Not visible) is a web developer wants to create a web page which always lands in portal.accenture.com, whenever user hits on welcome button in index.html given below:

index.html
-----------------------
<form action="MyServelet" method="POST">
<input type="submit" value="welcome">
</form>

Now Blessie started writing the code, all of a sudden, she handed over the job of completing it to you due to unavoidable reasons. Incomplete code is attached below for your reference.

MyServlet.java
--------------------------- response.sendRedirect("https:/portal.accenture.com");
@WebServlet(urlPatterns="/MyServlet)
public class MyServlet extends HttpServlet{
public static final long serialVersionUID = 1L;

public myServlet(){
super();
}

..........................................
Which of the following is correct statement with respect to Spring test @DirtiesContext

@Entity

public class EmployeeEntity{


@Id;
private int employeeId;
List<EmployeeEntity> findBySalaryBetweenOrderBySalaryDesc(Double param1, Double param2))
private String employeeName;
private Double salary;
//Getters and Setters are coded
}

Which of the following are with respect to Spring transaction 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.
both (i) and (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 option.


Choose from below the CORRECT statement about Autowiring. Autowiring requires setters or constructors in bean classes
Consider a web application is created with a welcome index.html mapped with a Servlet class to process the response.

Refer the code below:

index.html
.......................................

<form action="LanguagesServelet" method = "POST">


<input type="checkbox" name="language" value="english"/> English
<input type="checkbox" name="language" value="hindi"/> Hindi
<input type="checkbox" name="language" value="tamil"/> Tamil
<input type="checkbox" name="language" value="malayalam"/> Malayalam
<input type="checkbox" name="language" value="telegu"/> Telegu
<input type="checkbox" name="language" value="kannada"/> Kannada
<input type="checkbox" name="language" value="french"/> French
<input type="checkbox" name="language" value="spanish"/> Spanish
<input type="submit" value="Select...........................Languages"/>
</form>

..................Not Visible....................................
when you want to remove the user data from the session,what all the various options available in JSP option starting with(to,by,in)
mr.john has been assigned the task of creating a servlet filter to log IP addresses.......................web.xml file answer not clear but i guess <web>(option 1)
Refer the following JSP pages,
Header.jsp:
<% @ page language="java" content type="text/html:charset=ISO-8859-1" 1

From the following table match the JSP implicit objects given in tabe A with APIs in servlet package given in table B 1-ii,2-i,3-iv,4-iii
.....which provide the basic implementation of servlet interface except GenericServlet
choose from the below the INCORRECT statement about JSR-300 annotation JSR-300 annotation.....
which of the following is/are CORRECT statement with respect to "spring Test" @DirtiesContext is used to mark the context dirty....
which is an abstract class which provide the basic implementation of servlet interface except service() method GenericServlet
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the code given below


package com.model;
@component("prodObject")
@profile("myProdProfile")
@ActiveProfiles(profiles="myOrderProfile")
public class Product{
private int productId'
private String productName;
}
Class Library{
private Book book;
Public Library(Book book){ <bean id="library" class="com.accenture.lkm.Library
this.book=book; <constructor-arg>
} <bean class="com.accenture.lkm.Book">
}

Class Book{ </bean>


private string bookName; </constructor-arg>
public Book(String bookName){ </bean>
this.bookName= bookName;
}
}
Refer the below incomplete code for a test class
classes, @ActiveProfiles
@RunWith(SpringJUnit4ClassRunner.class)
<%!
Peter wants a method to add 2 numbers and return the result. He also wanted to place it
public int add(int num1, int num2) {
inside the service method. Help him to select the appropriate JSP scripting.
return num1 + num2;
}
%>
<%
Sadana wants to share the common database data throughtout the application.
String userName = (String)application.getAttribute("dbname")
Help her to identify the appropriate code to achieve the task.
%>
<%@page language="java" contextType = "text/html:charset=ISO-8859-1"
pageEncoding = "ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<%
<meta charset="ISO-8859-1">
String companyName = "Accenture";
<title>Sample</title>
String projectName = "ABC";
</head>
String location = "HYD";
<body>
%>
<%--Add JSP Script here-->
<%= companyName %>
</body>
<%= projectName %>
</html>
<%= location %>
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.

Identify the CORRECT script


Miss Monica has given login request to 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 Translation, Compilation, Instantiation, Service and Destroy
right order
Which of the following is correct statement with respect to Spring test @DirtiesContext

<web-app>
........
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
Mr John has been assigned the task of creating a servlet flter to log IP addresses
of the computers from which the requests originate. Help him to identify the correct snippet
<filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>
..........
</web-app>
Which of the following is CORRECT with respect to spring transaction propogation ?

i)propogation type: Propogation.REQUIRED starts a new transaction.


another method and a transaction does not exist.
i and ii both are correct
ii)propogation type: Propogation.REQUIRED_NEW starts a new transaction.
from another method and a transaction already exist.

Choose appropriate option.


Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) JSTL codes are placed inside service() method of translated servlet only 3 is correct
(iii) page scope variable is available only on the page where it is declared
Choose the most appropriate option.
_____ the incomplete code given below:
<beans.....>
<!--Assume dataSource, EntityManagerFactory, configuration are provided>
_______Line1______

<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>

</beans>

Choose from below the valid option to enable declaration of transaction


Management using annotations.

<web-app>
<filter>
<filter-name>....</filter-name>
<filter-class>...</filter-class>
</filter>
Shed the task of creating a servlet filter to log IP addressess of the requests originate.help him from the following options
<filter-mapping>
to identify meant for servelet filters on web.xml file
<filter-name>....</filter-name>
<uri-pattern>...<uri-pattern>
</filter-mapping>
.....
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code given below:


package com.accenture.lkm;
Class House{
Private String houseNum;
_____Line1____
_____Line2____
private Room room; @Autowired,@Qualifier("room1"),com
//setter and getter
}
class Room{
private int roomNum;
//setter and getter
}
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("com/accenture/lkm/resource/my_springbean.xml");
Select correct options to refer a Spring configuration file inside aa package? Choose2
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("classpath:com/accenture/lkm/resource/my_springbean.xml");
Which of the following is/are CORRECT with respect to Spring transaction methods?
(i) If a method throws runtime/unchecked exception, then rollback will be triggered implicity
only (i)
(ii) If a method throws checked exception, then rollback will be triggered implicitly
Choose the most appropriate option
@Transactiona(value="txManager",rollbackFor=InvalidDummyException.class)
public Integer addEmployeeAndDepartment(EmployeeBean employeeBean, DeaprtmentBean departmentBean) throws Exception{
int result=0;
int
deptId=employeeDepartmentDAO.addDepartment(deprtmentBean):employeeBean.setDepartmentCode(deptId); @Transactional(value="txManager",propogation=Propagtion Requires_NEW)
result=
deptId+employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which object is creared by web container for each Servlet during servlet initilization ServletConfig

Refer the incomplete code given below:


package com.model;
public class Author{
public Authore(){
System.out.println("author");
}
}
Below configuration is available in the file located at /com/resources/my_springbean.xml
<bean id="authorobj" class="com.model.Author"></bean>
package come.test; @ContextCOnfiguration(locations="/com/resources/my_springbean.xml")@Test
@Runwith(SpringJUnit4ClassRunner.class)
____Line1____
piblic class TestAuthorClass{
@Autowired
private Author author;
____Line2___
public void testAuthor(){
Assert.assertTrue(author!=null);
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="messageSource"
rohit wants to externalize the validation error messages. So, he defined the messages in
class="org springframework.support
'com/accenture/lkm/resoruces/messages_en.properties files'.Help rohit to configure the MesageSource beam in the context file
<property name="name" value="classpath\com\accenture\lkm\resources/messages_en.properties"/>
by choosing a valid option from beiow
</bean>

Rohit deployed the application in the Apache Tomcat Server. But he got an exception as "org.springframework.beans.factory. A) Configure<context:component-scan base-package="com.accenture.lkm.dao"/> in the root context
NoSuchBeanDefinitionException:No qualifying vean of type [com.accenture.lkm.dao.PruchaseDAO]". Choose from below valid confifuration
options to succesfully execute his application C) Configure <mvc:annotation-driven/> in the child context configuration

Rohit wants to display all the validation error messages in purchase jsp. <form:form method="POST" modelAttribute="bean" action="store.html">
Help him to display those messages at the bottom of the page. <table border="3">
Choose from below a valid option. Asssume the below taglib <!--Assume form elements are mentioned appropriately -->
directives are added in the jSP. </table>
<%@taglib url="http://springframework.org/tags/form" prefix="form"%> <spring:hasBindErrors name="bean">
<%@taglib
Consider theurl="http://springframework.org/tags"
code given below: prefix="spring"%> <h3>All Errors</h3>
package com.accenture.lkm; <form:errors path="*" cssClass="error"/>
public class Employee { </spring:hasBindErrors>
private list<String>hobbies: </form:form>
//Getters and Setters are already coded
}
<beans>
<bean id ="employee" class="com.accenture.lkm.Employees">
<property name="hobbies">
<list> Employee 2 hobbies [Playing Cricket Watching Movies]
<value Playing Cricket </value>
<value Watching Movies </value>
<list>
</property>
</bean>
</beans>
public class UIT Tester {
public static void main(String

<web-app>
.......
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a servlet filter to log IP addresses of the request originate. Help him from the following options to identify
meant forservlet filters in web.xml file.
<filter-mapping>
<filter-name>....</filter-name>
<urf-pattern>....</urf-pattern>
</filter mapping>
.......
</web-app>
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the Spring configuration code gievn below:


1 @Configuration
2 public class AppConfig {
3 @Bean("address")
4 public address createAddress( ) { ApplicationContext ctx =
5 Address address = new Address( ) : new annotationConfigApplicationcontextAppConfig
6 return address ; Address address=(Address)ctx
7 }
8 }
Identifybthe correct code to create spring container object and get the address object injected
Choose the most appropriate option.
Refer the incomplete code given below:
package com.accenture.lkm;
public class Job {
private int jobId:
//getter and setter
}
public class Preson {
private String[] skills;
-----------line1--------------
@Value("=(myjob)"1 @configuration @Bean @Beanvalue ="myjob")
private Job job;
person(String[] skills){
}
//getter and setter
}
Refer the Springconfig java class below
------------------Line2--------------------
public class Springconfig(

Which method is used to retrieve the recent access time of a equeste by user from session?
getLastAccessedTime()
choose from below valid option.
Rohit wants to validate the quantity entered by the customer as mentioned in requirement 2. Choose from the below valid Add @Range(min=1, max=10)anotation in the Bean class
option.[Choose 2] The request handler method should include @Valid to @ModelAnnotation parameter
Rohit wants to receive the requests from customers and forward those request to other components of the application for
further processing . Choose from the most appropriate option, which Rohit performs as his first step as per Spring-MVC
workflow.
A
<bean class="org.springframework>
<property name="prefix">
Rohit wants to navigate to success.jsp page on successful submission. Assume he wrote a handler method to return <value>/WEB-INF/jspViews/</value>
ModelAndView with logical view name as success. He needs to configure a View Resolver bean in child configuration file to </property>
resolve the logical view name.Choose from below a valid option <property name="suffix">
<value>jsp</value>
</property>
</bean>
Rohit wants to create a request handler method in controller that can handle customer request and send the response back to Create a request handler method in the controller to map the request using @RequestMapping annotation and
the response back to the customer. Help rohit to achieve this with a valid option given below. return the ModelAndView object.
Rohit wants to auto populate the items available for the selected SportsType to the respective drop-down box. Assume he A
defined the respective method in the controller which can return Map<String,Double>. Rohit is supposed to bind the key as OPTION NOT VISIBLE
label attribute, value as value attribute in the drop-down box. Choose from below a valid option.
Rohit wants to create an auto populated drop-down box in purchase.jsp page. Help Rohit to implement a proper handler Create a method in the controller to invoke DAO layer method which returns the Map of SportsType with
method in controller that can retrieve sportsType defined in DAO layer. Choose from below a valid option. @ModelAttribute annotation.
Which of the following is correct statement with respect to Spring test @DirtiesContext

From the following tables match the JSP implicit objects given in table A with APIs in
sevlets package given in table B. 1 - ii
Table A Table B 2-i
1) out i) ServletContext
2) application ii) JSPWriter 3 - iv
3) exception
4) page
iii) Object
iv) Threwable
4 - iii
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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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


1
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


Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(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 both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked
1) Refer the code given bellow
@component
@profile(“myprofile”)
Class product{
.
.
,
}

Ans: Option B
System.setProperty(“springprofileactive”.”myprofile”);
2)
Consider the code given below
Package com.accenture.lkm:
@Component(“Address”)

Public class address{

@value(“Hyderabad- Telanga)
Private String addressLine1;
//getters and settersare already coded
}

……………

Ans: Compile time error “bean name address is already used”

Option C
3)
Package com.accenture.lkm;
@Component(“employee”)
Public class Employee{
@Autowired
Private Address address;
//getter setters are already copied
}
………..

Public class UITester{


….....
}

Ans: Option C (Compile tiem error “ bean name address…..)


Q) Which of the following is correct with respect to spring?
i) @configuration is used to declare a XML file as Spring configuration
ii) @Componentscan is used to scan stereotype annotation

Choose the most appropriate option

Ans: ONLY 2

Q) Which of the following statement is /are CORRECT?

i) JVM Supports IOC


ii) Spring Container manages the instance of the beans mentioned in configuration and provide
them back to code when needed

Ans: ONLY 2

Q) Which of the following statement is /are CORRECT with respect to Spring transaction propogation
type?
i. Propagation type Propogation.REQUIRED starts a new transaction………………..
ii. Propagation type Propogation.REQUIRED_NEW starts a new transaction………………..
Choose most appropriate option.

Ans: BOTH
Q) Which of the following statement is /are CORRECT with respect to JSP?
i. Default scope of a variable is request
ii. Application scope variable will be available……………….
iii. JSTL code are not placed inside service() method of …..
iv. Choose the most appropriate option.

Ans: 2,3 Correct.


Q) Choose from the below the COORECT statement about Autowiring.

Ans: Option C (Autowiring requires setter or constructor in ….)


Refer the below entity class
@Entity
Public class public EmployeeEntity{
@Id
Private int employee
………………………
}

Choose from below valid option for Spring JPA Data……………..

………….
Who gets salary within given range in the descending order of salary.

Ans: Option D
List<EmployeeEntity>findBySalaryBetweenDesOrderBySalaryDoubleparam(double param2
Q) Which is an abstract class which provides the basic implementation of servlet interface except service() method?
Ans: Option C (GenericServlet)
Q) Consider a web application is created with a welcome file index.html mapped with a servlet class to process the
response
Refer the code below:
Index.html
……………………

Ans: req.getParameterValues("languages")

bhush
2021-04-10 13:49:37
--------------------------------------------
req.getParameterValues("languages")
Q) when you want to remove the user data from session, what all the various options available in JSP?
[choose 3]

Ans: Option A, B, C
Q) When Servlet destroy() method will be invoked by servlet Container?[choose2]
Ans:1 and 3
(when you make any changes in the servlet class and same
When you stop the servlet, destroy method of all existing……….)
Q) Which of the following is/are CORRECT statement(s) with respect to Spring
test?
i. @DirtiesContext is used to mark the context dirty so……….
ii. @ContextConfiguration can only point to Spring XML configuration……

Choose the most appropriate option


Ans: BOTH
Q) From the following table match the JSP implicit object given in table A with
APIs in servlets package given in table B.
Table A Table B.

1. OUT i) ServletContext
2. Application ii) JSPWriter
3. Exception iii) Object
4. Page iv) Throwable

Ans: Option A
1. OUT ii) JSPWriter
2. Application i) ServletContext
3. Exception iv) Throwable
4. Page iii) Object
Q) Refer the code given below:
Package com.model;
@Component(“prodObject”)
@Profile(“myProdProfile”)
Public class Product{
Private int productid;
Private String productName;
}
Package com.model;
@Component(“orderObeject”)
@Profiel(“myOrderProfile”)
Class Order{
………………….

Ans: Option A
@ActiveProfiles(profile=”myOrderProfiel”)
Q)…………………… JSR-330 annotations.
Ans: B Or
Q) Refer the code given below:
Class Library{
private Book book;
publc Library (Book book){
this.book=book;
}
}

Class Book{
............................................................................................
}
Choose from below…………….to define book as a inner bean of Library.

Ans: Option B
<bean id……………
<constrctor-arg>
……..
<bean class……….
<constructor-arg value=”book1></ constructor-arg>
</bean>
< /constructor-arg>
</bean>
Q) Refer the below incomplete code for a test class
@Runwith(SpringJUnit4ClassRunner.class
@ContextConfiguration…………
……………………….
Public class TestSpringCustomClass{
…………………..
}

Choose from the below a valid combination to complete the above code in the
order as it appears

Ans: Option B
Classes,@profiles
Q) Refer the incomplete code given below:
@Component
Class Customer{
…………………
Private Cart cart;

}
Assume instance of thr cart is managed by Spring Container by the name “cartObj” and all the classes ……
Choose from belowa valid SpEL to inject the cartobject in Customer bean.

Ans: Option A
@Value(“#(cartObj)”)
Q) ….. incomplete code given below.
Package com.accenture.lkm;
……………………Line1……………..
Class customer{

…………………………………………..

Ans: Option A ( @component,@Autowired,@Component,@Configuration,AnnotationConfigApplicationContext


Q) .. Spring configuration code given below
configuration
public class Appconfig{
@Bean(“address”)
Public Address createAddress(){
…………………….
}
}
identify the correct code to create spring container object and get the address object….
Choose the most appropriate option.

Ans: Option B [ ApplicationContext ctx= new AnnotationConfigApplicationContext(ApConfig.class);


Address address=(Address) ctx.getBean(“address”);
Q) Refer the Incomplete code given below:
Package com.accenture.lkm;
Public class job{
Private int jobId;
//getter and setter
}
……………………….

Ans: Option A
[@value(“#(myjob)”),@configuration, @Bean, @bean…..=….)]
Q) Which method is uswd to retrieve the recent access time of a request by user from session?

Ans: Option D [ GetLastAccessedTime() ]


Q) Refer the code below
Web.xml
………
<web-app>
<servlet>
<servlet-name>Book</servlet-name>
<load-on-startp>0</ load-on-startp>
………..

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>

As per web.xml file 2 servlets are configured for this application ……………….
first?
Choose below valid option:

Ans: Option A [ Book Servlet ]


Q) Komal’s task is to create a customer report on daily basis…………………..
Everyday when she generates a report. Help her to identify………………………
task.

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

ii.
<%
java.uitl.Date date=new java.util.Date();
out.print(date);
%>
<%=date;%>
iii.
<%
java.uitl.Date date=new java.util.Date();
out.print(date);
%>
<%=date%>

Ans: i & iii


Q) ………………………………… @DirtiesContext annotation.

Ans: Option B
[ It is used to close and load the application context………………]
MCQ3

Which of the following is correct statement with respect to Spring test @DirtiesContext

<bean id="library" class="com.accenture.lkm.Library">


<cons........>
<bean class............Book">
<constructor-arg value="book1"></constructor-arg>
(
</bean>
</constructor-arg>
</bean>

JSR-330 annotations JSR-330 annotations can not beuesd along with Spring framework annotations

To delete the session attribute we can call public void removeAttributes(String name) , By invoking public void
invaliddate(), In web.xml file use <session->

@RunWith(Spring.Junit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile") Public class TestSpringCustomClass{
classes, @ActiveProfiles
public class TestSpringCustomClass{ @Autowired private Employee employee; } ___
___
}
Choose from below a valid combination to complete the above code____

classes , @ActivePy

@Component class Customer{----------private Cart cart; } @Value

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


_____Line 1_____
class Customer{
private int customerId;
_____Line 2_____
private Address address;
}
______Line 3_____ @Component,@Autowied,@Coponent,@Configuration,AnnottionConfigApplicationContext
class Address{
public Address(){
------
------
-------
}
findByPublisherType(String p
@Entity class BookEntity{ @Id private int bookId; private String authorName; private String publisherType; //getter and setters }
Type)

DriverManageDataSource , LocalContainerEntityManagerFactoryBean,@Respository ,Autowired

@Respository, @PersistenceContext , @Transactional(value="Manager")

@Configuration public class AppConfig { @Bean("address") public Address creatAddress() { Adsress address= new Address(); ApplicatonContext ctx=new AnnotationConfigApplicationContext(AppConfig.class); Address address=(Address)
return Address; }} ctx.getBean("addres");

Refer the incomplete code given below:

1
MCQ3

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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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
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


Already Repeated Question
Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
Already Repeated Question
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.

2
MCQ3

Already Repeated Question


Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(i) Default scope of a variable is application
(ii) Session scope variable will be available in all JSP files if it is accessed in a single session both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
Already Repeated Question
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked

When servlet destroy() method is invoked by servlet container?

RegistrationServlet extends HTTPServlet


From the following identify the correct hierarchy of servlets assuming you are required to create a registration servlet to
HttPServlet extends GenericServlet
process registration request.
GenericServlet implements Servlets

Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.
When you want to remove the user data from session, what all the various options available in JSP? All option, other than Perform log out ...
From the following tables match the jsp implicit objects given in table A with Api's in servlets package given in table B
Table A Table B
1.out 1.Servlet c 1. OUT - JSPWRITER 2. APPLICATION- SERVLETCONFIG 3.
2.application 2.JSPWriter EXCEPTION . THROWABLE 4. PAGE - OBJECT
3.exception 3. Object
4.page 4.Throwable
which provides the basic implementation of Servlet interface except Generic Servlet
Which is an abstract class which provides the basic implementation of servlet interface except service() method? Generic Servlet

3
MCQ3

Refer the code given below


package com.model;
@component("prodObject")
@Profile("myProdProfile")
public classs Product
{
private int productid;
private String productName;
}
@ActiveProfiles(profiles="myorderProfile")
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 ....


Refer the code given below
@Entity
public class EmployeeEntity{
@Id @Modyfying
private int empId; @Query("update EmployeeEntity
private String name;
private double salary; Options are not clear
//getter and setter methods
}
Choose the valid implementation of the Update query to update employee salary, using Spring JPA Data.
From the following identify TWO INCORRECT statements about ServletCoding objects.
i) It is not created for each servlet dusring servlet initialization.
ii) It will be available to all servletsof an application. i and ii only
iii) Its lifetime is until the servlet class object is destroyed.
iv) One object per servlet class
Raghav must pre populate doctor's names from doctors table in a drop down list when patient is booking appointment online.
. He has written required method implementation in DAO and service layer.
Raghav added following query in orm.xml file

<named-query name="getPatientsData">
@Query(name="getPatientData")
<query>select p.pName,p.appointmentDate from patients p </query>
List<String> getPatientsData();
</named-query>

Select the correct methid declaration in DAO interface. Refer the patients class and patients table.
Raghav has added a method to update the details of the patients as below
public interface PatientsDAO
{
@Query(name="updateQuery1") @Modifying is not used on the method output should return the string data which i.. the updated
int updateAppointmentSlot(Patients patients, String new Appointment(Time); appointment time.
}
But he getting exception as "DML operation is not supported".What went wrong?

Raghav added the following methods in Service and DAO implementation classes to add paitent's information in db.
//service implementation
@transactional(propagation=Propagation.REQUIRED)
Integer addPatientInService(Patients patient)
{
//calling DAO method
}
addPatientInDAO() method always exceutes in a new transaction rather than the interface started in service
//DAO implementation layer of addPatientInService() method.
@transactional(propagation=Propagation.REQUIRES_NEW)
Integer addPatientInService(Patients patient)
{
//implementation
}

what is the behaviour of the addPatientInDAO() method?


Which of the following is/are correct statement(s) with respect to spring test?
(i) @DirtiesContest is used to mark the context dirty so that it can be closed
only (i)
(ii) @ContextConfiguration can only point to Spring XML.....
Choose the most appropriate option.

4
MCQ3

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;

refer the code given below


@Component
@Profile("myprofile")
System.setproperty("springprofiles active","myprofile").
class Product{
}
choose from below option to activate the profile"myprofile"

DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
_____ the incomplete code given below:
<beans>
<!--Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager____->
-----
-----
</bean>
@Repository,@PersostenceContext@Transactional(value="tx.Manager")
</beans>
____LIne 1____
public class EmployeeDAOlmpl implements____{
____Line 2_____
-------
____Line 3_____

<web-app>
--------------
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a serviet filter to log IP addresses of the requesis originate. help him from the following
options to identify meant for serviet filters in web.xmi file.
<web-mapping>
<filter-name>...</filter-name>
<urt-pattern>...</urt-pattern>
</filter-mapping>
----------
</web-app>

consider the code given below:


package com.accenture.ikm;
public class Employee(
private List<String>hobbies;
)
<beans>
<bean id="employee"class="com.accenture.ikm.Employee">
<property name="hobbies">
Employee 2 Hobbies : [Playing Cricket Watching Movies]
<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

Refer the incomplete code below


package com.accenture.ikm;
public class job{
private int jobid;
//getter and setter
}
public class person{
@Value("(myjob)").@Configuration @bean
private String[] skills;
--------Line1-----------
private job job;
Person(String[]Skills){
this.skills=skills;
}
}

5
MCQ3

Refer the Spring configuration code given below:


@Configuration
public class AppConfig {
ApplicationContext.ctx=
@bean("address")
new AnnotationConfigurationApplicationContext AppConfig .....
public address createAddress(){
Address address= (Address) ctx get....("address")
Address address = new Address();
return address;
}
Refer the code given below:
@Entity
class BookEntity{
@id
private int bookid; findByPublisherType(String p Type)
private String title;
private String authorName;
private String publisherType;
}
public Integer addEmployee
employeeBean,DepartmentBean
int result= 0;
int
deptId=employeeDepartment
@Transaction(value = "txManager",Propagation.REQUIRED_NEW)
employeeBean.setDepartmentCode
result =
deptId+employeeDepartment
return result;
}
which of the following statements are correct:
(i)Default scope of a veriable is page.
(i) & (ii)
(ii) Session scope veriable will be availabe in all JSP filesif it is accessed in a single session.
(iii) JSTL codes placed inside service() method of translated serviet.
Which method is used to retrieve the recent access time of a request by user by session? getLastAccessedTime()
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>
Book Servlet
</servlet>

<servlet>
<servlet-name>Magazine</servlet-name>
<servlet-class>com.accenture.MagazineServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
Choose from below valid options which provides complete support for creation of JPA specific EntityManagerFactory and
LocalContainerEntityManagerFactoryBean
Transaction Management.
Please Refer the following JSP pages Header.jsp <h1> This is Content of Header</h1> 1
<web-app>

<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
Mr. john has been assigned the task of creating a servlet filter to log IP addresses of the computers from which the </filter>
request originate. help him from the follwing options to identify the correct order of tags meant for servlet filters
in web.xml file.(Option is not Visible but answer is correct. just cross check in exam) <filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>

</web-app>
@RunWith(SpringJUNIT4ClassRunner.class) @ContextConfiguration(----------=MyConfig.class) ----------(profiles="myProfile")
Option 1(options not visible)
public class TestSpringCustomClass{ @Autowired private Employee employee; }
Which is an Abstract class which provides the basic implementation of Sevlet interface except Service method? Generic Servlet
Consider the code below package com.accenture.lkm @Component("address") public class Address @Value("Hyderabad-
Employee Address Banglore,Maharashtra
Telangana")
Refer the code given below @Component @Profile("myProfile") class Product{} Choose from below a valid option to activate
System.setProperty("spring.profiles.active", "myProfile");
the profile "myprofile"

6
MCQ3

@Componet public class Customer{ @Value("${customerID}")


John has created properties file as below config properties CustomerName: James,CustomerID:1009090(Once Verify once.
private int customerID; @Value("${customerName}")
As options are not visible.Go with the Syntax)
private int customerName;
which of the following statements are correct? 1.JVM supports IOC 2. Spring Container manages the instance of the beans
only II
mentioned in the configuration and provides them back to code when needed.
which of the following statements are correct? 1. @Configuration is used to declare a XML file as a Spring configuration 2.
only II
@ComponentScan is used to scan stereotype annotation.
(i) To delete the session...........
want to remove user data from session, what all various options available in (ii) by invoking public void invalidate().
(iii) in web.xml file use<session-timeout>15</session-timeout>
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.uti.Date();
out.print(date);
%>
ii.
<% i & iii
java.uti.Date date =new java.uti.Date();
%>
<%=date;%>
iii.
<%
java.uti.Date date =new java.uti.Date();
out.print(date);
%>
<%date%>

about @DirtiesContext annotation it is used to closed and load the application context.......
to retrieve the recent access times of a request by user from session? getLastAccessedTime()
(i)When you makes any changes in the...........
When Servlet destroy() method will be invoked by servlet container?
(ii)Whwn you stop the server, Destroy method of the.....
Refer the incomplete code given below:
<beans>
<!--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>
____Line1_______ @Repository,@PersistenceContext,@Transactional(value="txManager")
public class EmployeeDAolmpl implements EmployeeDAO{
_____Line2______
private EntityManager entityManager;
____Line3_______
public Integer addEmployee(EmployeeBean employeeBean)
Integer employeeID = 0;
return employeeID;
}

<jsp include page="Header.jsp">


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

7
MCQ3

which of the followign os CORRECT with respect to spring transection propogation


1)propogation typr Ptopogation REQUIRED starts a new transection ,it a method is involved another method and a
transection does not required.
both(1) and (2)
2) propogation type Propogation.REQUIRED_NEW start a new transection.if a method is involvedfrom another method and a
transection already exists
choose most appropriate option

Refer the incomplete code given below: package com.accenture.lkm;


class House{
private String houseNum;
--------------Line1-----------
--------------line2------------
private Rooom room; @Autowired,@Qualifier("room")
//setter and getter}
class Room{
private int roomNum;
//setter and getter}
[further question not visible in mcq3(c) pdf]

Assume that class "Employee" is created with property 'empid" and its setter metod
Refer teh spring configuration below
<bean id="emp" class ='com.Employee">
<property name="empID' value ="john">
</bean>
How many Emplotyees objects will be created if the below code executes successfully?
1
public static void main(String[] arg){
Employee emp1 =(Employee) context.getBean("emp");
Employee emp2 =(Employee) context.getBean("emp");
Employee emp3 = emp1;
}

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(_________=MyConfig.class)
_____________(profiles="myProfile")
classes, @ActiveProfile
public class TestSpringCustomClass{
@Autowired
(Option was not visible properly spelling may be different)
private Employee employee;
Test cases goes here
}
@Entity
public class CustomerEntity{
@Id @Modifying
private int cid; @Query("delete from CustomerEntity k where ......0
private String cname; int delete(@Param("cpoint") double ....
private double credit;
??getter and setter (the words which are not visible is marked as dots)
}

refer the code given below


@Entity
class BookEntity{
@Id
private int bookId;
private String title; findByPublisherType(String pType)
private String authorName;
private String publishertype;
//getter and setters
}
choose from below the valid option to retrieve the books based on the given publisher type by using query method approach

8
MCQ3

Refer the JSP coide given below and predict the output
<body>
<h3>
<%!
int bookId=1;
int publishYear = 2000; Book Id :2
public int incrementBookId(int bookId){ Publish Year :2001
return bookId++;
}
%>

Which of the fopllowing is CORRECT with respect to propogation type


propogation.REQUIRES_NEW?
option(!!) only
(!) For a method, begin a new transaction always
(!!) if a method is invokes from another method and a transaction exists, then the same transaction is used
choose the most appropriate
Line-X
public integer addEmployeeAndDepartment(EmployeeBean employeeBean,
Departmentbean departmentbean) throws Exception {
int result = 0;
int deptId = employeeDepartmentDAO.addDepartment(departmentBean); @Transaction(value="txmanager",propogation = Propogation.REQUIRES_NEW)
employee.Bean.setDepartmentCode(deptId);
result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which of the following statement are CORRECT with resepect to jsP
(!) Default scope of a variable is page
(!!) Session scope variable will be available in all JSP files if it is accessed in a single session both (!) and (!!)
(!!!) JSTL codes are placed insideservice() method of translater servlet
choose the most appropriate option
From the following identify the correct hierarchy of servelets assuming you are required to
Option not visible
create a registration servlet to process registration request
(!) When you make any changes in the servlet class and save
When Servlet destroy() method will be invoked by servlet Container?
(!!) When you stop the server, destroy method of all existing servlet objects will be mo...
John has created a properties file below: @C... (line not visible)

config.properties public class Customer{


customerName: James @Value("..........");
CustomerId: 1009090 ..........not visible.......
Choose from below a valid option to inject values in Customer bean from confiig.properties file }
Which of the following are correct with respect to Spring:

(i) @Configuration is used to declare an XML file as Spring configuration


option (ii) is correct
(ii) @CompensationScan is used to scan stereotype annotation

Choose most appropriate option


Which of the following statement(s) is/are CORRECT?
option (ii) is correct
(i) JVM Supports IOC
(ii) Spring container manages the instance of the beans mentioned in configuration and provides them back to code when needed.

9
MCQ3

(Not visible) is a web developer wants to create a web page which always lands in portal.accenture.com, whenever user hits on welcome button in index.html given below:

index.html
-----------------------
<form action="MyServelet" method="POST">
<input type="submit" value="welcome">
</form>

Now Blessie started writing the code, all of a sudden, she handed over the job of completing it to you due to unavoidable reasons. Incomplete code is attached below for your reference.

MyServlet.java
--------------------------- response.sendRedirect("https:/portal.accenture.com");
@WebServlet(urlPatterns="/MyServlet)
public class MyServlet extends HttpServlet{
public static final long serialVersionUID = 1L;

public myServlet(){
super();
}

..........................................

@Entity

public class EmployeeEntity{


@Id;
private int employeeId;
List<EmployeeEntity> findBySalaryBetweenOrderBySalaryDesc(Double param1, Double param2))
private String employeeName;
private Double salary;
//Getters and Setters are coded
}

Which of the following are with respect to Spring transaction 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.
both (i) and (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 option.


Choose from below the CORRECT statement about Autowiring. Autowiring requires setters or constructors in bean classes
Consider a web application is created with a welcome index.html mapped with a Servlet class to process the response.

Refer the code below:

index.html
.......................................

<form action="LanguagesServelet" method = "POST">


<input type="checkbox" name="language" value="english"/> English
<input type="checkbox" name="language" value="hindi"/> Hindi
<input type="checkbox" name="language" value="tamil"/> Tamil
<input type="checkbox" name="language" value="malayalam"/> Malayalam
<input type="checkbox" name="language" value="telegu"/> Telegu
<input type="checkbox" name="language" value="kannada"/> Kannada
<input type="checkbox" name="language" value="french"/> French
<input type="checkbox" name="language" value="spanish"/> Spanish
<input type="submit" value="Select...........................Languages"/>
</form>

..................Not Visible....................................
when you want to remove the user data from the session,what all the various options available in JSP option starting with(to,by,in)
mr.john has been assigned the task of creating a servlet filter to log IP addresses.......................web.xml file answer not clear but i guess <web>(option 1)
Refer the following JSP pages,
Header.jsp:
<% @ page language="java" content type="text/html:charset=ISO-8859-1" 1

From the following table match the JSP implicit objects given in tabe A with APIs in servlet package given in table B 1-ii,2-i,3-iv,4-iii
.....which provide the basic implementation of servlet interface except GenericServlet
choose from the below the INCORRECT statement about JSR-300 annotation JSR-300 annotation.....
which of the following is/are CORRECT statement with respect to "spring Test" @DirtiesContext is used to mark the context dirty....
which is an abstract class which provide the basic implementation of servlet interface except service() method GenericServlet

10
MCQ3

Refer the code given below


package com.model;
@component("prodObject")
@profile("myProdProfile")
@ActiveProfiles(profiles="myOrderProfile")
public class Product{
private int productId'
private String productName;
}
Class Library{
private Book book;
Public Library(Book book){ <bean id="library" class="com.accenture.lkm.Library
this.book=book; <constructor-arg>
} <bean class="com.accenture.lkm.Book">
}

Class Book{ </bean>


private string bookName; </constructor-arg>
public Book(String bookName){ </bean>
this.bookName= bookName;
}
}
Refer the below incomplete code for a test class
classes, @ActiveProfiles
@RunWith(SpringJUnit4ClassRunner.class)
<%!
Peter wants a method to add 2 numbers and return the result. He also wanted to place it
public int add(int num1, int num2) {
inside the service method. Help him to select the appropriate JSP scripting.
return num1 + num2;
}
%>
<%
Sadana wants to share the common database data throughtout the application.
String userName = (String)application.getAttribute("dbname")
Help her to identify the appropriate code to achieve the task.
%>
<%@page language="java" contextType = "text/html:charset=ISO-8859-1"
pageEncoding = "ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<%
<meta charset="ISO-8859-1">
String companyName = "Accenture";
<title>Sample</title>
String projectName = "ABC";
</head>
String location = "HYD";
<body>
%>
<%--Add JSP Script here-->
<%= companyName %>
</body>
<%= projectName %>
</html>
<%= location %>
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.

Identify the CORRECT script


Miss Monica has given login request to 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 Translation, Compilation, Instantiation, Service and Destroy
right order
<web-app>
........
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
Mr John has been assigned the task of creating a servlet flter to log IP addresses
of the computers from which the requests originate. Help him to identify the correct snippet
<filter-mapping>
<filter-name>...</filter-name>
<url-pattern>...</url-pattern>
</filter-mapping>
..........
</web-app>
Which of the following is CORRECT with respect to spring transaction propogation ?

i)propogation type: Propogation.REQUIRED starts a new transaction.


another method and a transaction does not exist.
i and ii both are correct
ii)propogation type: Propogation.REQUIRED_NEW starts a new transaction.
from another method and a transaction already exist.

Choose appropriate option.

11
MCQ3

Which of the following statements is/are CORRECT with respect to JSP?


(i) Default scope of a variable is application
(ii) JSTL codes are placed inside service() method of translated servlet only 3 is correct
(iii) page scope variable is available only on the page where it is declared
Choose the most appropriate option.
_____ the incomplete code given below:
<beans.....>
<!--Assume dataSource, EntityManagerFactory, configuration are provided>
_______Line1______

<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>

</beans>

Choose from below the valid option to enable declaration of transaction


Management using annotations.

<web-app>
<filter>
<filter-name>....</filter-name>
<filter-class>...</filter-class>
</filter>
Shed the task of creating a servlet filter to log IP addressess of the requests originate.help him from the following options
<filter-mapping>
to identify meant for servelet filters on web.xml file
<filter-name>....</filter-name>
<uri-pattern>...<uri-pattern>
</filter-mapping>
.....
</web-app>

Refer the incomplete code given below:


package com.accenture.lkm;
Class House{
Private String houseNum;
_____Line1____
_____Line2____
private Room room; @Autowired,@Qualifier("room1"),com
//setter and getter
}
class Room{
private int roomNum;
//setter and getter
}
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("com/accenture/lkm/resource/my_springbean.xml");
Select correct options to refer a Spring configuration file inside aa package? Choose2
ApplicationContext applicationContext=new
ClassPathXmlApplicationContext("classpath:com/accenture/lkm/resource/my_springbean.xml");
Which of the following is/are CORRECT with respect to Spring transaction methods?
(i) If a method throws runtime/unchecked exception, then rollback will be triggered implicity
only (i)
(ii) If a method throws checked exception, then rollback will be triggered implicitly
Choose the most appropriate option
@Transactiona(value="txManager",rollbackFor=InvalidDummyException.class)
public Integer addEmployeeAndDepartment(EmployeeBean employeeBean, DeaprtmentBean departmentBean) throws Exception{
int result=0;
int
deptId=employeeDepartmentDAO.addDepartment(deprtmentBean):employeeBean.setDepartmentCode(deptId); @Transactional(value="txManager",propogation=Propagtion Requires_NEW)
result=
deptId+employeeDepartmentDAO.addEmployee(employeeBean);
return result;
}
Which object is creared by web container for each Servlet during servlet initilization ServletConfig

12
MCQ3

Refer the incomplete code given below:


package com.model;
public class Author{
public Authore(){
System.out.println("author");
}
}
Below configuration is available in the file located at /com/resources/my_springbean.xml
<bean id="authorobj" class="com.model.Author"></bean>
package come.test; @ContextCOnfiguration(locations="/com/resources/my_springbean.xml")@Test
@Runwith(SpringJUnit4ClassRunner.class)
____Line1____
piblic class TestAuthorClass{
@Autowired
private Author author;
____Line2___
public void testAuthor(){
Assert.assertTrue(author!=null);
}

<bean id="messageSource"
rohit wants to externalize the validation error messages. So, he defined the messages in
class="org springframework.support
'com/accenture/lkm/resoruces/messages_en.properties files'.Help rohit to configure the MesageSource beam in the context file
<property name="name" value="classpath\com\accenture\lkm\resources/messages_en.properties"/>
by choosing a valid option from beiow
</bean>

Rohit deployed the application in the Apache Tomcat Server. But he got an exception as "org.springframework.beans.factory. A) Configure<context:component-scan base-package="com.accenture.lkm.dao"/> in the root context
NoSuchBeanDefinitionException:No qualifying vean of type [com.accenture.lkm.dao.PruchaseDAO]". Choose from below valid confifuration
options to succesfully execute his application C) Configure <mvc:annotation-driven/> in the child context configuration

Rohit wants to display all the validation error messages in purchase jsp. <form:form method="POST" modelAttribute="bean" action="store.html">
Help him to display those messages at the bottom of the page. <table border="3">
Choose from below a valid option. Asssume the below taglib <!--Assume form elements are mentioned appropriately -->
directives are added in the jSP. </table>
<%@taglib url="http://springframework.org/tags/form" prefix="form"%> <spring:hasBindErrors name="bean">
<%@taglib
Consider theurl="http://springframework.org/tags"
code given below: prefix="spring"%> <h3>All Errors</h3>
package com.accenture.lkm; <form:errors path="*" cssClass="error"/>
public class Employee { </spring:hasBindErrors>
private list<String>hobbies: </form:form>
//Getters and Setters are already coded
}
<beans>
<bean id ="employee" class="com.accenture.lkm.Employees">
<property name="hobbies">
<list> Employee 2 hobbies [Playing Cricket Watching Movies]
<value Playing Cricket </value>
<value Watching Movies </value>
<list>
</property>
</bean>
</beans>
public class UIT Tester {
public static void main(String

<web-app>
.......
<filter>
<filter-name>...</filter-name>
<filter-class>...</filter-class>
</filter>
the task of creating a servlet filter to log IP addresses of the request originate. Help him from the following options to identify
meant forservlet filters in web.xml file.
<filter-mapping>
<filter-name>....</filter-name>
<urf-pattern>....</urf-pattern>
</filter mapping>
.......
</web-app>

13
MCQ3

Refer the Spring configuration code gievn below:


1 @Configuration
2 public class AppConfig {
3 @Bean("address")
4 public address createAddress( ) { ApplicationContext ctx =
5 Address address = new Address( ) : new annotationConfigApplicationcontextAppConfig
6 return address ; Address address=(Address)ctx
7 }
8 }
Identifybthe correct code to create spring container object and get the address object injected
Choose the most appropriate option.
Refer the incomplete code given below:
package com.accenture.lkm;
public class Job {
private int jobId:
//getter and setter
}
public class Preson {
private String[] skills;
-----------line1--------------
@Value("=(myjob)"1 @configuration @Bean @Beanvalue ="myjob")
private Job job;
person(String[] skills){
}
//getter and setter
}
Refer the Springconfig java class below
------------------Line2--------------------
public class Springconfig(

Which method is used to retrieve the recent access time of a equeste by user from session?
getLastAccessedTime()
choose from below valid option.
Rohit wants to validate the quantity entered by the customer as mentioned in requirement 2. Choose from the below valid Add @Range(min=1, max=10)anotation in the Bean class
option.[Choose 2] The request handler method should include @Valid to @ModelAnnotation parameter
Rohit wants to receive the requests from customers and forward those request to other components of the application for
further processing . Choose from the most appropriate option, which Rohit performs as his first step as per Spring-MVC
workflow.
A
<bean class="org.springframework>
<property name="prefix">
Rohit wants to navigate to success.jsp page on successful submission. Assume he wrote a handler method to return <value>/WEB-INF/jspViews/</value>
ModelAndView with logical view name as success. He needs to configure a View Resolver bean in child configuration file to </property>
resolve the logical view name.Choose from below a valid option <property name="suffix">
<value>jsp</value>
</property>
</bean>
Rohit wants to create a request handler method in controller that can handle customer request and send the response back to Create a request handler method in the controller to map the request using @RequestMapping annotation and
the response back to the customer. Help rohit to achieve this with a valid option given below. return the ModelAndView object.
Rohit wants to auto populate the items available for the selected SportsType to the respective drop-down box. Assume he A
defined the respective method in the controller which can return Map<String,Double>. Rohit is supposed to bind the key as OPTION NOT VISIBLE
label attribute, value as value attribute in the drop-down box. Choose from below a valid option.
Rohit wants to create an auto populated drop-down box in purchase.jsp page. Help Rohit to implement a proper handler Create a method in the controller to invoke DAO layer method which returns the Map of SportsType with
method in controller that can retrieve sportsType defined in DAO layer. Choose from below a valid option. @ModelAttribute annotation.
From the following tables match the JSP implicit objects given in table A with APIs in
sevlets package given in table B. 1 - ii
Table A Table B 2-i
1) out i) ServletContext
2) application ii) JSPWriter 3 - iv
3) exception
4) page
iii) Object
iv) Threwable
4 - iii

14
MCQ3

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>
1
<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


Choose from below the INCORRECT statement about JSR-330 annotations?
Assume that class "Employee is created with property "empld" and its setter method.
Refer the spring configuration given below.

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


1
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


Refer the below incomplete code for a test class

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.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
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
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.

15
MCQ3

Refer the JSP code below and predict the output

<body>
<h3>
<%!

int bookld = 1;
int publish Year = 2000;
public int incrementBookld(int bookld) {
return bookld++;
}
Book Id: 2
%> publish Year: 2001

<%
publish Year++;
bookid++;
%>
</h3>
<h3> Book Id: <% = bookld %> </h3>
<h3> Publish Year: <% = publish Year %> </h3>
</body>

Predict the Output.


Which of the following is CORRECT with respect to propogation type Propogation.REQUIRES_NEW?

(i) For a method, begin a new transaction always


(ii) If a method is invoked from another method and a transaction exists, then the same transaction is used. (i) For a method, begin a new transaction always

Choose the most appropriate option


1
2
3
4 //Line-X
5 public Integer addEmployee AndDepartment(EmployeeBean employeeBean, DepartmentBean departmentBean) throws Exception {
6 int result = 0; @Transaction(value = "txManager", propogation = Propogation.REQUIRES_NEW)
7 int deptId = employeeDepartmentDAO.addDepartment(departmentBean);
8 employeeBean.setDepartmentCode(deptId);
9 result = deptId + employeeDepartmentDAO.addEmployee(employeeBean);
10 return result;
11 }
Which of the following statements is/are CORRECT with respect to JSP?
(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 both (i) and (ii)
(iii) JSTL codes are placed inside service() method of translated servlet
Choose the most appropriate option.
1) When you make any change in the servlet class and same
When Servlet destroy() method will be invoked by Servlet Container? [Choose 2]
2) When you stop the server, destroy method of all existing servlet objects all be invoked

16
Question-wise Details

Section #1

Question 1: Time: 24 Sec Marks: 1 / 1

Choose from below the CORRECT statement about Collection Injection in a bean.

Options Response Answer

<props> element to inject a collection of key-

value pairs, where both key and value are

always of String type.

<props> and <map> elements to inject a

collection of key-value pairs, where both key

and value can be of any type.

<props> element to inject a collection of key-

value pairs, where both key and value can be

of any type.

<map> element to inject a collection of key-

value pairs, where both the key and value are

always of String type.

Question 2: Time: 27 Sec Marks: 1 / 1

Joy is building a web application using servlet. He decided to use servlet filter for intercepting the request and response. Help him
to select the appropriate code from the below options to create a filter

Options Response Answer

public class MyFilter implements Filter {

public void init(FilterConfig fConfig)

throws ServletException {

// TODO Auto-generated method

stub

public void destroy() {

// TODO Auto-generated method

2/19
stub

public void doFilter(ServletRequest

request, ServletResponse response,

FilterChain chain) throws IOException,

ServletException {

PrintWriter out=response.getWriter();

out.print("Before service method

execution<br>");

chain.doFilter(request, response);

out.print("After service method

execution");

public class MyFilter implements Filter {

public void init(FilterConfig fConfig)

throws ServletException {

// TODO Auto-generated method

stub

public void destroy() {

// TODO Auto-generated method

stub

public void doFilter(ServletRequest

request, ServletResponse response) throws

IOException, ServletException {

PrintWriter out=response.getWriter();

out.print("Before service method

execution<br>");

chain.doFilter(request, response);

out.print("After service method

execution");

public class MyFilter implements Filter {

public void init(FilterConfig fConfig)

throws ServletException {

// TODO Auto-generated method

stub

public void destroy() {

// TODO Auto-generated method

stub

3/19
public void doFilter(ServletRequest

request, ServletResponse response,

FilterChain chain) throws IOException,

ServletException {

PrintWriter out=response.getWriter();

out.print("Before service method

execution<br>");

chain.forward(request, response);

out.print("After service method

execution");

public class MyFilter implements Filter {

public void init(FilterConfig fConfig)

throws ServletException {

// TODO Auto-generated method

stub

public void destroy() {

// TODO Auto-generated method

stub

public void doFilter(FilterChain chain)

throws IOException, ServletException {

PrintWriter out=response.getWriter();

out.print("Before service method

execution<br>");

chain.doFilter(request, response);

out.print("After service method

execution");

Question 3: Time: 21 Sec Marks: 1 / 1

4/19
index.jsp
-----------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<jsp:include page="display.jsp">
<jsp:param value="John" name="userName"/>
<jsp:param value="John@accenture.com" name="email"/>
</jsp:include>

display.jsp
-----------
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

Username : __________Line1___________
<br/>
Email :__________Line2___________

Choose from below the valid options [Choose 2], in the order as it appears, to print the values of userName and email.

Options Response Answer

<%=request.getParameter("userName") %>

<%=request.getParameter("email") %>

out.println(request.getParameter("userName"))

out.println(request.getParameter("email"));

<@request.getParameter("userName") %>

<%@request.getParameter("email") %>

<c:out value="${param.userName}"></c:out>

<c:out value="${param.email}"></c:out>

Question 4: Time: 20 Sec Marks: 1 / 1

5/19
Refer the incomplete code given below:
package com.accenture.lkm.entity;
@Entity
@Table(name="Doctor")
public class DoctorEntity {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String firstName;
private String lastName;
//setters and getters
}
package com.accenture.lkm.dao;
public interface DoctorDAO extends __________Line1___________{
List<DoctorEntity> __________Line2________________(String firstName);
}
Choose from below the valid option, in the order as it appears, to get doctors details, whose first name starts with 'J' by using
Query Method Approach.

Options Response Answer

CrudRepository<DoctorEntity, Integer>,

findByFirstNameLike

CurdRepository<DoctorEntity, Integer>,

searchByFirstNameLike

CrudRepository<Integer, DoctorEntity>,

getByFirstNameLike

CrudRepository<DoctorEntity, int>,

selectByFirstNameLike

Question 5: Time: 21 Sec Marks: 1 / 1

BookMyBus application allows users to search for bus services in a route. It has a servlet by name SearchBus to respond to such
requests. Given that it is likely to recieve 100 or more requests simultaneously. How likely the web container would respond?

6/19
Options Response Answer

Web container process each request by

spawning threads.

Web container process each request by

creating multiple servlet instances.

Web container process each request by

forwarding it to another web container.

Question 6: Time: 34 Sec Marks: 1 / 1

7/19
Refer the incomplete code given below:
package com.accenture.lkm;
public class Product {
private int productNum;
private String name;
private int barCode;
// Assume setter and getter are generated
}
Below configuration is available in the file located at /com/accenture/lkm/resources/my_springbean.xml
<bean class="com.accenture.lkm.Product" id="prodobj">
<property name="productNum" value="100"></property>
<property name="name" value="Laptop"></property>
<property name="barCode" value="200000"></property>
</bean>
package com.accenture.lkm.test;
@RunWith(SpringJUnit4ClassRunner.class)
_______________1_____________________
public class TestProductClass {
@Autowired
private Product product;
@Test
public void testProduct(){
System.out.println("prod");
Assert.assertTrue(product!=null);
}
____________________2_______________________
@Test
public void testProductBarCode(){
Assert._______3________(product.getBarCode()!=200000);

}
}
Choose from below a valid option to complete the above code, in order to load ApplicationContext for every test method and to
complete the test

8/19
Options Response Answer

@Configuration(locations="/com/accenture/lkm

/resources/my_springbean.xml"),

@DirtiesContext(methodMode=MethodMode.B

EFORE_METHOD), assertFalse

@TestConfiguration(locations="/com/accentur

e/lkm/resources/my_springbean.xml"),

@DirtiesContext, assertFalse

@Configuration(locations="/com/accenture/lkm

/resources/my_springbean.xml"),

@CreateContext(methodMode=MethodMode.

BEFORE_METHOD), assertFalse

@ContextConfiguration(locations="/com/accen

ture/lkm/resources/my_springbean.xml"),

@DirtiesContext(methodMode=MethodMode.B

EFORE_METHOD), assertFalse

Question 7: Time: 40 Sec Marks: 1 / 1

Refer the following table.


MovieName Genre Language
Spartans 300 History English
Dunkirk War film English

From the following help Miss.Nancy to identify CORRECT JSTL tags for creating such table in a JSP page.MovieBean is a bean
with fields movieName, genre and language with getters and setters.

Options Response Answer

<%@page

import="com.accenture.lkm.business.bean.Mo

vieBean"%>

<%@page import="java.util.ArrayList"%>

<%@ page language="java"

contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<%@taglib

uri="http://java.sun.com/jsp/jstl/core" prefix="c"

%>

9/19
<!DOCTYPE html>

<html>

<head>

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

<title>Sample</title>

</head>

<body>

<%

ArrayList<MovieBean> list= new ArrayList();

MovieBean one= new MovieBean();

one.setMovieName("Dunkirk");

one.setGenre("History");

one.setLanguage("English");

MovieBean two= new MovieBean();

two.setMovieName("Spartans 300");

two.setGenre("War film");

two.setLanguage("English");

list.add(one);

list.add(two);

request.setAttribute("movieList", list);

%>

<table>

<tr>

<th>Movie Name</th><th>Genre</th>

<th>Language</th></tr>

<c:forEach items="${movieList}" var="movie">

<tr><td>${movie.movieName }</td>

<td>${movie.genre}</td>

<td>${movie.language}</td></tr>

</c:forEach>

</table>

</body>

</html>

<%@page

import="com.accenture.lkm.business.bean.Mo

vieBean"%>

<%@page import="java.util.ArrayList"%>

<%@ page language="java"

contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<%@taglib

uri="http://java.sun.com/jsp/jstl/core" prefix="c"

%>

10/19
<!DOCTYPE html>

<html>

<head>

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

<title>Sample</title>

</head>

<body>

<%

ArrayList<MovieBean> list= new ArrayList();

MovieBean one= new MovieBean();

one.setMovieName("Dunkirk");

one.setGenre("History");

one.setLanguage("English");

MovieBean two= new MovieBean();

two.setMovieName("Spartans 300");

two.setGenre("War film");

two.setLanguage("English");

list.add(one);

list.add(two);

requestScope.setAttribute("movieList", list);

%>

<table>

<tr>

<th>Movie Name</th><th>Genre</th>

<th>Language</th></tr>

<c:forEach var="${movieList}" items="movie">

<tr><td>${movie.movieName }</td>

<td>${movie.genre}</td>

<td>${movie.language}</td></tr>

</c:forEach>

</table>

</body>

</html>

<%@page

import="com.accenture.lkm.business.bean.Mo

vieBean"%>

<%@page import="java.util.ArrayList"%>

<%@ page language="java"

contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1"%>

<!DOCTYPE html>

<html>

<head>

11/19
<meta charset="ISO-8859-1">

<title>Sample</title>

</head>

<body>

<%

ArrayList<MovieBean> list= new ArrayList();

MovieBean one= new MovieBean();

one.setMovieName("Dunkirk");

one.setGenre("History");

one.setLanguage("English");

MovieBean two= new MovieBean();

two.setMovieName("Spartans 300");

two.setGenre("War film");

two.setLanguage("English");

list.add(one);

list.add(two);

request.setAttribute("movieList", list);

%>

<table>

<tr>

<th>Movie Name</th><th>Genre</th>

<th>Language</th></tr>

<c:forEach var="movieList" items="movie">

<tr><td>${movie.movieName }</td>

<td>${movie.genre}</td>

<td>${movie.language}</td></tr>

</c:forEach>

</table>

</body>

</html>

Question 8: Time: 23 Sec Marks: 1 / 1

Refer the following code


CustomerBean.java:
package com.accenture.lkm;
public class CustomerBean {
private Integer customerId;
private String customerName;
//code for getters and setters
}

12/19
Utility.java:
package com.accenture.lkm;
import java.util.*;
public class Utility {
public List<CustomerBean>getCustomerDetails(){
List<CustomerBean> cList=new ArrayList<CustomerBean>();
CustomerBean c1=new CustomerBean();
c1.setCustomerId(1000);
c1.setCustomerName("John");
CustomerBean c2=new CustomerBean();
c2.setCustomerId(1001);
c2.setCustomerName("Mark");
cList.add(c1);
cList.add(c2);
return cList;
}
}

JSTLDemo.jsp:
<html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page import="com.accenture.lkm.Utility" %>
<%@page import="com.accenture.lkm.CustomerBean" %>
<%@page import="java.util.List" %>
<body>
<%
Utility u=new Utility();
List<CustomerBean> customerList=u.getCustomerDetails();
request.setAttribute("custList",customerList);
%>
<table border="1">
<c:forEach var="index" items="${custList}">
<tr> <td><c:out value="${index.customerId}"></c:out></td>
<td><c:out value="${index.customerName}"></c:out></td>
</tr>
</c:forEach>
</table>
</body>
</html>

What will be outcome when executing the above code?

13/19
Options Response Answer

1000 John

1001 Mark

1000 Mark

1001 John

1001 Mark

1002 John

1001 John

1002 Mark

Question 9: Time: 22 Sec Marks: 1 / 1

14/19
Refer the following code
LoginForm.html:
<html>
<body>
<form action="Login.jsp">
<table border="1">
<tr> <td> User Name </td><td> <input type="text" name="uname"> </td></tr>
<tr> <td> Password </td><td> <input type="password" name="pwd"> </td>
</table>
<input type="submit" value="submit" />
</form>
</body>
</html>

Login.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>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<body>
<c:if test="${param.uname=='System' and param.pwd=='admin'}">
<jsp:forward page="Success.jsp">
<jsp:param value="${param.uname}" name="share"/>
</jsp:forward>
</c:if>
</body>
</html>

Success.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>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<body>
<h2> Login Success, Welcome <c:out value="${param.share}"></c:out> </h2>
</body>
</html>

What will be the outcome if the user is entering the following data in LoginForm.html?
uname: System
pwd: admin

15/19
Options Response Answer

Login Success, Welcome System

Login Success, Welcome null

No output

Login Success, Welcome admin

Question 10: Time: 22 Sec Marks: 1 / 1

Assume that you are creating a web app to get book details from the user and to display it in the response page using Servlet,
JSP and JSTL

Refer below BookForm.jsp - is used to get book details from the user

<form action="book" method="POST">


<table>
<tr><td> Book Id</td><td> <input type="text" name="bookId"/></td></tr>
<tr><td> Book Name</td><td> <input type="text" name="bookName"/></td></tr>
<tr><td> Author</td><td> <input type="text" name="author"/></td></tr>
<tr><td> Price</td><td> <input type="text" name="price"/></td></tr>
</table>
<br>
<input type="submit" value="Submit" />
</form>

Refer below BookServlet.java is used to set the book details in the session so that it can be displayed in Book.jsp page

@WebServlet(value="/book")
public class BookServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public BookServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().append("Served at: ").append(request.getContextPath());
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out=response.getWriter();
HttpSession session=request.getSession();
Book book=new Book();
book.setBookId(Integer.parseInt(request.getParameter("bookId")));

16/19
book.setBookName(request.getParameter("bookName"));
book.setAuthor(request.getParameter("author"));
book.setPrice(Double.parseDouble(request.getParameter("price")));
session.setAttribute("bookBean", book);
RequestDispatcher rd=request.getRequestDispatcher("/Book.jsp");
rd.forward(request, response);
}
}

Check below in Book.jsp jsp comment line is added , we must fill code in it to display the book details added in session from
BookServlet using JSTL. Assume that jstl core library is added in the application.

Book.jsp
--------
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<body>
<%@ page import="com.accenture.bean.Book" %>

<%-- JSTL code goes here --%>

</body>

Choose from the below a valid code to be filled

17/19
Options Response Answer

<c:set var="bean"

value="${requestScope.bookBean}"/>

<c:out value="Book Details"/><br>

<c:out value="Book Id: ${bean.bookId}"/>

<br>

<c:out value="Book Name:

${bean.bookName}"/><br>

<c:out value="Author: ${bean.author}"/>

<br>

<c:out value="Price: ${bean.price}"/><br>

<c:set var="bean"

value="${sessionScope.bookBean}"/>

<c:out value="Book Details"/><br>

<c:out value="Book Id: ${bean.bookId}"/>

<br>

<c:out value="Book Name:

${bean.bookName}"/><br>

<c:out value="Author: ${bean.author}"/>

<br>

<c:out value="Price: ${bean.price}"/><br>

<c:set var="bean" value="${bookBean}"/>

<c:out value="Book Details"/><br>

<c:out value="Book Id: ${bean.bookId}"/>

<br>

<c:out value="Book Name:

${bean.bookName}"/><br>

<c:out value="Author: ${bean.author}"/>

<br>

<c:out value="Price: ${bean.price}"/><br>

<c:set var="bean" value="bookBean"/>

<c:out value="Book Details"/><br>

<c:out value="Book Id:

${bean.getBookId}"/><br>

<c:out value="Book Name:

${bean.getBookName}"/><br>

<c:out value="Author:

${bean.getAuthor}"/><br>

<c:out value="Price: ${bean.getPrice}"/>

<br>

18/19
GenericServlet (c)
BookId-2
PublishYear-2001
findbypublisher(Type
system.setProperty("spring.profiles.active","myprofile");
Line 1= @value("#jobObjects")
line 2= @configuration
line 3= @bean
findByPublisherType(String p type)
component and service
(LocalContainerEntityManagerFactoryBean)
findbypublishe(Type

both i and ii
@Transaction(value="txManager",
propogation.REQUIRED_NEW)
i and ii
_jsp service
1.ii 2.i 3.iv 4.iii
only ii

You might also like