You are on page 1of 22

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

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


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

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

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

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

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

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


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

DriverManageDataSource , LocalContainerEntityManagerFactoryBean,@Respository ,Autowired

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


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

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

Refer the incomplete code given below:

Refer the folowing JSP pages

Header.jsp:

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

Footer.jsp

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

Half question pending


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

1 <bean id = "emp" class = "com.Employee">


2 <property name = "empId" value = "John">
3 </bean>

How many Employee objects will be created if the below code executes successfuly in a main method?
Assume that "context" referes to spring container ApplicationContext
1
1 public static void main(String[] args) {
2 // code for ApplicationContext creation goes here
3 Employee emp1 = (Employee) context.getBean("emp");
4 Employee emp2 = (Employee) context.getBean("emp");
5 Employee emp3= emp1;
6 }

Use the most appropriate option


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

Refer the below incomplete code for a test class

1 @RunWith(SpringJUnit4ClassRunner.class)
2 @ContextConfiguration(__________ = MyConfig.class)
3 __________________(profiles = "myProfile")
4 public class TestSpringCustomClass (
5 @Autowired
6 private Employee employee:
7 // test cases goes here
8 }
Choose from below a valid combination to complete the above code in the order as it appears.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
private String authorName;
private String publisher Type;
// getters and setters
}

Choose from below the valid option to retrieve the books based on given publisher type by using Query Method Approach
Already Repeated Question
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Already Repeated Question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

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

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

Predict the Output.


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

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


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

Choose the most appropriate option


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

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


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

RegistrationServlet extends HTTPServlet


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

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

choose from the below the valid option to activate ....


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

Raghav added following query in orm.xml file

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

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

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

what is the behaviour of the addPatientInDAO() method?


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

@Component
class Customer(
_____ @Value("#(cartObj")
private Cart cart;
}
Assume instance of the Cart is managed by Spring Container ________
Choose from below a valid SpEL to inject the cart object in Customer bean;

refer the code given below


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

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

_____ the incomplete code given below:


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

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

consider the code given below:


package com.accenture.ikm;
public class Employee(
private List<String>hobbies;
)
<beans>
<bean id="employee"class="com.accenture.ikm.Employee">
<property name="hobbies">
Employee 2 Hobbies : [Playing Cricket Watching Movies]
<list>
<value>playing cricket </value>
<value>watching Movies</value>
</list>
</property></bean></beans>
public class UITester{
public static void main(String args[]){
not visible further question
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the incomplete code below


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

Refer the code below:


Web.xml
------------
<web-app>
<servlet>
<servlet-name>Book</servlet-name>
<servlet-class>com.accenture.BookServlet</servlet-class>
<load-on-startup>0</load-on-startup>
Book Servlet
</servlet>

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

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

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

Komal's task is to create a customer report on daily............


everyday when she generates a report help her to identify............
task.
i.
<%
java.uti.Date date =new java.uti.Date();
out.print(date);
%>
ii.
<% i & iii
java.uti.Date date =new java.uti.Date();
%>
<%=date;%>
iii.
<%
java.uti.Date date =new java.uti.Date();
out.print(date);
%>
<%date%>

about @DirtiesContext annotation it is used to closed and load the application context.......
to retrieve the recent access times of a request by user from session? getLastAccessedTime()
(i)When you makes any changes in the...........
When Servlet destroy() method will be invoked by servlet container?
(ii)Whwn you stop the server, Destroy method of the.....
Refer the incomplete code given below:
<beans>
<!--Assume rest of the configuration is written-->
<tx:annotation-driven transaction-manager="txManager"/>
<bean id="txManager"class="org.springframework.orm.jpa.jpa">
<property name="entityManagerFactory"ref="cst_entityManagerFactory">
</bean>
</beans>
____Line1_______ @Repository,@PersistenceContext,@Transactional(value="txManager")
public class EmployeeDAolmpl implements EmployeeDAO{
_____Line2______
private EntityManager entityManager;
____Line3_______
public Integer addEmployee(EmployeeBean employeeBean)
Integer employeeID = 0;
return employeeID;
}
Which of the following is correct statement with respect to Spring test @DirtiesContext

<jsp include page="Header.jsp">


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

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


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

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


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

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

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

refer the code given below


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

Which of the fopllowing is CORRECT with respect to propogation type


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

Which of the following statement are CORRECT with resepect to jsP


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

config.properties public class Customer{


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

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


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

Choose most appropriate option


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

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

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

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

public myServlet(){
super();
}

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

@Entity

public class EmployeeEntity{


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

Which of the following are with respect to Spring transaction propagation types:

(i) propagation type Propagation.REQUIRED starts a new transaction, if a method is provided from another method and a transaction does not exist.
both (i) and (ii)
(ii) propagation type Propagation.REQUIRED_NEW starts a new transaction, if a method is invoked from another method and a transaction already exists.

Choose the most appropriate option.


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

Refer the code below:

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

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


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

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

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

Refer the code given below


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

Class Book{ </bean>


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

Identify the CORRECT script


Miss Monica has given login request to EventmanagementApp. The app displays a JSP page to prompt her to enter
the username and password. Identify the phases of JSP page it goes through until the response is generated in Translation, Compilation, Instantiation, Service and Destroy
right order
Which of the following is correct statement with respect to Spring test @DirtiesContext

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

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


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

Choose appropriate option.


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

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

</beans>

Choose from below the valid option to enable declaration of transaction


Management using annotations.

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

Refer the incomplete code given below:


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

Refer the incomplete code given below:


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

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

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

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

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

Refer the Spring configuration code gievn below:


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

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

From the following tables match the JSP implicit objects given in table A with APIs in
sevlets package given in table B. 1 - ii
Table A Table B 2-i
1) out i) ServletContext
2) application ii) JSPWriter 3 - iv
3) exception
4) page
iii) Object
iv) Threwable
4 - iii
Refer the folowing JSP pages

Header.jsp:

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

Footer.jsp

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

Half question pending


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

1 <bean id = "emp" class = "com.Employee">


2 <property name = "empId" value = "John">
3 </bean>

How many Employee objects will be created if the below code executes successfuly in a main method?
Assume that "context" referes to spring container ApplicationContext

1 public static void main(String[] args) {


1
2 // code for ApplicationContext creation goes here
3 Employee emp1 = (Employee) context.getBean("emp");
4 Employee emp2 = (Employee) context.getBean("emp");
5 Employee emp3= emp1;
6 }

Use the most appropriate option


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

Refer the below incomplete code for a test class

1 @RunWith(SpringJUnit4ClassRunner.class)
2 @ContextConfiguration(__________ = MyConfig.class)
3 __________________(profiles = "myProfile")
4 public class TestSpringCustomClass (
5 @Autowired
6 private Employee employee:
7 // test cases goes here
8 }
Choose from below a valid combination to complete the above code in the order as it appears.
Refer the code given below:

@Entity
class BookEntity{
@ld
private int bookld;
private String title; findByPublisherType(String pType)
private String authorName;
private String publisher Type;
// getters and setters
}

Choose from below the valid option to retrieve the books based on given publisher type by using Query Method Approach
1 @Entity
2 public class CustomerEntity{
@Modifying
3 @Id
4 private int cid;
@Query("delete from CustomerEntity & where k where k.credit*cname)
5 private String cname;
int delete @Param(credit) double credit
6 private double credit;
7 // getter and setter methods
answer is not visible clearly
Choose the valid implementation of the delete query to delete customers who has credit less than a particular value.
Which of the following is correct statement with respect to Spring test @DirtiesContext

Refer the JSP code below and predict the output

<body>
<h3>
<%!

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

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

Predict the Output.


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

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


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

Choose the most appropriate option


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

You might also like