Professional Documents
Culture Documents
MCQ 3 Final Merged - Merged Merged
MCQ 3 Final Merged - Merged Merged
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>
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
ANS:A
Address address= (Address ) ctx.getBean(“createAddress”);
OR
ANS:B
……
Address address= (Address ) ctx.getBean(“Address”);
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”);
%>
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
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
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
48.Which method is used to retrieve the recent access time of a request by user from session?
ANS:D
getLastAccessedTime().
i.
<% java.util.Data date = new java.util.Date():
out.print(data);
%>
iii.
<%
Java.util.Data data = new java.utilDate():
%>
<%=data%>
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
<..
<..
58.refer code
@entity
Public class EmployeeEntity
@Id
Private int empId;
…string name;
,,,,double salary ;
//getter and setter methods
60.ClassRunner.class
“myprofile”);
ANS: A, classes, @ActiveProfiles
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____
@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");
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" %>
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 }
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
<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>
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;
}
<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
}
@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;
DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
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>
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>
<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
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
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)
}
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
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.
index.html
.......................................
..................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
<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 ?
<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>
</beans>
<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
<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
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" %>
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 @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
<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>
Answer : A) @Value(“#{cartObj}”)
2 Consider the code given below:
Package com.accenture.lkm;
Answer :
3 Refer the incomplete code given below
Package com.accenture.lkm;
Answer : A) 1
Answer : A) @Transaction(value="txManager",propogation.REQUIRED_NEW)
7 From the following identify which is NOT a session management technique?
Answer:- A) Request…………
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 :- B
15 Refer the code given below.
@Entity
Public class EmployeeEntity{
Answer:- A
16 Refer the incomplete code given below:
<beans>
<!..
Answer : A & B (A) Use @Autowired at LineX and (B) Use @Autowired at LineY
Answer : (A)
21 Refer the incomplete code
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?
Answer : D) getLastAccessedTime()
1 Refer the code given below:
Class 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 and D
4 Refer the Spring configuration code given below.
Identify the correct code to create spring container object and get the address object
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?
Choose the valid implementation of the delete query to delete customers who has credit less
Answer : A
8 Which of the following statement(s) is/are CORRECT with respect to JSP?
9 From the following identify TWO INCORRECT statements about ServletConfig object.
Answer :- b) ServletConfig
11 Mr.John has been assigned the task of creaing servlet filter to log IP address of the computers
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;
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) system.setProperty("spring.profiles.active","myprofile");
2 Consider the code given below
Package com.accenture.lkm;
@component(“address”)
Answer :- A
Answer : - Only 2
5 Which of the following statement(S) is/are correct.
6 Which of the following is CORRECT with respect to spring transaction pro… types ?
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
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)
@Entity
Class BookEntity
Ans: Option B
System.setProperty(“springprofileactive”.”myprofile”);
2)
Consider the code given below
Package com.accenture.lkm:
@Component(“Address”)
@value(“Hyderabad- Telanga)
Private String addressLine1;
//getters and settersare already coded
}
……………
Option C
3)
Package com.accenture.lkm;
@Component(“employee”)
Public class Employee{
@Autowired
Private Address address;
//getter setters are already copied
}
………..
Ans: ONLY 2
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.
………….
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……
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
[@value(“#(myjob)”),@configuration, @Bean, @bean…..=….)]
Q) Which method is uswd to retrieve the recent access time of a request by user from session?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
<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:
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: 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
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____
@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");
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" %>
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 }
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
<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>
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;
}
<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
}
@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;
DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
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>
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>
<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
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
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)
}
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
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.
index.html
.......................................
..................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
<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 ?
<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>
</beans>
<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
<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
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" %>
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 @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
<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>
Which of the following is correct statement with respect to Spring test @DirtiesContext
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
@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");
1
MCQ3
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" %>
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 }
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
<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>
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
<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
}
4
MCQ3
@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;
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>
5
MCQ3
<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
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;
}
7
MCQ3
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)
}
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++;
}
%>
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
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.
index.html
.......................................
..................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
11
MCQ3
<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>
</beans>
<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>
12
MCQ3
<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
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
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" %>
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 @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
<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>
16
Question-wise Details
Section #1
Choose from below the CORRECT statement about Collection Injection in a bean.
of any type.
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
throws ServletException {
stub
2/19
stub
ServletException {
PrintWriter out=response.getWriter();
execution<br>");
chain.doFilter(request, response);
execution");
throws ServletException {
stub
stub
IOException, ServletException {
PrintWriter out=response.getWriter();
execution<br>");
chain.doFilter(request, response);
execution");
throws ServletException {
stub
stub
3/19
public void doFilter(ServletRequest
ServletException {
PrintWriter out=response.getWriter();
execution<br>");
chain.forward(request, response);
execution");
throws ServletException {
stub
stub
PrintWriter out=response.getWriter();
execution<br>");
chain.doFilter(request, response);
execution");
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.
<%=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>
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.
CrudRepository<DoctorEntity, Integer>,
findByFirstNameLike
CurdRepository<DoctorEntity, Integer>,
searchByFirstNameLike
CrudRepository<Integer, DoctorEntity>,
getByFirstNameLike
CrudRepository<DoctorEntity, int>,
selectByFirstNameLike
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
spawning threads.
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
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.
<%@page
import="com.accenture.lkm.business.bean.Mo
vieBean"%>
<%@page import="java.util.ArrayList"%>
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>
<%
one.setMovieName("Dunkirk");
one.setGenre("History");
one.setLanguage("English");
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>
<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"%>
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>
<%
one.setMovieName("Dunkirk");
one.setGenre("History");
one.setLanguage("English");
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>
<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"%>
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>
<%
one.setMovieName("Dunkirk");
one.setGenre("History");
one.setLanguage("English");
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>
<tr><td>${movie.movieName }</td>
<td>${movie.genre}</td>
<td>${movie.language}</td></tr>
</c:forEach>
</table>
</body>
</html>
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>
13/19
Options Response Answer
1000 John
1001 Mark
1000 Mark
1001 John
1001 Mark
1002 John
1001 John
1002 Mark
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
No output
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
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" %>
</body>
17/19
Options Response Answer
<c:set var="bean"
value="${requestScope.bookBean}"/>
<br>
${bean.bookName}"/><br>
<br>
<c:set var="bean"
value="${sessionScope.bookBean}"/>
<br>
${bean.bookName}"/><br>
<br>
<br>
${bean.bookName}"/><br>
<br>
${bean.getBookId}"/><br>
${bean.getBookName}"/><br>
<c:out value="Author:
${bean.getAuthor}"/><br>
<br>
18/19
Which of the following is correct statement with respect to Spring test @DirtiesContext
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____
@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");
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" %>
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 }
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
<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>
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;
}
<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
}
@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;
DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
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>
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>
<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
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
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)
}
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
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.
index.html
.......................................
..................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
<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 ?
<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>
</beans>
<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
<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
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" %>
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 @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
<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>
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>
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
ANS:A
Address address= (Address ) ctx.getBean(“createAddress”);
OR
ANS:B
……
Address address= (Address ) ctx.getBean(“Address”);
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”);
%>
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
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
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
48. Which method is used to retrieve the recent access time of a request by user from session?
ANS:D
getLastAccessedTime().
i.
<% java.util.Data date = new java.util.Date():
out.print(data);
%>
iii.
<%
Java.util.Data data = new java.utilDate():
%>
<%=data%>
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
<..
<..
60. ClassRunner.class
“myprofile”);
ANS: A, classes, @ActiveProfiles
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)
}
Choose from below a valid combination to complete the above code
@Entity class BookEntity{ @Id private int bookId; private String authorName; private String publisherType; //getter and setters }
@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");
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" %>
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 }
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
<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>
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;
}
<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
}
@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;
DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
Which of the following is correct statement with respect to Spring test @DirtiesContext
</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>
<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
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
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)
}
index.html
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
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
index.html
.......................................
..................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
<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 ?
<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>
</beans>
<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
<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
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" %>
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 @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
<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>
Answer : A) @Value(“#{cartObj}”)
2 Consider the code given below:
Package com.accenture.lkm;
Answer :
3 Refer the incomplete code given below
Package com.accenture.lkm;
Answer : A) 1
Answer : A) @Transaction(value="txManager",propogation.REQUIRED_NEW)
7 From the following identify which is NOT a session management technique?
Answer:- A) Request…………
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 :- B
15 Refer the code given below.
@Entity
Public class EmployeeEntity{
Answer:- A
16 Refer the incomplete code given below:
<beans>
<!..
Answer : A & B (A) Use @Autowired at LineX and (B) Use @Autowired at LineY
Answer : (A)
21 Refer the incomplete code
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?
Answer : D) getLastAccessedTime()
1 Refer the code given below:
Class 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 and D
4 Refer the Spring configuration code given below.
Identify the correct code to create spring container object and get the address object
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?
Choose the valid implementation of the delete query to delete customers who has credit less
Answer : A
8 Which of the following statement(s) is/are CORRECT with respect to JSP?
9 From the following identify TWO INCORRECT statements about ServletConfig object.
Answer :- b) ServletConfig
11 Mr.John has been assigned the task of creaing servlet filter to log IP address of the computers
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;
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) system.setProperty("spring.profiles.active","myprofile");
2 Consider the code given below
Package com.accenture.lkm;
@component(“address”)
Answer :- A
Answer : - Only 2
5 Which of the following statement(S) is/are correct.
6 Which of the following is CORRECT with respect to spring transaction pro… types ?
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
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)
@Entity
Class BookEntity
1.Component
2.Class customer{
3. -----------
private Cart cart; Option:1
}
} option:2
option:1&2
goes here
class BookEntity{
@ld
Option:1
private int bookid,
} </bean>
} /constructor-arg>
@Component("address")
public class Address (
@Value("Hyderabad-Telangana")
Option:b
private String addressLine1;
//Getters and Setters are already coded
package com.accenture.lkm;
@Autowired
class House (
______Line2______
}
De here to search
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");
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”)
3 @Bean
6 return address;
7}
8}
Identify the correct code to create spring
container object and get the hea injected.
Choose the most appropriate option.
3 @Id
8 }
(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
@Transactional(value="txManager,
rollbackFor Invalidumyt
ion.class)
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.
<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>
Option:3
25 Refer the following code. <%
<html> %>
<head> <%=companyName %><br>
</head>
<body> Option:1
/TR/htm/4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset-ISO-8859-1
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>
Line1
Person(String[] skills){
Option:1&2
34 Which of the following is CORRECT with Only(i)
respect to propogation type
propogation.REQUIRES NEW?
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
<body>
<h3>
<%!
int bookld=1;
(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
package com.model;
@Component("prodObject) Option:1
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
} </bean>
______Line1________ Option:1
______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>
<bean id="txManager"
class="org.springframework.orm.pa pa
<property name="entityManagerFactory
ref-est_entityMag
</bean
</beans>
_____Line1_____
-/property
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>
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
ANS:A
Address address= (Address ) ctx.getBean(“createAddress”);
OR
ANS:B
……
Address address= (Address ) ctx.getBean(“Address”);
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”);
%>
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
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
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
48.Which method is used to retrieve the recent access time of a request by user from session?
ANS:D
getLastAccessedTime().
i.
<% java.util.Data date = new java.util.Date():
out.print(data);
%>
iii.
<%
Java.util.Data data = new java.utilDate():
%>
<%=data%>
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
<..
<..
58.refer code
@entity
Public class EmployeeEntity
@Id
Private int empId;
…string name;
,,,,double salary ;
//getter and setter methods
60.ClassRunner.class
“myprofile”);
ANS: A, classes, @ActiveProfiles
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____
@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");
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" %>
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 }
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
<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>
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;
}
<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
}
@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;
DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
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>
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>
<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
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
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)
}
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
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.
index.html
.......................................
..................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
<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 ?
<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>
</beans>
<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
<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
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" %>
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 @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
<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>
Answer : A) @Value(“#{cartObj}”)
2 Consider the code given below:
Package com.accenture.lkm;
Answer :
3 Refer the incomplete code given below
Package com.accenture.lkm;
Answer : A) 1
Answer : A) @Transaction(value="txManager",propogation.REQUIRED_NEW)
7 From the following identify which is NOT a session management technique?
Answer:- A) Request…………
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 :- B
15 Refer the code given below.
@Entity
Public class EmployeeEntity{
Answer:- A
16 Refer the incomplete code given below:
<beans>
<!..
Answer : A & B (A) Use @Autowired at LineX and (B) Use @Autowired at LineY
Answer : (A)
21 Refer the incomplete code
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?
Answer : D) getLastAccessedTime()
1 Refer the code given below:
Class 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 and D
4 Refer the Spring configuration code given below.
Identify the correct code to create spring container object and get the address object
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?
Choose the valid implementation of the delete query to delete customers who has credit less
Answer : A
8 Which of the following statement(s) is/are CORRECT with respect to JSP?
9 From the following identify TWO INCORRECT statements about ServletConfig object.
Answer :- b) ServletConfig
11 Mr.John has been assigned the task of creaing servlet filter to log IP address of the computers
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;
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) system.setProperty("spring.profiles.active","myprofile");
2 Consider the code given below
Package com.accenture.lkm;
@component(“address”)
Answer :- A
Answer : - Only 2
5 Which of the following statement(S) is/are correct.
6 Which of the following is CORRECT with respect to spring transaction pro… types ?
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
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)
@Entity
Class BookEntity
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____
@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");
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" %>
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 }
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
<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>
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;
}
<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
}
@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;
DriverManagerDataSource, LocalContainerEntityManagerFactoryBean,@repository,@A
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>
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>
<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
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
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)
}
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
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.
index.html
.......................................
..................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
<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 ?
<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>
</beans>
<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
<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
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" %>
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 @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
<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>
Ans: Option B
System.setProperty(“springprofileactive”.”myprofile”);
2)
Consider the code given below
Package com.accenture.lkm:
@Component(“Address”)
@value(“Hyderabad- Telanga)
Private String addressLine1;
//getters and settersare already coded
}
……………
Option C
3)
Package com.accenture.lkm;
@Component(“employee”)
Public class Employee{
@Autowired
Private Address address;
//getter setters are already copied
}
………..
Ans: ONLY 2
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.
………….
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……
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
[@value(“#(myjob)”),@configuration, @Bean, @bean…..=….)]
Q) Which method is uswd to retrieve the recent access time of a request by user from session?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
<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:
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: 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
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
@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");
1
MCQ3
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" %>
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 }
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
<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>
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
<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
}
4
MCQ3
@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;
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>
5
MCQ3
<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
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;
}
7
MCQ3
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)
}
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++;
}
%>
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
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.
index.html
.......................................
..................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
11
MCQ3
<bean id="transactionManager"
class=org.springframework.orm.jpa.JpaTransactionManager">
<property name="entitymanagerFActory" ref="csf_entityMAnagerFactory"/>
</bean>
</beans>
<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>
12
MCQ3
<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
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
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" %>
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 @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
<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>
16
Question-wise Details
Section #1
Choose from below the CORRECT statement about Collection Injection in a bean.
of any type.
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
throws ServletException {
stub
2/19
stub
ServletException {
PrintWriter out=response.getWriter();
execution<br>");
chain.doFilter(request, response);
execution");
throws ServletException {
stub
stub
IOException, ServletException {
PrintWriter out=response.getWriter();
execution<br>");
chain.doFilter(request, response);
execution");
throws ServletException {
stub
stub
3/19
public void doFilter(ServletRequest
ServletException {
PrintWriter out=response.getWriter();
execution<br>");
chain.forward(request, response);
execution");
throws ServletException {
stub
stub
PrintWriter out=response.getWriter();
execution<br>");
chain.doFilter(request, response);
execution");
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.
<%=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>
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.
CrudRepository<DoctorEntity, Integer>,
findByFirstNameLike
CurdRepository<DoctorEntity, Integer>,
searchByFirstNameLike
CrudRepository<Integer, DoctorEntity>,
getByFirstNameLike
CrudRepository<DoctorEntity, int>,
selectByFirstNameLike
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
spawning threads.
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
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.
<%@page
import="com.accenture.lkm.business.bean.Mo
vieBean"%>
<%@page import="java.util.ArrayList"%>
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>
<%
one.setMovieName("Dunkirk");
one.setGenre("History");
one.setLanguage("English");
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>
<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"%>
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>
<%
one.setMovieName("Dunkirk");
one.setGenre("History");
one.setLanguage("English");
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>
<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"%>
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>
<%
one.setMovieName("Dunkirk");
one.setGenre("History");
one.setLanguage("English");
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>
<tr><td>${movie.movieName }</td>
<td>${movie.genre}</td>
<td>${movie.language}</td></tr>
</c:forEach>
</table>
</body>
</html>
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>
13/19
Options Response Answer
1000 John
1001 Mark
1000 Mark
1001 John
1001 Mark
1002 John
1001 John
1002 Mark
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
No output
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
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" %>
</body>
17/19
Options Response Answer
<c:set var="bean"
value="${requestScope.bookBean}"/>
<br>
${bean.bookName}"/><br>
<br>
<c:set var="bean"
value="${sessionScope.bookBean}"/>
<br>
${bean.bookName}"/><br>
<br>
<br>
${bean.bookName}"/><br>
<br>
${bean.getBookId}"/><br>
${bean.getBookName}"/><br>
<c:out value="Author:
${bean.getAuthor}"/><br>
<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