Professional Documents
Culture Documents
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>