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

Java MCQ2 Se Ad

The correct answer is C) It is dependent on the database. A thin JDBC driver is dependent on the database as it relies on the database specific classes and methods. It does not have its own network protocol and delegates all requests to the database server.

Uploaded by

melophile653
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
454 views

Java MCQ2 Se Ad

The correct answer is C) It is dependent on the database. A thin JDBC driver is dependent on the database as it relies on the database specific classes and methods. It does not have its own network protocol and delegates all requests to the database server.

Uploaded by

melophile653
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 137

Pre-request every one again to join in every following groups to

get further updates and if you leave groups after your TFA and
stream tests you will miss your further updates for sure so just
stay connected.

Dm - https://t.me/angelnndevil

Main group link - https://t.me/ad2group

Get more dumps here

Materials/Channel/dumps -
https://t.me/adaccenturematerial
1 In order to establish connection with MYSQL database in JDBC

Ans:- 2) jdbc:mysql://localhost:3306/test.
2) There are a number of HTTP methods. Select valid HTTP methods from given list. [choose 2]

Ans :- 1) GET and 2) PUT

3) Suresh a marketing executive wants to create an customer report on monthly basis.

Ans :- B) PreparedStatement
4) Choose from the following CORRECT statements about Class.forName() method call.

Ans :- C) I and II only.

5) Which of the following are JPA providers?[choose 2]

Ans :- EclipseLink and Hibernate.


6) Which object represents the programmatic connection defination?

Ans :- B) EntityManager Factory.

7) Consider the following JPA code. Where “MovieData” is Persistence unit name in persistance.xml
file.

Ans :- A)
8) Choose from below VALID named queires annotation in JPA

Ans : - A)

9) Jack wants to delete a customer(customerId=1001) from a customer table, since customer is not

Ans : - A) Removed.
10)Consider Becky wants to perform update on price and author name by book id on book table

Ans :- C not A.

11) What type of testing is done using junit?

Ans :- D) Unit Testing


12) Anil is explaining Junit5 assumtions to his team.

Ans :- A) Failed assumtion result in a test failure.

13)Thomas is designing home page for a news website. ............. page design.

Ans :- C) <link rel=”stylesheet” type=”text/css” href=”containerstyle.css”/>


14) Ena and her team is working on UI design of a job portal

Ans :- A) POST

15) Dhananjay has been entrusted with the task of creating a webpage.

Ans :- (A)
16) Consider css and html code in mystyle.css and index.html files as below:

Ans :- A) <link rel=”stylesheet” type=”text/css” href=”mystyle.css”>

17) Consider the below html:

Ans:-
18) Which method is used to check whether the designated column can be used in SQL where
clause?

Ans :- c) isSearchable()
19)Harry wants to create a customer report to CRM application………from the given options.

Ans :-

D) when there are no more rows to iterate the retrieved result then… ..... nothing
20) Choose the disadvantage on thin driver from below options

Ans:-

C) It is dependent on the database.


21) Which of the following statement is/are valid to register driver class in JDBC?

Ans :-

A) Statement 4.
22 )Sheila wants to check if a condition in her code is working correctly. Which Junit assert method is

Most appropriate for her?

Ans :- B) void assertTrue(boolean condition)


23) Consider the following test case:

Ans :-

(B)
24) Which one of the below tags create boundries of documents header?

Ans:-

A) <head>
25) Which of the below are valid XML tags?

Ans:

Answer :- <body></body>
26) Which of these statements are correct with respect to CSS?

Ans :-

A) CSS is used for describing the presentation of web pages, including colors,input and fonts
B) CSS enables presentation and content teams can work simultaniously in the independent
components
1) Eesha wants to add a new customer record record in a customer table.
2) Consider the following JPA Code. Where “MovieData” is persistence unit name in

Persistence.xml file.

Ans: -

Answer:- (A)
3)Refer the following JPA code unit1 is the persistence unit name in persistence.xml
Public class MovieDAOImpl{

Answer :- A) i and ii only


4)Mr. John has written a code to update movie details. He has a compile-time error”
…………………………………..help him to fix the error by choosing one of the following options.

Answer :- A) pstatement setInt(2,bean.getMovieId());


5)Which Annoations and method signatures are correct in Junit? [choose 2]

Answer :- A)@BeforeAll static void beforeAll()

B) @BeforeEach void beforeEach()

6) John is creating a java application for CRM. He wants his application to be connected with the
Mysql............................................................. with the database.
7) Refer the following code. Mrs.janet has been asked to code JDBC program

Answer :- (A)
8) From which version of JDBC, driver name registration is not required?

Answer :- B) JDBC 4.0

9)Rose is writing a script where she has a requirement to incorrect ....................... appropriate code.

Answer :- A) var result=document.getElementById(“num”);

result=parseInt(result)+2;

console.log(result);
10 Select a valid option to create html form, that allows users to enter name,email and gender.

Answer:-
11 Which of the following in JPA when invoked, entity changes to managed state.

Answer :- A) i and ii only.


12 Refer the table given below:

Answer :-
13 Consider the below XSL file called LibraryTransform.xsl
14 Consider the following entity classes and sample records

Answer :- customer record with customer 1001 will be deleted from customer table.
15 Bob has a requirement to style a div element in his webpage

Answer : c) .box1 {

background-color: red;

font-style:italic;

}
16 Jacqueline wants to create a customer report by fetching customerid ............ following structure

Answer : ????????????????

17) Please select the correct annotations [choose 3]

Answer :- A) @Test

b) @Disabled

c) @Tag
17 Which of the below statements are correct with respect to HTTP and HTTPS:

Answer:- B) 2nd and 3rd are correct.

18 Ani is working with a house construction application ....................... association

Answer :- A) Its OnetoMany Unidirectional association.


19 Punith, a developer wants to synchronize the changes done on the CustomerEntity objects.
Answer :- 1001 John Pune Gold.
1) Mr. Gaetano gets following error upon executing the code to retrieve Movie
details… ...... String language.

Refer the following code.

Answer :- A ) Pstatement.setInt(1,id).
2) Which of these statements are incorrect with respect to Junit 5? [choose 3]

Answer:- A) Junit 5 supports java 5 or higher

C) Junit Juniper provides support for running Junit3 and Junit 4……..

E) Annotation @BeforeAll is analogous to Junit4’s @BeforeEach


3) Choose from below the INVALID annotation in JPA

Answer :- D) @Qualifier
4) Consider BookMyTicket application. It allows users to book movie folder ............. JPQL
query is correct?

Answer :- A) select movie, screen from MovieEntity movie, ScreenEntity screen where

Movie.movieId=screen.movieId.
5) Consider the following program :

Answer :- 2) Assertions.assertEquals(sValue1, sValue2);


6) Which of the below is/are valid javascript function(s);

Answer :- c) 1st
7) Ena and her team is working on UI design of a Job Portal.

Answer :- A) Post
8) Consider the following code.unit1 is the persistence unit name in………………

Answer : -
9) Which of the following options are valid for the property “hibernate.hdm2ddi.auto”

Answer :- Create
Update
Create-drop

10)Assume the book table is created in book_dp database and record a inserted as per below schema.

Answer :- A) No record deleted.


10) Harish and team is writing is writing a Junit 5 based test cases. Help them to identify, which annotation…….method?

Answer :- org.junit.jupiter.api.Test;
…………………………………..
…………………………………
Some code below
10) Yash task is to update the customer record using JPQL so he was writinh update statement

Answer:- B) Parameter cannot be passes to a named query to do the operation on required data set
11 Predict the output of following program:

Answer :- A) Assertion fails and displays the supplied failure message “condition is true”.
12) Assume that BookEntity and PublisherEntity has many to many JPA Entity relationship,
Refer the tables and code below:

Answer :- A

13) Refer the following code

Answer :- D) True 1001 Delhi


14) Assume that table book is already created in the book_db database, with columns

Answer :- A) 1
15 In JPA, JPQL queries are translated by JPQL query processor. Consider the following SQL statement.

Answer :- A) Select m from MovieEntity m;


Pre-request every one again to join in every following groups to
get further updates and if you leave groups after your TFA and
stream tests you will miss your further updates for sure so just
stay connected.

Dm - https://t.me/angelnndevil

Main group link - https://t.me/ad2group

Get more dumps here

Materials/Channel/dumps -
https://t.me/adaccenturematerial
JAVA MCQ02 Assessinont Olotal Oy 29 9 Fnh T
mett
Section 1 of 1 Section #1 1 of 20 2

Question #1 Revisit Choose the best option

Choose the disadvantage on thin driver from below options OPoor performance than all other drivers

OSoftware installation is required in server or client side


OIt is dependent on the database
OIt is partially written in Java
JAVA MCQ02 Assessment Total 00.2938 Finish Test
metti
Section 1 of1 Section #1 2m 10 2of 20 All 20

Question #2 Revisit Choose the best option

Suresh a marketing executive wants to create an customer reporton monthly basis. He wants OStatement
to iterate the records from customer table more faster. Help him to select appropriate interface
for this situation. O PreparedStatement
O CallableStatement
OResultSet
JAVA Mca02 Assessment9 Total 00 2931
metti Finish Test

Section 1 of 1 Section #1 3 3 of 20 20

Question #3 Revisit Choose the best option


Choose from the following cORRECT statements about Class.forName() method call. O l andl only
This method is used for dynamically loading the driver's classfle into memory and toregisterit O l andll only
automatically.
) Since JDBC 4.0 this is redundant since auto discovery was enabled. Oland l only.
u0) It is used only for loading type 4 driver.
Section 1 of 1 Aof 20
Section #1

Question#4 Revisit Choose the best option

Refer the foliowing code Ofalse


Table: Customer 1001 Pune
Customerld customerName customerLocation
O false
1001 John Delhi
1001 Delhi

CustomerDao.java true
class CustomerDao 1001 Pune
public void updateCustomer() throws SOLException, ClassNotFoundException{
O true
try 1001 Delhi
int id 1001;
double modifiedLocation = "Pune";
String updatedata = "update customer set customerlocation=? where

customerlid= 2"
Connection connection =

DriverManager.getConnection("jdbc.mysql:/localhost:3306/jdbcdemos", "root', "root");


PreparedStatement pstatement =

connection.prepareStatement(updatedata),
pstatement.setint(2, id):
pstatement.setString(1, modifiedLocation);
boolean rowsUpdateCount pstatement.execute():
System.out.printin(rowsupdateCount)
String retrievedata = "select from customer"
Section 1 of 1 Section#1 5 Sof 20 All 20

Question #5 Revisit Choose the best option

Assume that book table is created in book db database and record is inserted as per No record deleted.
below schema
Total No.of Books =4
insert into book (book_name,price) values (Alchemist,250.0);
No. of record deleted = 2
insert into book (book_name,price) values (Secret,200.0)
insert into book (book_name,price) values('GOT,750.0); OTotal No.of Books = 2
insert into book (book_name.price) values ('Hary Potter 450.0); No. of record deleted =2
Refer the code below and predict the output
ORuntime Exception at line-1
publicclass BookExample
private static Connection connect = null;
OCompilation error at line-1
privatestatic PreparedStatement preparedStatement1 null:
private static PreparedStatement preparedStatement2 = null;
private static ResultSet resultSet = nul;

public static void deleteBooks(double price1, double price2)


int noOfRecordDeleted=0;
String query = "delete from book where price between ? and ? :

try{
connect DriverManager.getConnection("jdbc:mysql://localhost:3306
book_db","root","roof")
preparedStatement1=connect.prepareStatement(query);
preparedStatement1.setDouble(1, price1)
preparedStatement1.setDouble(2. price2)
noOfRecordDeleted= preparedStatement1.executeUpdate();
Section 1 of 1 Section #1 6 6 of 20 All

Question #6 Revisit Choose the best option

Consider the following code.unitf is the persistance unit name in persistance.xml. O entity2 is the reference of managed copy hence it wil be a successful updato

public Integer addMovie(MovieBean movie) throws Exception{ Oentity2 results in creation of new record.
I TODO Auto-generated method stub OEntity does not exists exception is thrown.
Integer movielD = 0;

EntityManager entityManager = null;

try
EntityManagerFactory entityManagerFactory=
Persistence.getEntityManagerFactory( 'unit1"):
entyManager = entityManagerFactory.createEntityManager()
MovieEntity movieEntity1 new MovieEntity();:
MovieEntity.setMovield(movieEntity.getMovield();
MovieEntity.setMovieName(movieEntity.getMovieName()
MovieEntity.setMovieGenre(movieEntity getMovieGenre():
entityManager getTransaction().begin():
MovieEntity movieEntity2= entityManager.merge(movieEntity1);
movieEntity2.setMovieName("dummy):
entityManager.getTransaction().commit():
movielD= movieEntity2.getEmployeeld(:
catch (Exception exception){
throw exception;
)finally{
JAVA MCQ02 Assessment Tolal 00.29:07 Finish Test
metti
Section 1 of 1 Section #1 7 of 20 20

Question #7 Revisit Choose the best option(s)

Which ofthe following are JPA providers?[choose 2] EclipselLink


Hibernate
MyBatis
xQJ
NPA
Total 00 29.03 Finish lest
JAVA MCQ02 Assessment
metti
8of 220
Section 1 of 1 Section # 1

Revisit Choose the best option


Question #8

OEntityManager
Which object represents the programmatic connection definition? It also reads
the connection information frompersistence.xml by mapping with the PersistenceUnitName. OEntityManagerFactory

OEntity
O PersistenceContext
Section 1 of 1 Section #1 ol 20
20

Question #9 Revisit Choose the best option

Consider the following JPA code. Where "Movie Data" is persistence unit name in A)
persistance.xml file.
List Object list=query.getResultList();
EntyManagerFactory emfactory = Persistence.createEntityManagerFactory('MovieData"): System.out.printin "Moviename It MovieGenre It MovieLanguage
EntityManager entitymanager = emfactory.createEntityManager(); for (Object entity : list) {
Query query=entityManager.createQuery("select m.movieName, m.genre,m.language from Object) obj=(Object0) entity
MovieEntity m"): System.out.prtin((String)objf0]+"r+(String)objf1]+""+(String)obj[2]):
II Fill the code here

MovieEntity has the fields String movieName, String genre and String language. O B)
Note that Movie table has three rows. Identify only one correct statment from the following
List MovieEntity> list=query.getResultList();
System.out.printin("Moviename It MovieGenre t MovielLanguage");
options to print the movie details as shown.
for(MovieEntity entity: list) {
MovieName MovieGenre MovieLanguage System.out.printin(entity getMovieName()+"\r+entity.getGenre()"
Dunkirk History Spanish
t+entity.getLanguage(0%
Interstellar Science-fiction French
MI 7 Action and Adventure. English C)
ListsObject> list=query.getResultList():
System.out.printin("Moviename It MovieGenre t Movielanguage");
for (Object entity: list) {
Object obj=(Object|) entity
System.out.printn(String)obif1]+""+(String)obj|2]+"\r"+(String)obj[3);
Section 1 of 1 Section #1 9 9of20 A

20

Question #9 Revisit

Conslder the following JPA code. Where "MovieData" is persistence unit name in
O 8)
persistance.xml file.
ListMovieEntity> list=query getResultList():
system.out.printn("Moviename it MovieGere t MovieLanguage")
EntyManagerFactory emfactory =
Persistence.createEntityManagerFactory("MovieData") for (MovieEntity enty: list) {
EntityManager entitymanager= emfactory.createEntityManager()
Query query=entityManager.createQuery("'select m.movieName, m.genre,m.language from System.out.printin(entity.getMovieName()+"+entitygetGenre()+"
MovieEntity m"); P+entity getLanguage()
WFill the code here

C)
MovieEntity has the fields String movieName, String genre and String language. ListObject list=query.getResultList();
Note that Movie table has three rows. Identify only one correct statment from the following System.out.printin("Moviename \t MovieGenre It MovielLanguage"
options to print the movie details as shown. for (Object entity: list) {
Object] obj=(Object|) entity,
MovieName MovieGenre MovielLanguage System.out.prinl(String)obj[1]+""+(String)obj[2]+r+(Stringobj[3);
Dunkirk History Spanish
Interstellar Science-fiction French
MI 7 Action and Adventure English D)
List<MovieEntity> list=query.getResultList()
System.out.printin("Moviename It MovieGenre It MovielLanguage"
for (MovieEntity entity:
list
System.out.printin(entity.getMovieGenre()+"r+entity.getMovieName()+"
r+entity.getLanguage();
O Total 00:28:35 Finish Test
JAVA -MCa02 Assessment
metti 9 10 1 0of 20
G
Section 1 of 1 Section #1

Choose the best option


Revisit
Question # 10
@NamedQueries "select b from BookEntity b),
Choose from below VALID named queries annotation in JPA @NamedGAry(name="query1"query

@NamedQuery(name="query2"query = "select b.bookld from BookEntityb')

O @NamedQueries({
@NamedQuery(name="query1",query "select b from BookEntity b'),
@NamedQuery(name="query2",query=
"select b.bookld from BookEntity b")

O @NamedQueries(
@NamedQuery(name="query1".query
="select b from BookEntity b"),
@NamedQuery(name="query2",query= "select b.bookld from BookEntity b")

O@NamedQueries( "select b from BookEntity b°)


@NamedQuery(name="query1"query=

= "select b.bookld from BookEntity b")


@NamedQuery(name=query2".query

O@NamedQueries{ BookEntityb")
"select b from
@NamedQuery(name="query1".query=
from BookEntity b'")
@NamedQuery(name="query2",query= "select b.bookld
O T o t a l 00 28.18 Finush Test
JAVA McQ02 Assessment
metti
Section 1 of 1 Section #1 10 11 12 11 of 20 Al 29

Question *11 GRevisit Choose the best option

Jack wants to delete a customer(customerld 1001) from a customer table , since O removed
customer is not
O detached
active for longer time. He is using the below code to delete the customer record.Consider
persistance unit is "unit1". O managed

@Entity O newN
class CustomerEntity
@Id
int customerld
String customerName;
IGenerate getters and setters

class CustomerDaof
public void deleteCustomer(X
try(
int id=1001:
EntityManagerFactory entityManagerFactory =

Persistence.createEntityManagerFactory('unit1")
EntityManager entityManager =
entityManagerFactory.createEntityManager()
entityManager.getTransaction().begin(;
employeeEntity = entityManager.find(EmployeeEntity.class.id)
ifid ==employeeEntity.getEmployeeld()) {
Total 00 28. 15 Firush T9st
JAVA MCQ02 Assessment
metti All
12 13 11 of 20
7 10 11
Section 1 of 1 Section#1

Choose the best option


IGenerate getters and setters

O removed
class CustomerDaof
public void deleteCustomer( O detached
try O managed
int id=1001:
EntityManagerFactory entityManagerFactory =F O new
Persistence.createEnttyManagerFactory('unit1"):
EntyManager entityManager=entityManagerFactory.createEntityManager(0
entityManager.getTransaction().begin():
employeeEntity = entityManager.find(EmployeeEntity.class,id);

ifgid==employeeEntity.getEmployeeld())
entityManager.remove(employeeEntity)
entityManager.getTransaction().commit();/Mline - 1

else{
System.out.printin("employee id doesn't exist!")

catch(Exceptionexception
exception.printStack Trace():

Observe the above code and find out entity object goes to which state after line - 1
JAVA MCa02 Assessment Total 00-28.07 Finish Test

metti
Section 1 of 1 Secton #1 10 11 12 13 14 12of 20 All 20

Question # 12 Revisit Choose the best option

Consider Becky wants to perform update on price and author name by book id on book O Query query =
entityManager.createQuery("'update BookEntity k set k.price=?1 and
table k.author=72 where k.book_id = 13);

ReferBookEntity class below query.setParameter(1, 200.0);


@Entity query.setParameter(2, "Shakespeare");
@Table(name="book") query.setParameter(3,1):
public class BookEntity
@Id OQuery query entityManager.createQuery("update BookEntity k set k.price=?11
= and

@Column(name="bookid") k.author ?21 where k.book_id ?25"): =

query.setParameter(11, 200.0):
private Integer bookld;
query.setParameter(21, "Shakespeare");
@Column(name="book_name")
query.setParameter(25,1);
private String bookName;
private String author,
private Double price;
OQuery query entityManager.createQuery(update BookEntity k set k.price=?11 and
=

k.author=?21 where k.bookld = id");

@Column(name="publish_year") query.setParameter(11, 200.0);


private Integer publishYear query.setParameter(21, "Shakespeare");
lgetters and setters query.setParameter("id".1);
Query query= entityManager.createQuery(update BookEntity k set k.price=?11 and
k.author=?21 where k.book_id :id"); =

Refer table Book data below: query.setParameter(11, 200.0);


query.setParameter(21, "Shakespeare");
ID Book Name Author Price Publish Year query.setParameter("id", 1);
OTotal 00.28.03 Finish Teost
JAVA McQ02 Assessment
metti
12 of 20 All 20
10 11 12 13 14
Section 1 of 1 Section #1
Kerer LaDIe D0OK d a a beiow
Choose the best option

ID Book Name Author Price Publish Year k set k.price=?1 and


= entityManager.createQuery("update BookEntity
O Query query
k.author=?2 where k.book_id = ?3");
Alchemist Paulo Coelho 250$ 1988
query.setParameter(1, 200.0)
2 Davinci code Dan Brown 250S 2003 query.setParameter(2, "Shakespeare"):
3 Hary Potter J.K.Roling 250$ 1998
query.setParameter(3,1):
4 Black Beauty Anna Sewell 250S 1877
and
= entityManager.createQuery("update BookEntity k set k.price=?11
2006
5 The Secret Rhonda Byrne 2505 O Query query
Life of PI Yann Martel 2508 2001 k.author=?21 where k.book_id ?25");
6
query.setParameter(11, 200.0)
query.setParameter(21, "Shakespeare");
Consider the code structure below:
query.setParameter(25,1);
k.price=?11 and
class BookUpdateExample{ = entityManager.createQuery("update BookEntity k set

public static void main(String[] args


O Query query
k.author=?21 where k.bookld = :id");

Integer res =null; query.setParameter(11, 200.0);


query.setParameter(21, "Shakespeare");
try EntityManagerFactory entityManagerFactory =
query.setParameter("id",1);

Persistence.createEntityManagerFactory("pu");
= entityManager.createQuery("update BookEntity k set k.price=?11 and
entityManager = entityManagerFactory.createEntityManager():
O Query query
k.author-?21 where k.book_id = zid");

query.setParameter(11, 200.0);
""/
Line-1: Code goes here query.setParameter(21, "Shakespeare");
query.setParameter("id",1);
entityManager.get Transaction().begin();
res = query.executeUpdate()
JAVA McQ02 Assessment O Total 00 27:57 Finish Tesl
metti
Section 1 of 1 Section #1 7 10 11 12 13 19 13 of 20 Al 20

Question # 13 Revisit Choose the best option

What type of testing is done using Junit? O Functional testing

OIntegration testing
O System testing
O Unit testing
OTotal 00:27:52 Finish Test
JAVA MCa02 Assessment
metti
12 13 15 14 of 20> All
1 49
Section 1 of 1 Section #1 6 T 9 10 11

Question # 14 Revisitl Choose the best option

Anil is explaining JUnit 5 assumptions to his team. Which one of the below statements is false OFailed assumptions result in a test failure.
with respect to assumptions and assertions?
O A failed assertion results in a test failure.

O Assumptions is a collection of utlity methods that support conditional test execution based
on assumptions.

Method assumingThat() executes the supplied Executable test, only if the supplied
assumption is valid.
JAVA Mca02 AssossmentD Total 0027 43 Finsh e s l

metti
3 16 of 20 All
Section 1
of 1 Section #1i 10 12 14
1

Question # 15 Revisit Choose the best option

Consider the following test case: O Assertion results in a test failure because of -
AssertionFailedError. execution exceeded
timeout of 1000 ms by 100 ms
import java.time. Duration;
import org.junit.jupiter.api.Assertions; O Assertion results in a test failure because of -

AssertionFailedError. expected.
java.lang.Integer but was: java.lang.String
import org.junit.jupiter.api. Test;
O Assertion results in successtul test,execution and displayes green bar.
class McqTests
OThe testcase results in compiler error(s).

Test
public void testAssertions()

Assertions.assert Timeout(Duration.ofSeconds(1), ()->

Thread.sleep(100):

Assertions.assertEquals(10, "10");
JAVA McQ02 Assessment Total 00:27:42 Finish Tesl
mett
Section 1 of 1 Section #1 11 13 17 1 16 of 2 AU 49

Question # 16
Revisit Choose the best option

Thomas is designing home page for a news website. Home page design consist of many O<style type="textcss" href="containerstyle.css"></style
container like <div> tag to display the new article details. Thomas needs to follow certain css
Osstyle type="text/ess" sre="containerstyle.css">s/style
design which are standard throughout the website design. This standard css design are
available as extemal css file called containerstyle.css. Please choose the most approapriate O<link rel="stylesheet"t pe="text/css" href="containerstyle.css"/>
option to help Thomas to use the standard css in his home page design.
Oslink rel="stylesheet" type="text/css" src="containerstyle.css'>
JAVA McQ02 Assossment Total 00 27 38 Finish Tet
metti
Section 1 of 1 Section #1 12 13 14 15 16 17 of 2 All

Question # 17 Revisit Choose the best option

Ena and her team is working on Ul design of a Job Portal. Currently they are designing a OPost
candidate registration form. Ena and her team needs help to identify the Http method that
would allow submit the registretion fom details as part of request body to identified resource.
OTrace
On successful submission of request it would create a registration id. Please choose the most O Update
appropriate http request method.
O Get
JAVA MCQ02 Assessment Total 00:27.29 Firush Test
metti
18 of 20 Al
Section 1 of 1 Section #1 11 12 1 3 14 15 16 17 18 20

Question t# 18 Revisit Choose the best option

Dhananjay has been entrusted with the task of creating a webpage. O <IDOCTYPE html>
The webpage will have a text box and a button. chtml
The user can enter the number using the text box.
<body
On click of the button, request a calculation function to display multiplication table on the sh2>Number table</h2
webpage as shown in the image. script>
Using javascript, calculate multiplication table of the number entered in the text box. function calculate(H
Select the valid code topion which can fulil this requirement. Jar n parselnt(document.getElementByld('n1).value);

var text = ";

vari
for(i = 1;i <= 10; i++)

text+""+(n"i) +"<br";
document.getElementByld("demo").innerHTML = text;

s/script>
Enter Number: sinput type="texe" name="number" id="n1>
sbr/>
sbutton onclick="calculate(0">Calculate</button>
sp id="demo"> </p>
s/body
/html>
OTotal 00:27 22 Finish Tost
JAVA MCa02 Assessment
mettt& All
13 15 17 1 19 19 of 220
Section 1 of 1 Section #1

Choose the best option


Question # 19 CRevisit
Consider css and html code in mystyle.css and index.html files as below: O link rel="stylesheet" type="texucss" href="mystyle.css">
mystyle.css O <style src="mystyle.css">
.center
O <styleshee>mystyle.css</stylesheet
color red;
background-color: yellow: O <script src="mystyle.css"></script

O None of the above


index.html:
<html>
shead
-Line3
/head

sbody
<h1 class="center">Java</h1>
p class="center">Java isa popular programming language, creeted in 1995</p>
s/body
/html>

Which one of below lines, if placed at Line 3 in index.html, will use css styles from mystyle.css
inside index.html.
JAVA MCQ02 Assessmont OTotal 00 27 14 Finish Test

metti
20 20 of 20 19
7 A
Section 1 of 1 Section #1 12 13

Question # 20 Revisit Choose the best option

Consider the below html: function voterAge()


<h1>Voter Age Validation/h1>
var age=parseint(document.getElementByld("age"):
sform action="success">
Enter your age:sinput type="text" id="age"> if(age>18)
<input type="button" value="Validate" onclick="voterAge()">
<form> alert("Valid Age"):
Choose the most appropriate javascript function implementation for voterAge() that display
an elsef
alert message with message "Valid Age" if value entered is 18 and above and message
alert("Invalid Age");
"Invalid Age" if not entered in the range.

function voterAge()
var age=parseNum(document.getElementByld"'age")).

if(age=18)

alert("Valid Age");
else
alert("Invalid Age");

O function voterAge)
Pre-request every one again to join in every following groups to
get further updates and if you leave groups after your TFA and
stream tests you will miss your further updates for sure so just
stay connected.

Dm - https://t.me/angelnndevil

Main group link - https://t.me/ad2group

Get more dumps here

Materials/Channel/dumps -
https://t.me/adaccenturematerial
Which of the following are JPA providers ? [choose 2] EclipseLink & Hibernate
1st option
public integer addcustomer() throw exception {
integer customerid =0;
Entitymanager entityManager =null;
try{

Eesha wants to add a new customer record in a customer table. }


Consider the CustomerEntity with the below structure.
class CustomerEntity{ catch(Exception exception ){
int customerid;
String customerName; throw exception;
String customerLocation;
String customerType; } finally{
//Generate getters and setters if(entityManager is null){
entityManager.dozen();

} }
Help her to select the appropriate code from the below options to achieve this task.
CSS is used for describing the presentation of web pages ,including colors layout and fonts
which of these statements are correct with respect to CSS ? css enables presentation and content teams can work simultaneously on independent componenets
<!DOCTYPE html>
<html>
<body>
<h2>Number table</h2>
<script>
function calculate() {
var n=parseInt(document.getElementById("n1").value);
var text="";
var i;
for(i=1; i<=10;i++) {
Dhananjay has been entrusted with the task of creating a webpages. text+=" " +(n*i)+ "<br>";
The webpage will have s text box and a button. }
The user can enter the number using the text box. document.getElementById("demo").innerHTML=text;
On click of the button, request a calculation function to display multiplication table on the webpage as shown in the image. }
Using javascript, calculate mutiplication table of the number entered in the text box. </script>
Select the valid code option which can fulfill this requirement. Enter Number: <input type="text" name="number" id="n1"/>
<br/>
<button onclick="calculate()"> Calculate</button>
<p id="demo"></p>
</body>
</html>

Consider the following JPA code. Where "MoviesData" is persistence unit name in
persistence.xml file.
EntityManagerFactory emfactory=Persistence.createEntityManagerFactory("MovieData");
EntityManager entitymanager = emfactory.createEntityManager();
Query query=entityManager.createQuery("select m.movieName, m.genre,m.language from
A)
MovieEntity m");
List<Object> list=query.getResultList();
// fill the code here
System.out.println("Moviename \t MovieGenre \t MovieLanguage");
for(Object entity : list) {
MovieEntity has the fields String movieName, String genre and String language.
Object[] obj=(Object[]) entity;
Note that Movie table has three rows. Identify only one correct statement from the following
System.out.println((String)obj[0]+"\t"+(String)obj[1]+"\t"+(String)obj[2]);
options to print the movie details as shown.
}
MovieName Movie Genre MovieLanguage
Dunkirk History Spanish
Interstellar Science-fiction French
MI 7 Action and Adventure English
Refer the following JPA code unit1 is the persistance unit name in persistance.xml.
public class MovieDAOImpl{
public void addMovie(MovieBean movie) throws Exception {
EntityManager entityManager = null;
try{
EntityManagerFactory enitityManagerFactory =
Persistance.createEntityManagerFactory("unit1");
enitityManager = enitityManagerFactory.createEntityManager();
MovieEntity movieEntity= new MovieEntity();
MovieEntity.setMovieId(movieEntity.getMovieId());
MovieEntity.setMovieName(movieEntity.getMovieName());
MovieEntity.setMovieGenre(movieEntity.getMovieGenre());
entityManager.getTransaction().begin();
entityManager.merge(movieEnity);
entityManager.getTransaction().commit();
} catch (Exception exception) {
throw exception;
}
finally {
if(entityManager != null) {
entityManager.close();
}.
. i and ii only
.
.
.
MovieDAOImpl impl=new MovieDAOimpl();
imple.addMovie(bean);

MovieBean bean=new MovieBean();


bean.setMovieId(1003);
bean.setMovieName("Toy Story 3");
bean.setMovieGenre("Fantasy");
impl.addMovie(bean);
}
}

MovieBean has fields int movieId. String movieName and String movieGenre. MovieEntity
has fields int movieid. String movieName and String movieGenre. Assume that in MovieTable
no record exists with movieId 1004. A record exists with movie id 1003. Upon
executing the program which of the following statements are true. Choose Two.

i) New record with movie id 1004 is inserted.


ii)record with movie id 1003 is updated.
iii)... not exists exception is thrown while invoking addMovie() method with movie
Mr. John has written a code to update movie details. He has a compile-time-error " The
method setString(int, String) in the type PreparedStatement is not applicable for the
arguments (int, int)" against marked line in the following code. MovieBean class is used
and its fields are int movieId, String movieName , String genre and String language. Note
that MySql database is locally installed. Default port number is used. Schema is jdbcdemos
Movie Bean class has fields int movieId, String movieName, String genre adnn String
language. Help him to fix the error by choosing one of the following options:

public void updateMovie(MovieBean bean) throws SQLException,


ClassNotFoundExeption {
Connection connection=null;
String url="jdbc:mysql://localhost:3306/jdbcdemos";
String username="root";
String password="root";
try {
connection= DriverManager.getConnection(url,username,password);
String updatedata="update movie set gente=? where movie= ?";
PreparedStatement pstatement=
connection.prepareStatement(updatedata);
pstatement.setString(1,bean.getGenre());
pstatement.setString(2,bean.getMovieId()); // Compeil-time error here
boolean rowsUpdateCount=pstatement.execute();
if( rowsUpdatecount != true ) {
System.out.println("Employee update successfull !!");
} else {
System.out.println("OOps some thing went wrong!! we are on
process.. ");
}
} catch (Exception e) {
throw e;
} finally {
connection.close();
}

A) @BeforeAll
static void beforeAll()
Which Annotations and method signatures are correct in Junit ? [Choose 2]
B) @BeforeEach
void beforeEach()

Consider the following program and choose a right option:

import static org.junit.Assert.assertNotNull;


import static org.junit.jupiter.api.Assertions.assetTrue;
impport org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
C) The default delimeter is a comma (,) but you can use another....(Not understandable)....attribute
class McqTests {

@ParameterizedTest
@CsvSource(value={"TechVersant@1","TechVersant@2"} , delimeter='@')
void simpleCsv( final String s1 , final int n1) {
assertNotNull(s1);
assertTrue(n1>0);
}
}
public static Connection getDBConnection() throws ClassNotFoundException,
SQLException {
String url="jdbc:mysql://localhost:3306/jdbcdemos";
String username="root";
John is creating a java application for CRM. He wants his application to be connected with
String password="root";
the mysql database to maintain the customer records. Help him to establish connection with
Connection connection=null;
the database.
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(url,username,password);
return connection;
}
Refer the following code Mrs Janet has been asked to code JDBC program to insert
movie details in the movie table columns 'movieid' , 'moviename' , 'genre' and
'language'. Help her to complete the following code by identifying the right set of
statements to be added. Choose one. Note that Mysql database is locally installed . Default
port numner is used. Schema is 'jdbcdemos'. 'Movie' Bean class has fields int 'movieId',
String 'movieName', String 'genre' and String 'language'.

public int insertMovie( MovieBean bean) throws ClassNotFoundExeception , SQLException,


Exception {
String url="jdbc:mysql://localhost:3306/jdbcdemos";
String username="root";
String password="root";
Connection connection=null;
` try {
A) pstatement.setString(1,bean.getMovieName());
int rowsInsertCount=0;
pstatement.setString(2,bean.getGenre());
String insertdata="insert into movie(moviename,genre,language)
pstatement.setString(3,bean.getLanguage());
values(?,?,?)";
rowsInsertCount=pstatement.executeUpdate();
connection=DriverManager.getConnection(url,username,password);
PreparedStatement pstatement=connection.prepareStatement(insertdata);
// add statements here
if (rowsInsertCount > 0) {
System.out.println("No of rows inserted: " + rowsInsertCount);
} else {
System.out.println("OOps something went wrong !!");
}
return rowsInsertCount;
} catch(Exception e) {
throw e;
} finally {
connection.close();
}
From which version of JDBC , driver name registration is not required? JDBC 4.0
Which method is used to check whether the designated column can be used in SQL where clause? C) isSearchable()
Rose is writing a script where she has a requriment to increment a value received from
textbox with a id "num"
Value entered in the text box is 100
var result=document.getElementById("num"); //line 1 var result=document.getElement.ById("num");
result=result+1; //line2 result=parseInt(result)+1;
console.log(result); //line3 console.log(result);
When Rose runs the above script the output of line 3 is 1001.
Help Rose resolve the problem by replacing the 3 lines of code marked line1, line2
line3 the most appropriate code.
Question is not visible It leads to failure i.e. referential intergrity constraint violation and exception hence no record is deleted.
class BookUpdateExample {
public static void main(String[] args) {
Integer res=null;
try{
EntityManagerFactory entityManagerFactory=Persistence.create EntityManagerFactory ("pu");
entityManager=entityManagerFactory.createEntityManager();

/** Line-1: Code goes here **/

entityManager.getTransaction().begin();
res=query.excuteUpdate();
entityManager.getTransaction().commit();
}
catch(Exception exception) {
throw exception;
}
finally {
if(entityManager!=null) {
entityManager.close();
}
}
}
}
<!DOCTYPE html>
<html>
<body>
<h2>Number table</h2>
<script>
function calculate() {
var n=parseInt(document.getElementById("n1").value);
var text="";
var i;
for(i=1; i<=10;i++) {
Dhananjay has been entrusted with the task of creating a webpages. text+=" " +(n*i)+ "<br>";
The webpage will have s text box and a button. }
The user can enter the number using the text box. document.getElementById("demo").innerHTML=text;
On click of the button, request a calculation function to display multiplication table on the webpage as shown in the image. }
Using javascript, calculate mutiplication table of the number entered in the text box. </script>
Select the valid code option which can fulfill this requirement. Enter Number: <input type="text" name="number" id="n1"/>
<br/>
<button onclick="calculate()"> Calculate</button>
<p id="demo"></p>
</body>
</html>

Which of the following methods in JPA when involed, entity changes to managed state.
Choose TWO
i) Find
i and ii only
ii) Persist
iii) Remove
iv) Merge
Consider the below html:
<h1>Voter Age Validation</h1>
<form action="success"> function voter Age()
Enter your age:<input type="text' id="age"> {
<input type="button" value="Validate" onclick="voterAge()"> var age=parseInt(document.getElementById("age").value);
</form> if(age>=18)
Choose the most appropriate javascript function implementation for voterAge() {
that display an alert message with message "Valid Age" If value entered is 18 and alert("Valid Age");
above and message "Invalid Age" if not entered in the range. }
else {
alert("Invalid Age");
}
}
alechmist @NamedQueries({
harry potter @NamedQuery(name="latest_book",query="select b.bookName from BookEntity b where b.public year IN(select MAX(b.
black beauty publishyear)from BookEntity b)"),
the secret @NamedQueries({
life of Pi @NamedQuery(name="oldest_book",query="select b.bookName from BookEntity b where b.public year IN(select MIN(b.
Davinvi code publishyear)from BookEntity b)"),
@entity
@table(name="book")
public class Bookentity{
@Id
@column(name="bookId")
private integer bookId;
@column(name="book_name")
private string bookName;
private Stringauthor
@entity
@table(name="customer")
public class customerentity{
@Id
private Integer customerId;
private String customerName;
@ManyToOne(cascade="CascadeType.PERSIST)
@JoinColumn(name="locationId_fk") It leads to failure i.e. referntial integrity constraint voilation and exception hence no record is deleted
private locationEntity location;
@Entity
@Table(name="loaction")
pubic class LocationEntity{
@Id
private int locatuonId;
private String city;

Sheila wants to check if a condition in her code is working correctly . Which Junit assert method is appropriate for her? void assertTrue(boolean condition)
which one of the below tag creates boundaries of document header? <head>
void assertTrue(condition)
class.forName("drivercClassName")
It is dependent on database
Which of the following statement is/are valid to register driver class in JDBC?

1) DriverManager.getConnection("driverClassName");
2) DriverManager.registerDriver("driverClassName");
3) DriverClassName obj=new DriverClassName();
2&4
4) Class.forName("driverClassName");

isSearchable()
which of the below is valid XML tag <boby></body>
consider the below XSl file calle Library Transform.xsl with code
<xsl;stylsheet version ="1.0"xmlns = "https://...
<xsl:template match="/">

<html>

<body>

<h1>Library</h1>
<books>
<table border="1">
<book>
<tr>
<isbn>678999</isbn><title>Learning XMI</title
<td>ISBN</td>
</book>
<td>TITLE</td>
<book>
<tr>
<xsl:for-each select="books/book">
<isbn>008999</isbn><title>Learning HTML</title>
<tr>
</book>
</books>
<td><xsl:value-of select-"isbn"/></td>
<td><xsl:value-of select="title"/></td>
</tr>
</xsl:for-each>

</xsl:template>
</xsl:stylesheet>

Which of the below would generate a well formed xml with above x
<book>
<isbn>678999</isbn><title>Learning XMI</title
</book>
Consider the following test case: Consider the following test case:
import java.time.Duration; import java.time.Duration;
import org.junit.jupiter.api.Assertion; import org.junit.jupiter.api.Assertion;
import org.junit.jupiter.ap.Test; import org.junit.jupiter.ap.Test;
class MCQTest{ class MCQTest{
@Test @Test
public void testAssertions(){ public void testAssertions(){
Assertions.assertTimeout(Duration.ofSeconds(1),(){ Assertions.assertTimeout(Duration.ofSeconds(1),(){
Thread.sleep(100); Thread.sleep(100);
}}; }};
Assertions.assertEquals(10,"10"); Assertions.assertEquals(10,"10");
} }
<isbn>008999</isbn><title>Learning HTML</title>
</book>
<html>
<body>
<h2> form </h2>
<form>
Name:<br>
option to create html form, that allow users to enter name,email and gender. must allow to select only one of a given choice
<input type="text" id="fname" name="fname"><br>
male,female and other.
email:<br>
<input type = "text" id="email"name="email></br>
<input type = "radio" id="male"name="gender>value="male">
male<br>
<input type = "radio" id="female"name="gender>value="female">
female<br>
<input type = "radio" id="other"name="gender>value="other">
other</br>
</form></body></html>

box1{
bob has a requirement to style a div element in his webpage to have background color to be red and font style to be italic. background-color red;
below is the div element,help bobselect the most appropriate way to apply styling via CSS. font-style italic;
<div class="box"></div> }
<!doctype html>
<html>
<body>
<h2>number table></h2>
<script>
Dhananjay has been entrusted with the task of creating a webpages. function calculate(){
The webpage will have s text box and a button. var n = parseInt(document.getElementById("n1").value);
The user can enter the number using the text box. var text="";
On click of the button, request a calculation function to display multiplication table on the webpage as shown in the image. var i;
Using javascript, calculate mutiplication table of the number entered in the text box. for(i=1;i<=10;i++){text+=" "+(n*i)+"<br>";}
Select the valid code option which can fulfill this requirement. document.getElementbyid("demo").innerHTML=text;}
</script>
enter number<input type= "text" name=""number"id="n1"/><br/>
<button onclick="calculate()">calculate</button>
<p id="demo"></p></body></html>

In order to establish connection with MYSQL database in JDBC which one of the following connection urls is correct?
note that port number is 3306,schema is test and mysql is locally instead jdbc:mysql://localhost:3306/test
already written in sheet
@test
@disabled
please select the correct ennotation @tag
get
there are a number of http methods.select valid http methods from given list[choose 2] put
Jacqueline wants to create a customer report by fetching customerId, customername and customerlocation from
customer table. Consider CustomerEntity class with the following structure.

@Entity
class CustomerEntity{
@Id
private int customerId;
private String customerName;
private String customerContact;
private String customerLocation;
//Code with getters and setters
}

Help her to select the appropriate code from the given options.
Which of the below statements are correct with respect to HTTP and HTTPS:
1. HTTPS stands for Hyper Text Transfer Protocol Server
2. HTTPS is Combination of HTTP and Secure Socket Layer (SSL) 2nd and 3rd statements are correct
3. The https:// web pages indication along with a lock icon in the browser window pane indicate the presence of a
secure web page.
Ani is working with a house construction application. She created two entity classes House and Window
that helps to design the application. What's true about the following @Entity association
between House and Window?
@Entity
public class Window{
@ld
private int winNo;
private House aHouse;
}
It's One To Many bidirectional association
@Entity
public class House {
@ld
private int houseNo;
@OneToMany(cascade Cascade Type ALL)
private List<Window> windows;
}
Choose the best option

Punith, a developer wants to synchronize the changes done on the CustomerEntity object on the customer table.
He is using the below code to update the changes

public class CustomerDao{


public Integer addCustomer() throws Exception {
Integer customerID = 0;
EntityManager entityManager = null;
try {
EntityManagerFactory entityManagerFactory = Persistence createEntityManagerFactory();
entityManager entityManagerFactory.createEntityManager();
CustomerEntity customerEntity1 = new CustomerEntity();
customerEntity1.setCustomerid(1001);
customerEntity1.setCustomerName("John");
customerEntity1.setLocation("Pune");
customerEntity1 setType("Gold");
entityManager.getTransaction().begin(); 101 John Pune Gold
entityManager.merge(customerEntity1);
customerEntity1.setLocation("Delhi");
entityManager.getTransaction().commit();
customerID = customerEntity1.getCustomerId();
} catch (Exeption exception) {
throw exception;
} finally (
if (entityManager = null) {
entityManager.close();
}
}
return customerID;
}

Which of the following customer data will be stored/updated in the customer table after executing the above code.
Mr. Gaetano gets following error upon executing the code to retrieve details from the table "movie" with columns
movied, moviename, genre and language. From the following options which one he has to add in line1 in order to fix it.
Note that Mysql database is locally installed. Default port number is used. Schema is jdbcdemos < add movie bean structure>.
Movie Bean class has fieds int movield, Sting movieName, String genre and String language.
Refer the following code

public void readMovie() throws ClassNotFoundException, SQLException {


Connection connection = null;
String url ="jdbc:mysql://localhost:3306/jdbcdemos";
String usemame = "root";
String password = "root";
try {
String retrievedata = "select * from movie where movieId = ?";
connection = DriverManager.getConnecton(url, username, password);
PreparedStatement pstatement = connection.prepareStatement(retrievedata); //Line 1
ResultSet resultSet = pstatement.executeQuery();
pstatement.setint(1, Id)
while(resultSet.nest()) {
System.out.println("Movie ID: " + resultSet.getint("movieId") +
"\nMovie name: " + resultSet.getString("movieName") +
"\nGenre: " + resultSet.getString("genre") +
"\nLanguage: " + resultSet.getString("language"));
System.out.println("==============================================");
} catch (Exception e) {
throw e;
} finally {
connection close();
}
}

Error:

*Remaining is not there*


Choose from the following CORRECT statement about parsing, compiling and executing SQL queries in JDBC. Statement is used for encapsulating an SQL statement to parse, compile and execute it to database
public static Connection getDBConnection() throws ClassNotFoundException,
SQLException
{
String url="jdbc:mysql://localhost:3306/dbcon";
john is creating a java application for CRM. He wants his application to be String username="root";
connected with the mysql database to maintain the customer records. Help him to String password="root";
connection with the database. Connection connection=null;
Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection(username,password);
return connection;
}

Harry wants to creates a customer report for CRM application. He wants to


iterate the recordsfrom employee table. He is using ResultSet for the first time.
When there are no more rows to iterate the retrieved result then read() returns nothing.
Help him to identify one wrong statement about ResultSet from the given option.

Eesha wants to add a new customer record in a customer table.


Consider the CustomerEntity with the below structure.
class CustomerEntity{
int customerid;
String customerName;
String customerLocation;
public integer addcustomer throw exception { integer customerid =0; entitymanager entitymanager =null;
String customerType;
//Generate getters and setters

}
Help her to select the appropriate code from the below options to achieve this task.
Which annotation and method signatures are correct in Junit?
1.Junit 5 supports Java 5 or higher
Which of these statements are incorrect with respect to Junit 5?
2.Junit Jupiter provides support for running Junit 3 and Junit 4 based test on the platform.
3.Annotation @BeforeAll is analogous to Junit 4's @beforeEach

consider BookMyTicket application.It allows users to book movie tickets. JPA is used for persistance
operations. It has two entities MovieEntity with fields int 'movieId', String 'movieame', String 'genere'
and String 'language'. ScreenEntity with field int 'movieId',int 'screenId', String 'screenName', Date
select movie,screen from movieEntity movie,ScrrenEntity screen where Movie.movieid = screen.movieid
'showTime.They share one to one association.You are required to write JPQL to fetch movie name,
genre, language, screen name and show them to give movie id. Which one of the following JPQL
queries is correct?
Consider the following JPA code. Where "Movie Data" is persistence unit name in
persistance.xml file.
EntyManagerFactory emfactory = Persistence.createEntityManagerFactory('MovieData"):
EntityManager entitymanager = emfactory.createEntityManager();
Query query=entityManager.createQuery("select m.movieName, m.genre,m.language from
MovieEntity m"):
List Object list=query.getResultList (); System.out.printin "Moviename It MovieGenre It MovieLanguage
MovieEntity has the fields String movieName, String genre and String language. for (Object entity : list) {
Note that Movie table has three rows. Identify only one correct statment from the following Object) obj=(Object0) entity
options to print the movie details as shown. System.out.prtin((String)objf0]+"r+(String)objf1]+""+(String)obj[2]): }

MovieName MovieGenre MovieLanguage


Dunkirk History Spanish
Interstellar Science-fiction French
MI 7 Action and Adventure. English

Consider the following entity classes and sample records


@Entity
@Table(name = "customer")
public class CustomerEntity{
@Id
private Integer customerId;
private String customerName;
@ManyToOne(cascade = CascadeType.PERSIST)
@JoinColumn(name="locationId_fx")
private LocationEntity location;

// Code and setters/getters goes here


} Answer:
@Entity
@Table(name = "location") customer record with customerid 1001 will be deleted from customer table
public class LocationEntity{
@Id
private int locationId;
private String city;
// Code and setters/getters goes here
}

customer
customer Id customerName locationId_fk
1001 Jack 1
1002 Jim 1
1003 Jai 2

location
locationId city
1 Chennai
2 Pune
3 Banglore
BookEntity.java
------
@Entity
@Table(name = "book")
public class BookEntity{
@Id
@Column(name="book_id")
private Integer bookId;
@Column(name="book_name")
private String bookName;

// Code and setters/getters goes here


}

persistence.xml
-----
<persistence version="2.1"
xmlns="http://xmins.jcp.org/xml/ns/persistence"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name='JPA Merge">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.entity.BookEntity</class>
<properties>
1)Runtime exceptio in line-1
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
2)101
<property name="javax.persistence.jdbc.url" value='jdbc mysql:localhost:8306jpa_de" />
3)complilation error in ine-2
<property name='javax.persistence.jdbc.user" value="root"/>
4)Runtime exception in line-3
<property name="javax.persistence.jdbc.password" value="root">
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>

</properties>
Answer: Runtime exception in line-3
</persistence-unit>
<persistence>

BookMain.java
--------
public class BookMain { @EmbeddedId
public static void main(String[] args){ @Embeddable
EntityManagerFactory emf=Persistence Merge"); @NamedQuery
@Qualifier
choose from below INVALID annotation in JPA
Entity Manager em-ent.creaturing
BookEntity book1=new BookEntity(); Answer: @Qualifier
book1.setBookld(101);
book1.setBookNome("Alchemist");
BookEntity book2 em mage book
Book Entity book3 = new Book
book3.setBookName/Secret?
book3.setBookbook
Book Entity boord en meget
em clearl
System.out.println(book4.getbook());
}
}
Predict the output
Mr. Gaetano gets following error upon executing the totale
table'movie' with columns movieid, moename gener
options which one he has to add in lines in order to fant. Noe te pa
locally installed. Default port number is used. Schema is hosteren
structure> Movie Bean class has fields int movield, Sting modelare
String language
Refer the following code.

public void readMovie() throws ClassNotFoundException, Sector


Connection connection = null; A) pstatement.setint(1,id);
String url = "dbo.mysql/localhost3306jcbcdenas" B) pstatement.setString(1,'1');
String username = "root" C) pstatement.setMovieId(1,id);
String password ="root" D) pstatement.setint(0,id);
try!
String retrievedata = 'select from movie Answer:A) pstatement.setint(1,id);
connection=DriverManager getcomestnut
PreparedStatement pstatement
connection.prepare Statement/retrievedsta:
Mine
ResultSet resultSet =pstatementet
while (resultSet net
System.out.print
"In Movie name:

Ben wants to delete the customer record


1001 john
1002 jack
1003 krish
int id=1001;
String customerdata="DELETE" from customer WHERE customer="+
Employee deleted successfully:1
id+";
DriveManager getConnection(")dbc.mysql://localhost:3306/jdbcdemos","root","root");
Statement statement =connection.createStatement();
int deleteRowsUpdateCount=statement.executeUpdate(deletedata);
if(deleteRowsUpdateCount>0){
System.out.println("Employee deleted Successfully:"+ deleteRowsUpdateCount);
Which property of ResetSet type will be automatically assigned if you do not specify ResultSet TYPE_FORWARD_ONLY
Harry wants to create customer report CRM application. he wants to iterate records from employee table
he is using ResultSet for first time. help him to identity one wrong statement abt ResultSet when there are no more rows to iterate retrieved result next() method result returns nothing
which method is used to check whether designated column can be used in SQL where clause? isSearchable()
function voterAge()
{
var age=parseNum(document.getElementByid("age");
consider below html if(age=>18)
<h1>Voter Age Validation</h1> {
<from action="success"> alert("valid age");
Enter your age:<input type="text"id="age"> else
<input type="button value="validate" onclick="voteAge()"> alert("invalid age");
<from> }
choose right javascript implementation }
which below is/are valid javascript funcations

1-
funcation sum(){
document froms.calc.result.value=
parseInt(document.forms.calc.number2.value)+
parseInt(document.forms.calc.number1.value);
}

2- c)1st
public int getSum(int a int b){
reurn a+b;
}

3-
function int getSum(int a, int b){
return a+b;
}
which of below statements are correct w.r.t http and https

1-
HTTPS stands hyper text transfer protocol server
2nd and 3rd are correct
2-
HTTPS is combination of HTTP and secure socket layer(SSL)
3-
the https:// web pages indication along withlock icon browser window indicate presence of secure web page
Ena and her team is working on UI design of job portal, currently they are designing cadidate registration form.
ena n her team need helps to identify http method that would allow submit registration form details as part of request body
POST
to identify resource. on successful submission of req it would create registration id
please choose appropreiate help request method
QUESTIONS ANSWERS
Choose the disadvantage on thin driver from below options It is dependent on the database
Suresh a marketing executive wants to create an customer report on monthly basis. He wants
to iterate the records from customer table more faster. Help him to select appropriate interface PreparedStatement
for this situation.
Choose from the following CORRECT statements about Class.forName() method call.
This method is used for dynamically loading the driver's class fle into memory and to register it
automatically. I and II only
I) Since JDBC 4.0 this is redundant since auto discovery was enabled.
II) It is used only for loading type 4 driver
Assume that book table is created in book db database and record is inserted as per
below schema

insert into book (book_name,price) values (Alchemist,250.0);


insert into book (book_name,price) values (Secret, 200.0);
insert into book (book_name,price) values ('GOT,750.0);
insert into book (book_name.price) values ('Hary Potter 450.0);
Refer the code below and predict the output
public class BookExample {
private static Connection connect = null; No record deleted
private static PreparedStatement preparedStatement1 = null:
private static PreparedStatement prepared Statement2 = null;
private static ResultSet resultSet = null;
public static void deleteBooks(double price1, double price2) {
int noOfRecordDeleted=0;
String query = "delete from book where price between ? and ?:
try{
connect DriverManager.getConnection("jdbc:mysql://localhost:3306
book_db","root","roof")
preparedStatement1=connect.prepareStatement(query);
preparedStatement1.setDouble(1, price1)
prepared Statement1.setDouble(2. price2)
noOfRecordDeleted= prepared Statement1.executeUpdate();

Incomplete Question
EclipseLink
Which of the following are JPA providers ? [choose 2] Hibernate
Which object represents the programmatic connection definition? It also reads
EntityManagerFactory
the connection information from persistence.xml by mapping with the PersistenceUnitName
List Object list=query.getResultList (); System.out.printin "Moviename It MovieGenreIt MovieLanguage
for (Object entity : list) {
Considerthe following JPAcode. Where “MovieData”is Persistence unit name in persistance.xml Object) obj=(Object0) entity
file. System.out.prtin((String)objf0]+"r+(String)objf1]+""+(String)obj[2]);
@NamedQueries{
@NamedGAry(name="query1"query "select b from BookEntity b),
Choose from below VALID named queries annotation in JPA
@NamedQuery(name="query2"query = "select b.bookld from BookEntityb')
})
What type of testing is done using Junit? Unit testing
Anil is explaining JUnit 5 assumptions to his team. Which one of the below statements is false
Failed assumptions result in a test failure
with respect to assumptions and assertions?
Consider the following test case:

import java.time. Duration;


import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api. Test;

class McqTests {
Assertion results in a test failure because of -
@Test AssertionFailed Error. expected.
public void testAssertions() { java.lang.Integer but was: java.lang.String

Assertions.assert Timeout(Duration.ofSeconds(1), ()-> {


Thread.sleep(100);
});
Assertions.assertEquals(10, "10");
}
}
Thomas is designing home page for a news website. Home page design consist of many
container like <div> tag to display the new article details. Thomas needs to follow certain css <link rel="stylesheet"t pe="text/css" href="containerstyle.css"/>
design which are standard throughout the website design. This standard css design are
available as extemal css file called containerstyle.css. Please choose the most approapriate
option to help Thomas to use the standard css in his home page design.

consider the following code.unit1 is the persistance unit name in persistance.xml


public integer addMovie(MovieBean movie) throws Exception{
//TODO Auto-generated method stub
integer movieID = 0;
EntityManager entityManager = null;
try{
EntityMnagerFactory entityManagerFactory = Persistance.getEntityManagerFactory("unit1");
entityManager = entityMnagerFactory.createEntityManager();
MovieEntity movieEntity1 = new MovieEntity(); entity2 is the reference od managed copy hence it will be successful update
MovieEntity.setMovieId(movieEntity.getMovieId());
MovieEntity.setMovieName(movieEntity.getMovieName());
MovieEntity.setMovieGenre(movieEntity.getMovieGenre());
entityManager.getTransection().begin();
movieEntity.movieEntity2 = entityManager.merge(movieEntity1);
movieEntity2.setMovieName("dummy");
entityMnager.getTransection().commit();
movieID = movieEntity2.getEmployeedId();}
catch(Exception exception){throw exception;}finally{
incomplete question

jack want to delete a customer(customerId = 1001)from a customer table,since customer is notactive for longer time he is
using the below code to delete the customer recoed .consider persistance unit is" unit1".
@Entity
class CustomerEntity{
@Id
int customerId;
String customerName;
//Generate getters and setters}
class CustomerDao(
public voud deleteCustomer(){ removed
try{int id = 1001;
EntityMnagerFactory entityManagerFactory = Persistance.createEntityManagerFactory("unit1");
EntityManager entityManager = entityMnagerFactory.createEntityManager();
entityManager.getTransection().begin();
employeeEntity = entityManager.find(EmployeeEntity.class,id);
if(id== employeeEntity.getEmployeeId()){
entityManager.remove(emploeeEntity);
entityManager.getTransection().commit();//line-1}
else{system.out.println("employee id doesn't exist!");}}
catch(Excepetion exception){exception.printstackTrace();}}
observe the aboue code and find out entity object goes to which state after line-1

ena and her team is working on UI design of a job portal. currently they are designing a candidate registration form.ena and post
her team needs a help to identify the Http method that would alow submit th registration form details as part of request body
to identified resourcses on successful submission of request it would create a registration id.please choose the most appropriate
http request method
Consider css and html code in mystyle.css and index.html file as below:
mystyle.css:
.center(
color:red;
background-color:yellow;}
index.html:
<htmml><head> <link rel = "stylesheet" type="text/css" href ="mystyle.css">
>!-line3->
</head><body>
<h1 class = "center">java</h1>
<p class = "center"> java is a popular programming language,created in 1995>/p>
</body></html>
which one of the below lines,if placed at line 3 in index.html,will use css style from mystyle.css inside index.html

Consider Becky wants to perform update on price and author name by book id on book table
Refer BookEntity class below:
@Entity @Table(name="book") public class BookEntity{
@Id @Column(name="book_id") private Integer bookld; @Column(name="book_name") private String bookName;
private String author,
private Double price; @Column(name="publishyear") private Integer publishYear:
//getters and setters
Refer table Book data below :
ID Book Name Author Price Publish Year
1 Alchemist paulcoelho 250$ 1988
2 Davinci code Dan Brown 250$ 2003
3 Harry potter J.K rowling 250$ 1998 Query query = entityManager.createOuery("update BookEntity k set k.prlce=?11 and k.author-?21 where k.book_id = :Id");
4 black beauty Anna sewell 250$ 1877 query.setParameter(11,200.0);
5 the secret rhonda byrne 250$ 2006 query.setParameter(21, "Shakespeare");
6 life of pi yann martel 250$ 2001 query .setParameter("id",1);
consider the code structure below:
class bookUpdateExample{p.s.v.main(String[] args){
integer res = null;
try{EntutyMangerFactory entityMnagerFactory = persistence.createEntityManagerFactory("pu");
entityMnager = entityMnagerFactory.createEntityManager();
/**line-1:code goes here**/
entityMnager.getTransection().begin();
res = query.excecuteupdate();
Eesha wants to add a new customer record in a customer table.
Consider the CustomerEntity with the below structure,
class CustomerEntity{
int customerid;
String customerName;
String customerLocation;
String customer Type;
//Generate getters and setters
}
Help her to select the appropriate code from the below options to acheive this task.
Choose from below VALID named queries annotation in JPA.
Mr.Gaetano gets following error upon executing the code to retrieve movie details from the
table 'movie' with columns movieid, moviename, genre and language. From the following
options which one he has to add in line1 in order to fix it. Note that Mysql database is
locally installed. Default port number is used. Schema is jdbcdemos <add movie bean
structure> Movie Bean class has fields int movield, String movieName, String genre and
String language.
Refer the following code.

public void readMovie() throws ClassNotFoundException, SQLException (


Connection connection = null;
String url="jdbc:mysql:/localhost.3306/jdbcdemos";
String username = "root";
String password="root";
try{
String retrievedata = "select from movie where movieid=?",
connection=DriverManager.getConnection(urf, username, password);
PreparedStatement pstatement =
connection.prepareStatement(retrievedata);
ResultSet resultSet =pstatement.executeQuery();
while (resultSet.next()) {
System.out.println("Movie ID:+ resultSet getint("movield")+
public static Connection getDBConnection() throws ClassNotFoundException SQLException {
String url = "jdbc:mysql://localhost:3306/jdbcdemos";
String username = "root";
John is creating a java application for CRM. He wants his applicationto be connected String password = "root";
with the MYSQL Database to maintain the customer records. Help him to establish connection Connection connection = null;
to the database. Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(url, username,passowrd);
return connection;
}
Harry wants to create a customer report for CRM application. He wants to iterate the records
from employee table. He is using ResultSet for the first time. Help him to identify one wrong statement When there are no more rows to iterate the retrieved result the next() method
about ResultSet from the given options. returns nothing.
Rose is writing a script where she has a requriment to increment a value received from
textbox with a id "num"
Value entered in the text box is 100
var result=document.getElementById("num"); //line 1 var result=document.getElement.ById("num");
result=result+1; //line2 result=parseInt(result)+1;
console.log(result); //line3 console.log(result);
When Rose runs the above script the output of line 3 is 1001.
Help Rose resolve the problem by replacing the 3 lines of code marked line1, line2
line3 the most appropriate code.
Consider the following JPA code. Where "MoviesData" is persistence unit name in
persistence.xml file.
EntityManagerFactory emfactory=Persistence.createEntityManagerFactory("MovieData");
EntityManager entitymanager = emfactory.createEntityManager();
Query query=entityManager.createQuery("select m.movieName, m.genre,m.language from
MovieEntity m"); List<Object> list=query.getResultList();
// fill the code here System.out.println("Moviename \t MovieGenre \t MovieLanguage");
for(Object entity : list) {
MovieEntity has the fields String movieName, String genre and String language. Object[] obj=(Object[]) entity;
Note that Movie table has three rows. Identify only one correct statement from the following System.out.println((String)obj[0]+"\t"+(String)obj[1]+"\t"+(String)obj[2]);
options to print the movie details as shown. }

MovieName Movie Genre MovieLanguage


Dunkirk History Spanish
Interstellar Science-fiction French
MI 7 Action and Adventure English

@NamedQueries({
Choose from below VALID named queries annotation in JPA. @NamedQueries @NamedGAry(name="query1"query "select b from BookEntity b),
@NamedQuery(name="query2"query = "select b.bookld from BookEntityb')
})
Jack wants to delete a customer(customerld 1001) from a customer table , since customer is not
active for longer time. He is using the below code to delete the customer record.Consider
persistance unit is "unit1".

@Entity
class CustomerEntity {
@Id
int customerld;
String customerName;
//Generate getters and setters
} Managed (ans in pdf is Removed ...need to just verify)
class CustomerDao {
public void deleteCustomer() {
try {
int id=1001;
EntityManagerFactory entityManagerFactory =
Persistence.createEntityManagerFactory('unit1");
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
employeeEntity = entityManager.find(EmployeeEntity.class.id);
if (id == employeeEntity.getEmployeeld()) {
entityManager.remove(employeeEntity);
entityManager.getTransaction().commit();//line - 1
}
else{
System.out.printin("employee id doesn't exist!");
}
}
catch(Exception exception) {
exception.printStack Trace();
}
}
Observe the above code and find out entity object goes to which state after line - 1
What type of testing is done using Junit? Unit Testing
What JDBC stands for? Java Database Connectivity
What is JDBC?
Which of the following is not a component/class of JDBC API? Transaction
Which of the following is not a component/class of JDBC API? ConnectionPool
A - JDBC DriverManager is a class that manages a list of database drivers.
B - It matches connection requests from the java application with the proper database driver using
Which of the following is correct about DriverManager class of JDBC?
communication subprotocol.
Ans: Both
A - JDBC driver is an interface enabling a Java application to interact with a database.
B - The JDBC driver gives out the connection to the database and implements the protocol for transferring the
Which of the following is correct about driver interface of JDBC? query and result between client and database.
Ans: Both

A - Connection interface consists of methods for contacting a database.


Which of the following is correct about Connection interface of JDBC? B - It represents communication context.
Ans: Both
A - Statement encapsulates an SQL statement which is passed to the database to be parsed and compiled.
Which of the following is correct about Statement class of JDBC? B - Statement encapsulates an SQL statement which is passed to the database to be planned and executed.
Ans: Both
A) ResultSet holds data retrieved from a database after you execute an SQL query using Statement objects.
B) It acts as an iterator to allow you to move through its data.
Which of the following is correct about ResultSet class of JDBC?
C) The java.sql.ResultSet interface represents the result set of a database query.
Ans : All
Which of the following manages a list of database drivers in JDBC? DriverManager
Which of the following gives out the connection to the database and implements the protocol for transferring the
query and result between client and database? JDBC driver
Which of the following consists of methods for contacting a database? Connection
Which of the following encapsulates an SQL statement which is passed to the database to be parsed, compiled,
planned and executed? Statement
Which of the following holds data retrieved from a database after you execute an SQL query using Statement objects? ResultSet
ResultSet.TYPE_BACKWARD_ONLY
In which of the following type of ResultSet, the cursor can only move forward in the result set? ResultSet.TYPE_FORWARD_ONLY
In which of the following type of ResultSet, the cursor can scroll forwards and backwards, and the result set is sensitive to
changes made by others to the database that occur after the result set was created? ResultSet.TYPE_SCROLL_SENSITIVE
Which of the following type of JDBC driver, calls native code of the locally available ODBC driver? JDBC-ODBC Bridge plus ODBC driver
Which of the following type of JDBC driver, calls database vendor native library on a client side.
This code then talks to database over network? Native-API, partly Java driver
Which of the following type of JDBC driver, talks with the server-side middleware that then talks to database? JDBC-Net, pure Java driver
Which of the following type of JDBC driver, uses database native protocol? Native-protocol, pure Java driver
Which of the following type of JDBC driver, is also called Type 1 JDBC driver? JDBC-ODBC Bridge plus ODBC driver
Which of the following type of JDBC driver, is also called Type 2 JDBC driver? Native-API, partly Java driver
What are the component/class of JDBC API? DriverManager, Driver, Connection, Statement, ResultSet, SQLException
Which of the below are valid XML tags? <body></body>
Consider the below XSL file called LibraryTransform.xsl with code
<xsl:stylesheet version="1.0" xmlns="http:www.w3.org">
<xsl:template match="/">
<html>
<body>
<h1>Library</h1>
<books>
<table border="1">
<book>
<tr>
<isbn>67899</isbn><title>Learning XML</title>
<td>ISBN</td>
</book>
<td>TITLE</td>
<book>
</tr>
<isbn>00899</isbn><title>Learning HTML</title>
<xsl:for-each select="books/book">
</book>
<tr>
</books>
<td><xsl:value-of select="isbn"/></td>
<td><xsl:value-of select="title"/></td>
</tr>
</xsl:for -each>
</xsl:stylesheet>
Which of the below would generate a well formed xml with above x
public static Connection getDBConnection()throws ClassNotFoundException
SQLExecption{
String
String username = "root";
John is creating a java application to CRM.He wants his application to be connected with the MYSQL
String password="root";
database
Connection connection= null;
to maintain the customer records. Help him to establish connection with the database.
ClassForName("com.mysql.jdbc Driver")
connection= DriveManager.getConnection
return connection
}
Which of the below is/are valid javascript function(s)?
import org.junit.jupiter.api.Assertion;
import org.junit.jupiter.api.Test;

class McqTests {
@Test
public void testAssertions() {
String sValue1= new String("TechGenics");
String sValue2= "TechGenics";
//Line 3
Assertions.assertEquals(sValue1, sValue2);
}
}
}

Which one of the below assertions, if placed at Line 3 in above code, will result into sucessful for
execution.
1. Assertions.assertSame(sValue1, sValue2);
2. Assertions.assertEquals(sValue1, sValue2);

Mr.Fred is a curator of the chain of museaums owned by the government. He is unsing a jaba
application names publicomuseo to store,retrive and modify artifect deatils in tnames hose museaums.
Mr. Martin runs an event management company names gastinodevents.Both have joined hands to the host
events
in those museaums to ignite interest among the public.Assuming that application uses JPA for persistance Many to one
operartions
which type of association exists between museum entity and Event entity.Choose one.

In JPA,JPQL queires are transiated byJPQL query processor.Consider the following sql statement
select * from MovieDetails.
Select m from MovieEntity m
From the following identity the equivalent JPQL statement.Note that table is MovieDetails
and entity is MovieEntity.
which of the following is/are valid to register driver class in JDBS?
1)DriverManager.getConnection("driverClassName");
2)DriverManager.registerDriver("driverClassName"); Class.forName("driverClassName");
3)DriverClassName obj=new DriverClassName();
4)Class.forName("driverClassName");
EntityManagerFactory provider name Has connection information,entity names and persistance
EntityManager data from a A logical collection of data for storing,manipulating and retriving database
1-iii,2-iv,3-ii,4-i
Entity connections Represents the programmatic connection templete for creating
persistance.xml Manages entities and performs CRUD operations
@test,
please select the correct annotations @desabled
@tag
create
which of the following options are valid for property " hibernate.hdm2ddi.auto" update
create-drop
org.junit.jupiter.api.test
harish and team is writing is writing a junit5 based test cases.help them to identify,which annotation.... method .....................................
..........................some code below
Yash task is to update the customer record using JPQL so he was writing update statement and passed to the createQuery()
method, then he realised that its not a good practice to pass query string while creating queries. He would like to use namedQuery
Answer:- B) Parameter cannot be passes to a named query to do the operation on required data set
for this approach. Help him to identify wrong statement about NamedQuery.
Predict the output of following program:
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class McqTests{
@Test
public void TestAssertions(){ Assertion fails and displays the supplied failure message “condition is true”
int iValue1 = 200;
int iValue2 = 200;

Assertions.assertTrue(iValue < iValue2, "Condition is true");


}
}
Assume that table book is already created in the book_db database, with columns 'book_id', 'book_name' and 'price'.

Refer the code beloe:

public class TransactionExample{


private static Connection connect = null;
private static PreparedStatement preparedStatement1 = null;
private static PreparedStatement preparedStatement2 = null;

public static void main(String a[]){


int count = 0;
try{ Answer :- A) 1
connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/book_db", "root", "rooot");

preparedStatement1 = connect.prepareStatement("insert into book values(?,?,?)");

preparedStatement1.setInt(1,1);
preparedStatement1.setString(2, "Book1");
preparedStatement1.setDouble(3, 100.0);
count = preparedStatement1.executeUpdate();
}
}
}
In JPA, JPQL queries are translated by JPQL query processor. Consider the following SQL statement:

select * from MovieDetails; Answer :- A) Select m from MovieEntity m;

From the following identify the equivalent JPQL statement. Note that table is MovieDetails and entity is MovieEntity.
1) EclipseLink & Hibernate
Which of the following are JPA providers ? [choose 2]

CSS is used for describing the presentation of web pages ,including colors layout and fonts
2) css enables presentation and content teams can work simultaneously on independent componenets
which of these statements are correct with respect to CSS ?
<!DOCTYPE html>
3) <html>
<body>
<h2>Number table</h2>
<script>
function calculate() {
var n=parseInt(document.getElementById("n1").value);
var text="";
var i;
for(i=1; i<=10;i++) {
Dhananjay has been entrusted with the task of creating a webpages. text+=" " +(n*i)+ "<br>";
The webpage will have s text box and a button. }
The user can enter the number using the text box. document.getElementById("demo").innerHTML=text;
On click of the button, request a calculation function to display multiplication table on the webpage as shown in the image. }
Using javascript, calculate mutiplication table of the number entered in the text box. </script>
Select the valid code option which can fulfill this requirement. Enter Number: <input type="text" name="number" id="n1"/>
<br/>
<button onclick="calculate()"> Calculate</button>
<p id="demo"></p>
</body>
</html>
4)
Consider the following JPA code. Where "MoviesData" is persistence unit name in
persistence.xml file.
EntityManagerFactory emfactory=Persistence.createEntityManagerFactory("MovieData");
EntityManager entitymanager = emfactory.createEntityManager(); A)
Query query=entityManager.createQuery("select m.movieName, m.genre,m.language from List<Object> list=query.getResultList();
MovieEntity m"); System.out.println("Moviename \t MovieGenre \t MovieLanguage");
// fill the code here for(Object entity : list) {
Object[] obj=(Object[]) entity;
MovieEntity has the fields String movieName, String genre and String language. System.out.println((String)obj[0]+"\t"+(String)obj[1]+"\t"+(String)obj[2]);
Note that Movie table has three rows. Identify only one correct statement from the following }
options to print the movie details as shown.

MovieName Movie Genre MovieLanguage


Dunkirk History Spanish
Interstellar Science-fiction French
MI 7 Action and Adventure English

5)
Refer the following JPA code unit1 is the persistance unit name in persistance.xml.
public class MovieDAOImpl{
public void addMovie(MovieBean movie) throws Exception {
EntityManager entityManager = null;
try{
EntityManagerFactory enitityManagerFactory =
Persistance.createEntityManagerFactory("unit1");
enitityManager = enitityManagerFactory.createEntityManager();
MovieEntity movieEntity= new MovieEntity();
MovieEntity.setMovieId(movieEntity.getMovieId());
MovieEntity.setMovieName(movieEntity.getMovieName());
MovieEntity.setMovieGenre(movieEntity.getMovieGenre());
entityManager.getTransaction().begin();
entityManager.merge(movieEnity);
entityManager.getTransaction().commit();
} catch (Exception exception) {
throw exception;
}
finally {
if(entityManager != null) {
entityManager.close();
}.
. i and ii only
.
.
.
MovieDAOImpl impl=new MovieDAOimpl();
imple.addMovie(bean);

MovieBean bean=new MovieBean();


bean.setMovieId(1003);
bean.setMovieName("Toy Story 3");
bean.setMovieGenre("Fantasy");
impl.addMovie(bean);
}
}

MovieBean has fields int movieId. String movieName and String movieGenre. MovieEntity
has fields int movieid. String movieName and String movieGenre. Assume that in MovieTable
no record exists with movieId 1004. A record exists with movie id 1003. Upon
executing the program which of the following statements are true. Choose Two.

i) New record with movie id 1004 is inserted.


ii)record with movie id 1003 is updated.
iii)... not exists exception is thrown while invoking addMovie() method with movie
6) pstatement setInt(2,bean.getMovieId());
Mr. John has written a code to update movie details. He has a compile-time-error " The
method setString(int, String) in the type PreparedStatement is not applicable for the
arguments (int, int)" against marked line in the following code. MovieBean class is used
and its fields are int movieId, String movieName , String genre and String language. Note
that MySql database is locally installed. Default port number is used. Schema is jdbcdemos
Movie Bean class has fields int movieId, String movieName, String genre adnn String
language. Help him to fix the error by choosing one of the following options:

public void updateMovie(MovieBean bean) throws SQLException,


ClassNotFoundExeption {
Connection connection=null;
String url="jdbc:mysql://localhost:3306/jdbcdemos";
String username="root";
String password="root";
try {
connection= DriverManager.getConnection(url,username,password);
String updatedata="update movie set gente=? where movie= ?";
PreparedStatement pstatement=
connection.prepareStatement(updatedata);
pstatement.setString(1,bean.getGenre());
pstatement.setString(2,bean.getMovieId()); // Compeil-time error here
boolean rowsUpdateCount=pstatement.execute();
if( rowsUpdatecount != true ) {
System.out.println("Employee update successfull !!");
} else {
System.out.println("OOps some thing went wrong!! we are on
process.. ");
}
} catch (Exception e) {
throw e;
} finally {
connection.close();
}
7) A) @BeforeAll
static void beforeAll()
Which Annotations and method signatures are correct in Junit ? [Choose 2]
B) @BeforeEach
void beforeEach()

8)
Consider the following program and choose a right option:

import static org.junit.Assert.assertNotNull;


import static org.junit.jupiter.api.Assertions.assetTrue;
impport org.junit.jupiter.params.ParameterizedTest; C) The default delimeter is a comma (,) but you can use another....(Not understandable). ... attribute
import org.junit.jupiter.params.provider.CsvSource;

class McqTests {

@ParameterizedTest
@CsvSource(value={"TechVersant@1","TechVersant@2"} , delimeter='@')
void simpleCsv( final String s1 , final int n1) {
assertNotNull(s1);
assertTrue(n1>0);
}
}
9) public static Connection getDBConnection() throws ClassNotFoundException,
SQLException {
String url="jdbc:mysql://localhost:3306/jdbcdemos";
String username="root";
John is creating a java application for CRM. He wants his application to be connected with
String password="root";
the mysql database to maintain the customer records. Help him to establish connection with
Connection connection=null;
the database.
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(url,username,password);
return connection;
}
10) A) pstatement.setString(1,bean.getMovieName());
Refer the following code Mrs Janet has been asked to code JDBC program to insert pstatement.setString(2,bean.getGenre());
movie details in the movie table columns 'movieid' , 'moviename' , 'genre' and pstatement.setString(3,bean.getLanguage());
'language'. Help her to complete the following code by identifying the right set of rowsInsertCount=pstatement.executeUpdate();
statements to be added. Choose one. Note that Mysql database is locally installed . Default
port numner is used. Schema is 'jdbcdemos'. 'Movie' Bean class has fields int 'movieId',
String 'movieName', String 'genre' and String 'language'.

public int insertMovie( MovieBean bean) throws ClassNotFoundExeception , SQLException,


Exception {
String url="jdbc:mysql://localhost:3306/jdbcdemos";
String username="root";
String password="root";
Connection connection=null;
` try {
int rowsInsertCount=0;
String insertdata="insert into movie(moviename,genre,language)
values(?,?,?)";
connection=DriverManager.getConnection(url,username,password);
PreparedStatement pstatement=connection.prepareStatement(insertdata);
// add statements here
if (rowsInsertCount > 0) {
System.out.println("No of rows inserted: " + rowsInsertCount);
} else {
System.out.println("OOps something went wrong !!");
}
return rowsInsertCount;
} catch(Exception e) {
throw e;
} finally {
connection.close();
}
11) JDBC 4.0
From which version of JDBC , driver name registration is not required?
12) C) isSearchable()
Which method is used to check whether the designated column can be used in SQL where clause?
13)
var result=document.getElement.ById("num");
Rose is writing a script where she has a requriment to increment a value received from
result=parseInt(result)+1;
textbox with a id "num"
console.log(result);
Value entered in the text box is 100
var result=document.getElementById("num"); //line 1
result=result+1; //line2
console.log(result); //line3
When Rose runs the above script the output of line 3 is 1001.
Help Rose resolve the problem by replacing the 3 lines of code marked line1, line2
line3 the most appropriate code.
14)
Question is not visible
15) <!DOCTYPE html>
<html>
<body>
<h2>Number table</h2>
<script>
function calculate() {
var n=parseInt(document.getElementById("n1").value);
var text="";
var i;
for(i=1; i<=10;i++) {
Dhananjay has been entrusted with the task of creating a webpages. text+=" " +(n*i)+ "<br>";
The webpage will have s text box and a button. }
The user can enter the number using the text box. document.getElementById("demo").innerHTML=text;
On click of the button, request a calculation function to display multiplication table on the webpage as shown in the image. }
Using javascript, calculate mutiplication table of the number entered in the text box. </script>
Select the valid code option which can fulfill this requirement. Enter Number: <input type="text" name="number" id="n1"/>
<br/>
<button onclick="calculate()"> Calculate</button>
<p id="demo"></p>
</body>
</html>

16)
Which of the following methods in JPA when involed, entity changes to managed state.
Choose TWO i and ii only
i) Find
ii) Persist
iii) Remove
iv) Merge
17)
Consider the below html:
<h1>Voter Age Validation</h1> function voter Age()
<form action="success"> {
Enter your age:<input type="text' id="age"> var age=parseInt(document.getElementById("age").value);
<input type="button" value="Validate" onclick="voterAge()"> if(age>=18)
</form> {
Choose the most appropriate javascript function implementation for voterAge() alert("Valid Age");
that display an alert message with message "Valid Age" If value entered is 18 and }
above and message "Invalid Age" if not entered in the range. else {
alert("Invalid Age");
}
}

Anyone of these is the answer


18) @NamedQueries({
alechmist @NamedQuery(name="latest_book",query="select b.bookName from BookEntity b where b.public year IN(select MAX(b.
harry potter publishyear)from BookEntity b)"),
black beauty @NamedQueries({
the secret @NamedQuery(name="oldest_book",query="select b.bookName from BookEntity b where b.public year IN(select MIN(b.
life of Pi publishyear)from BookEntity b)"),
Davinvi code
@entity
@table(name="book")
public class Bookentity{
@Id
@column(name="bookId")
private integer bookId;
@column(name="book_name")
private string bookName;
private Stringauthor
19) It leads to failure i.e. referntial integrity constraint voilation and exception hence no record is deleted
@entity
@table(name="customer")
public class customerentity{
@Id
private Integer customerId;
private String customerName;
@ManyToOne(cascade="CascadeType.PERSIST)
@JoinColumn(name="locationId_fk")
private locationEntity location;
@Entity
@Table(name="loaction")
pubic class LocationEntity{
@Id
private int locatuonId;
private String city;

20)
Sheila wants to check if a condition in her code is working correctly . Which Junit assert method is appropriate for her? void assertTrue(boolean condition)
21) <head>
Which one of the below tag creates boundaries of document header?
22) void assertTrue(condition)
23) class.forName("drivercClassName")
24) It is dependent on database
25) <boby></body>
which of the below is valid XML tag
26)
consider the below XSl file calle Library Transform.xsl with code
<xsl;stylsheet version ="1.0"xmlns = "https://...
<xsl:template match="/">

<html>

<body>
<books>
<h1>Library</h1>
<book>
<table border="1">
<isbn>678999</isbn><title>Learning XMI</title
<tr>
</book>
<td>ISBN</td>
<book>
<td>TITLE</td>
<tr> <isbn>008999</isbn><title>Learning HTML</title>
<xsl:for-each select="books/book">
</book>
<tr> </books>
<td><xsl:value-of select-"isbn"/></td>
<td><xsl:value-of select="title"/></td>
</tr>
</xsl:for-each>

</xsl:template>
</xsl:stylesheet>

Which of the below would generate a well formed xml with above x
27) <book>
28) <isbn>678999</isbn><title>Learning XMI</title
Type question

</book>
29) Consider the following test case:
Consider the following test case: import java.time.Duration;
import java.time.Duration; import org.junit.jupiter.api.Assertion;
import org.junit.jupiter.api.Assertion; import org.junit.jupiter.ap.Test;
import org.junit.jupiter.ap.Test; class MCQTest{
class MCQTest{ @Test
@Test public void testAssertions(){
public void testAssertions(){ Assertions.assertTimeout(Duration.ofSeconds(1),(){
Assertions.assertTimeout(Duration.ofSeconds(1),(){ Thread.sleep(100);
Thread.sleep(100); }};
}}; Assertions.assertEquals(10,"10");
Assertions.assertEquals(10,"10"); }
}
30) <isbn>008999</isbn><title>Learning HTML</title>
31) </book>
32)

<html>
<body>
<h2> form </h2>
<form>
Name:<br>
option to create html form, that allow users to enter name,email and gender. must allow to select only one of a given choice
<input type="text" id="fname" name="fname"><br>
male,female and other.
email:<br>
<input type = "text" id="email"name="email></br>
<input type = "radio" id="male"name="gender>value="male">
male<br>
<input type = "radio" id="female"name="gender>value="female">
female<br>
<input type = "radio" id="other"name="gender>value="other">
other</br>
</form></body></html>
33)
.box1{
bob has a requirement to style a div element in his webpage to have background color to be red and font style to be italic. background-color red;
below is the div element,help bobselect the most appropriate way to apply styling via CSS. font-style italic;
<div class="box"></div> }
34) <!doctype html>
<html>
<body>
<h2>number table></h2>
<script>
Dhananjay has been entrusted with the task of creating a webpages. function calculate(){
The webpage will have s text box and a button. var n = parseInt(document.getElementById("n1").value);
The user can enter the number using the text box. var text="";
On click of the button, request a calculation function to display multiplication table on the webpage as shown in the image. var i;
Using javascript, calculate mutiplication table of the number entered in the text box. for(i=1;i<=10;i++){text+=" "+(n*i)+"<br>";}
Select the valid code option which can fulfill this requirement. document.getElementbyid("demo").innerHTML=text;}
</script>
enter number<input type= "text" name=""number"id="n1"/><br/>
<button onclick="calculate()">calculate</button>
<p id="demo"></p></body></html>

35)
jdbc:mysql://localhost:3306/test
In order to establish connection with MYSQL database in JDBC which one of the following connection urls is correct?
note that port number is 3306,schema is test and mysql is locally instead

36)
already written in sheet
37) @test
@disabled
please select the correct ennotation @tag
38) get
there are a number of http methods.select valid http methods from given list[choose 2] put
39)
Jacqueline wants to create a customer report by fetching customerId, customername and customerlocation from
customer table. Consider CustomerEntity class with the following structure.

@Entity
class CustomerEntity{
@Id
private int customerId;
private String customerName;
private String customerContact;
private String customerLocation;
//Code with getters and setters
}

Help her to select the appropriate code from the given options.sssssssss

40)
Which of the below statements are correct with respect to HTTP and HTTPS:
1. HTTPS stands for Hyper Text Transfer Protocol Server 2nd and 3rd statements are correct
2. HTTPS is Combination of HTTP and Secure Socket Layer (SSL)
3. The https:// web pages indication along with a lock icon in the browser window pane indicate the presence of a
secure web page.
41) It's One To Many bidirectional association
Ani is working with a house construction application. She created two entity classes House and Window Or(confirm the answer)
that helps to design the application. What's true about the following @Entity association One to many unidirectional association
between House and Window?
@Entity
public class Window{
@ld
private int winNo;
private House aHouse;
}

@Entity
public class House {
@ld
private int houseNo;
@OneToMany(cascade Cascade Type ALL)
private List<Window> windows;
}
Choose the best option
42)
Punith, a developer wants to synchronize the changes done on the CustomerEntity object on the customer table.
He is using the below code to update the changes

public class CustomerDao{


public Integer addCustomer() throws Exception {
Integer customerID = 0;
EntityManager entityManager = null;
try {
EntityManagerFactory entityManagerFactory = Persistence createEntityManagerFactory();
entityManager entityManagerFactory.createEntityManager();
CustomerEntity customerEntity1 = new CustomerEntity();
customerEntity1.setCustomerid(1001);
customerEntity1.setCustomerName("John");
customerEntity1.setLocation("Pune");
customerEntity1 setType("Gold"); 1001 John Pune Gold
entityManager.getTransaction().begin();
entityManager.merge(customerEntity1);
customerEntity1.setLocation("Delhi");
entityManager.getTransaction().commit();
customerID = customerEntity1.getCustomerId();
} catch (Exeption exception) {
throw exception;
} finally (
if (entityManager = null) {
entityManager.close();
}
}
return customerID;
}

Which of the following customer data will be stored/updated in the customer table after executing the above code.
43)
Mr. Gaetano gets following error upon executing the code to retrieve details from the table "movie" with columns
movied, moviename, genre and language. From the following options which one he has to add in line1 in order to fix it.
Note that Mysql database is locally installed. Default port number is used. Schema is jdbcdemos < add movie bean structure>.
Movie Bean class has fieds int movield, Sting movieName, String genre and String language.
Refer the following code

public void readMovie() throws ClassNotFoundException, SQLException {


Connection connection = null;
String url ="jdbc:mysql://localhost:3306/jdbcdemos";
String usemame = "root";
String password = "root";
try {
String retrievedata = "select * from movie where movieId = ?";
connection = DriverManager.getConnecton(url, username, password);
PreparedStatement pstatement = connection.prepareStatement(retrievedata); //Line 1 pstatement.setint(1, Id)
ResultSet resultSet = pstatement.executeQuery();
while(resultSet.nest()) {
System.out.println("Movie ID: " + resultSet.getint("movieId") +
"\nMovie name: " + resultSet.getString("movieName") +
"\nGenre: " + resultSet.getString("genre") +
"\nLanguage: " + resultSet.getString("language"));
System.out.println("==============================================");
} catch (Exception e) {
throw e;
} finally {
Connection.close();
}
}

Error:

*Remaining is not there*


44) Statement is used for encapsulating an SQL statement to parse, compile and execute it to database
Choose from the following CORRECT statement about parsing, compiling and executing SQL queries in JDBC.
45) public static Connection getDBConnection() throws ClassNotFoundException,
SQLException
{
String url="jdbc:mysql://localhost:3306/dbcon";
john is creating a java application for CRM. He wants his application to be String username="root";
connected with the mysql database to maintain the customer records. Help him to String password="root";
connection with the database. Connection connection=null;
Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection(username,password);
return connection;
}
46)
Harry wants to creates a customer report for CRM application. He wants to When there are no more rows to iterate the retrieved result then read() returns nothing.
iterate the recordsfrom employee table. He is using ResultSet for the first time.
Help him to identify one wrong statement about ResultSet from the given option.
47)
Eesha wants to add a new customer record in a customer table.
Consider the CustomerEntity with the below structure.
class CustomerEntity{
int customerid;
String customerName; public integer addcustomer throw exception { integer customerid =0; entitymanager entitymanager =null;
String customerLocation;
String customerType;
//Generate getters and setters

}
Help her to select the appropriate code from the below options to achieve this task.

48) Which annotation and method signatures are correct in Junit?

49)
1. Junit 5 supports Java 5 or higher
Which of these statements are incorrect with respect to Junit 5?
2. Junit Jupiter provides support for running Junit 3 and Junit 4 based test on the platform.
3.Annotation @BeforeAll is analogous to Junit 4's @beforeEach
50) select movie,screen from movieEntity movie,ScrrenEntity screen where Movie.movieid = screen.movieid
consider BookMyTicket application.It allows users to book movie tickets. JPA is used for persistance
operations. It has two entities MovieEntity with fields int 'movieId', String 'movieame', String 'genere'
and String 'language'. ScreenEntity with field int 'movieId',int 'screenId', String 'screenName', Date
'showTime.They share one to one association.You are required to write JPQL to fetch movie name,
genre, language, screen name and show them to give movie id. Which one of the following JPQL
queries is correct?

51)
Consider the following JPA code. Where "Movie Data" is persistence unit name in
persistance.xml file.
EntyManagerFactory emfactory = Persistence.createEntityManagerFactory('MovieData"):
EntityManager entitymanager = emfactory.createEntityManager();
Query query=entityManager.createQuery("select m.movieName, m.genre,m.language from
MovieEntity m"): List Object list=query.getResultList (); System.out.printin "Moviename It MovieGenre It MovieLanguage
for (Object entity : list) {
MovieEntity has the fields String movieName, String genre and String language. Object) obj=(Object0) entity
Note that Movie table has three rows. Identify only one correct statment from the following System.out.prtin((String)objf0]+"r+(String)objf1]+""+(String)obj[2]): }
options to print the movie details as shown.

MovieName MovieGenre MovieLanguage


Dunkirk History Spanish
Interstellar Science-fiction French
MI 7 Action and Adventure. English
52)
Consider the following entity classes and sample records
@Entity
@Table(name = "customer")
public class CustomerEntity{
@Id
private Integer customerId;
private String customerName;
@ManyToOne(cascade = CascadeType.PERSIST)
@JoinColumn(name="locationId_fx")
private LocationEntity location;

// Code and setters/getters goes here Answer:


}

@Entity customer record with customerid 1001 will be deleted from customer table
@Table(name = "location")
public class LocationEntity{
@Id
private int locationId;
private String city;
// Code and setters/getters goes here
}

customer
customer Id customerName locationId_fk
1001 Jack 1
1002 Jim 1
1003 Jai 2

location
locationId city
1 Chennai
2 Pune
3 Banglore
53)
BookEntity.java

@Entity
@Table(name = "book")
public class BookEntity{
@Id
@Column(name="book_id")
private Integer bookId;
@Column(name="book_name")
private String bookName;

// Code and setters/getters goes here


}

persistence.xml

<persistence version="2.1"
xmlns="http://xmins.jcp.org/xml/ns/persistence"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name='JPA Merge">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.entity.BookEntity</class> 1)Runtime exceptio in line-1
<properties> 2)101
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /> 3)complilation error in ine-2
<property name="javax.persistence.jdbc.url" value='jdbc mysql:localhost:8306jpa_de" /> 4)Runtime exception in line-3
<property name='javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root">
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
Answer: Runtime exception in line-3
</properties>
</persistence-unit>
<persistence>

BookMain.java
54) @EmbeddedId
@Embeddable
@NamedQuery
@Qualifier
choose from below INVALID annotation in JPA
Answer: @Qualifier
55)
Mr. Gaetano gets following error upon executing the totale
table'movie' with columns movieid, moename gener
options which one he has to add in lines in order to fant. Noe te pa
locally installed. Default port number is used. Schema is hosteren
structure> Movie Bean class has fields int movield, Sting modelare
String language
Refer the following code.
A) pstatement.setint(1,id);
public void readMovie() throws ClassNotFoundException, Sector B) pstatement.setString(1,'1');
Connection connection = null; C) pstatement.setMovieId(1,id);
String url = "dbo.mysql/localhost3306jcbcdenas" D) pstatement.setint(0,id);
String username = "root"
String password ="root" Answer:A) pstatement.setint(1,id);
try!
String retrievedata = 'select from movie
connection=DriverManager getcomestnut
PreparedStatement pstatement
connection.prepare Statement/retrievedsta:
Mine
ResultSet resultSet =pstatementet
while (resultSet net
System.out.print
"In Movie name:
56)
Ben wants to delete the customer record
1001 john Employee deleted successfully:1001
1002 jack Employee deleted successfully:1
1003 krish Employee deleted successfully:2
int id=1001; OOps some thing went wrong!! we are on process..
String customerdata="DELETE" from customer WHERE customer="+
id+";
DriveManager getConnection(")dbc.mysql://localhost:3306/jdbcdemos","root","root");
Statement statement =connection.createStatement();
int deleteRowsUpdateCount=statement.executeUpdate(deletedata);
if(deleteRowsUpdateCount>0){
System.out.println("Employee deleted Successfully:"+ deleteRowsUpdateCount);
Answer:
Employee deleted successfully:1

57) ResultSet TYPE_FORWARD_ONLY


Which property of ResetSet type will be automatically assigned if you do not specify
58)
Harry wants to create customer report CRM application. he wants to iterate records from employee table when there are no more rows to iterate retrieved result next() method result returns nothing
he is using ResultSet for first time. help him to identity one wrong statement abt ResultSet
which method is used to check whether designated column can be used in SQL where clause? isSearchable()
59) function voterAge()
{
var age=parseNum(document.getElementByid("age");
consider below html if(age=>18)
<h1>Voter Age Validation</h1> {
<from action="success"> alert("valid age");
Enter your age:<input type="text"id="age"> else
<input type="button value="validate" onclick="voteAge()"> alert("invalid age");
<from> }
choose right javascript implementation }
60) c) 1st
which below is/are valid javascript funcations

1-
funcation sum(){
document froms.calc.result.value=
parseInt(document.forms.calc.number2.value)+
parseInt(document.forms.calc.number1.value);
}

2-
public int getSum(int a int b){
reurn a+b;
}

3-
function int getSum(int a, int b){
return a+b;
}
61)
which of below statements are correct w.r.t http and https

1- 2nd and 3rd are correct


HTTPS stands hyper text transfer protocol server
2-
HTTPS is combination of HTTP and secure socket layer(SSL)
3-
the https:// web pages indication along withlock icon browser window indicate presence of secure web page
62)
Ena and her team is working on UI design of job portal, currently they are designing cadidate registration form. POST
ena n her team need helps to identify http method that would allow submit registration form details as part of request body
to identify resource. on successful submission of req it would create registration id
please choose appropreiate help request method
QUESTIONS ANSWERS
63) It is dependent on the database
Choose the disadvantage on thin driver from below options
64)
Suresh a marketing executive wants to create an customer report on monthly basis. He wants PreparedStatement
to iterate the records from customer table more faster. Help him to select appropriate interface
for this situation.
65) on
Choose from the following CORRECT statements about Class.forName() method call.
This method is used for dynamically loading the driver's class fle into memory and to register it I and II only
automatically.
I) Since JDBC 4.0 this is redundant since auto discovery was enabled.
II) this method is used for dynamically loading the driver's class file into memory and register it automatically.
III) It is used only for loading type 4 driver
66)
Assume that book table is created in book db database and record is inserted as per
below schema

insert into book (book_name,price) values (Alchemist,250.0);


insert into book (book_name,price) values (Secret, 200.0);
insert into book (book_name,price) values ('GOT,750.0);
insert into book (book_name.price) values ('Hary Potter 450.0);
Refer the code below and predict the output
public class BookExample {
private static Connection connect = null;
private static PreparedStatement preparedStatement1 = null:
private static PreparedStatement prepared Statement2 = null;
private static ResultSet resultSet = null;
public static void deleteBooks(double price1, double price2) { No record deleted
int noOfRecordDeleted=0;
String query = "delete from book where price between ? and ?:
try{
connect DriverManager.getConnection("jdbc:mysql://localhost:3306
book_db","root","roof")
preparedStatement1=connect.prepareStatement(query);
preparedStatement1.setDouble(1, price1)
prepared Statement1.setDouble(2. price2)
noOfRecordDeleted= prepared Statement1.executeUpdate();

Incomplete Question

67) EclipseLink
Which of the following are JPA providers ? [choose 2] Hibernate
68)
EntityManagerFactory
Which object represents the programmatic connection definition? It also reads
the connection information from persistence.xml by mapping with the PersistenceUnitName
69) List Object list=query.getResultList (); System.out.printin "Moviename It MovieGenreIt MovieLanguage
for (Object entity : list) {
Considerthe following JPAcode. Where “MovieData”is Persistence unit name in persistance.xml Object) obj=(Object0) entity
file. System.out.prtin((String)objf0]+"r+(String)objf1]+""+(String)obj[2]);
70) @NamedQueries{
@NamedGAry(name="query1"query "select b from BookEntity b),
Choose from below VALID named queries annotation in JPA
@NamedQuery(name="query2"query = "select b.bookld from BookEntityb')
})

71) Unit testing


What type of testing is done using Junit?
72)
Failed assumptions result in a test failure
Anil is explaining JUnit 5 assumptions to his team. Which one of the below statements is false
with respect to assumptions and assertions?

73)
Consider the following test case:

import java.time. Duration;


import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api. Test;

class McqTests { Assertion results in a test failure because of -


AssertionFailed Error. expected.
@Test java.lang.Integer but was: java.lang.String
public void testAssertions() {

Assertions.assert Timeout(Duration.ofSeconds(1), ()-> {


Thread.sleep(100);
});
Assertions.assertEquals(10, "10");
}
}

74)
<link rel="stylesheet"type="text/css" href="containerstyle.css"/>
Thomas is designing home page for a news website. Home page design consist of many
container like <div> tag to display the new article details. Thomas needs to follow certain css
design which are standard throughout the website design. This standard css design are
available as extemal css file called containerstyle.css. Please choose the most approapriate
option to help Thomas to use the standard css in his home page design.

75)

consider the following code.unit1 is the persistance unit name in persistance.xml


public integer addMovie(MovieBean movie) throws Exception{
//TODO Auto-generated method stub
integer movieID = 0;
EntityManager entityManager = null;
try{
EntityMnagerFactory entityManagerFactory = Persistance.getEntityManagerFactory("unit1");
entityManager = entityMnagerFactory.createEntityManager();
MovieEntity movieEntity1 = new MovieEntity(); entity2 is the reference of managed copy hence it will be successful update
MovieEntity.setMovieId(movieEntity.getMovieId());
MovieEntity.setMovieName(movieEntity.getMovieName());
MovieEntity.setMovieGenre(movieEntity.getMovieGenre());
entityManager.getTransection().begin();
movieEntity.movieEntity2 = entityManager.merge(movieEntity1);
movieEntity2.setMovieName("dummy");
entityMnager.getTransection().commit();
movieID = movieEntity2.getEmployeedId();}
catch(Exception exception){throw exception;}finally{
76)
jack want to delete a customer(customerId = 1001)from a customer table,since customer is notactive for longer time he is
using the below code to delete the customer recoed .consider persistance unit is" unit1".
@Entity
class CustomerEntity{
@Id
int customerId;
String customerName;
//Generate getters and setters}
class CustomerDao(
public voud deleteCustomer(){
try{int id = 1001; removed
EntityMnagerFactory entityManagerFactory = Persistance.createEntityManagerFactory("unit1");
EntityManager entityManager = entityMnagerFactory.createEntityManager();
entityManager.getTransection().begin();
employeeEntity = entityManager.find(EmployeeEntity.class,id);
if(id== employeeEntity.getEmployeeId()){
entityManager.remove(emploeeEntity);
entityManager.getTransection().commit();//line-1}
else{system.out.println("employee id doesn't exist!");}}
catch(Excepetion exception){exception.printstackTrace();}}
observe the aboue code and find out entity object goes to which state after line-1

77)
ena and her team is working on UI design of a job portal. currently they are designing a candidate registration form.ena and post
her team needs a help to identify the Http method that would alow submit th registration form details as part of request body
to identified resourcses on successful submission of request it would create a registration id.please choose the most appropriate
http request method
78) <link rel = "stylesheet" type="text/css" href ="mystyle.css">
Consider css and html code in mystyle.css and index.html file as below:
mystyle.css:
.center(
color:red;
background-color:yellow;}
index.html:
<htmml><head>
>!-line3->
</head><body>
<h1 class = "center">java</h1>
<p class = "center"> java is a popular programming language,created in 1995>/p>
</body></html>
which one of the below lines,if placed at line 3 in index.html,will use css style from mystyle.css inside index.html
79)
Consider Becky wants to perform update on price and author name by book id on book table Query query = entityManager.createOuery("update BookEntity k set k.prlce=?11 and k.author-?21 where k.book_id = :Id");
Refer BookEntity class below: query.setParameter(11,200.0);
@Entity @Table(name="book") public class BookEntity{ query.setParameter(21, "Shakespeare");
@Id @Column(name="book_id") private Integer bookld; @Column(name="book_name") private String bookName; query .setParameter("id",1);
private String author,
private Double price; @Column(name="publishyear") private Integer publishYear:
//getters and setters
Refer table Book data below :
ID Book Name Author Price Publish Year
1 Alchemist paulcoelho 250$ 1988
2 Davinci code Dan Brown 250$ 2003
3 Harry potter J.K rowling 250$ 1998
4 black beauty Anna sewell 250$ 1877
5 the secret rhonda byrne 250$ 2006
6 life of pi yann martel 250$ 2001
consider the code structure below:
class bookUpdateExample{p.s.v.main(String[] args){
integer res = null;
try{EntutyMangerFactory entityMnagerFactory = persistence.createEntityManagerFactory("pu");
entityMnager = entityMnagerFactory.createEntityManager();
/**line-1:code goes here**/
entityMnager.getTransection().begin();
res = query.excecuteupdate();

Answer: C
.

80)
Choose from below VALID named queries annotation in JPA.
public static Connection getDBConnection() throws ClassNotFoundException SQLException {
81) String url = "jdbc:mysql://localhost:3306/jdbcdemos";
String username = "root";
John is creating a java application for CRM. He wants his applicationto be connected String password = "root";
with the MYSQL Database to maintain the customer records. Help him to establish connection Connection connection = null;
to the database. Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(url, username,passowrd);
return connection;
}
82)
Harry wants to create a customer report for CRM application. He wants to iterate the records When there are no more rows to iterate the retrieved result the next() method
from employee table. He is using ResultSet for the first time. Help him to identify one wrong statement returns nothing.
about ResultSet from the given options.
83)
Rose is writing a script where she has a requriment to increment a value received from
textbox with a id "num"
Value entered in the text box is 100 var result=document.getElement.ById("num");
var result=document.getElementById("num"); //line 1 result=parseInt(result)+1;
result=result+1; //line2 console.log(result);
console.log(result); //line3
When Rose runs the above script the output of line 3 is 1001.
Help Rose resolve the problem by replacing the 3 lines of code marked line1, line2
line3 the most appropriate code.
84)
Consider the following JPA code. Where "MoviesData" is persistence unit name in
persistence.xml file.
EntityManagerFactory emfactory=Persistence.createEntityManagerFactory("MovieData");
EntityManager entitymanager = emfactory.createEntityManager();
Query query=entityManager.createQuery("select m.movieName, m.genre,m.language from List<Object> list=query.getResultList();
MovieEntity m"); System.out.println("Moviename \t MovieGenre \t MovieLanguage");
// fill the code here for(Object entity : list) {
Object[] obj=(Object[]) entity;
MovieEntity has the fields String movieName, String genre and String language. System.out.println((String)obj[0]+"\t"+(String)obj[1]+"\t"+(String)obj[2]);
Note that Movie table has three rows. Identify only one correct statement from the following }
options to print the movie details as shown.

MovieName Movie Genre MovieLanguage


Dunkirk History Spanish
Interstellar Science-fiction French
MI 7 Action and Adventure English
85)
@NamedQueries({
Choose from below VALID named queries annotation in JPA. @NamedQueries @NamedGAry(name="query1"query "select b from BookEntity b),
@NamedQuery(name="query2"query = "select b.bookld from BookEntityb')
})
86)
Jack wants to delete a customer(customerld 1001) from a customer table , since customer is not
active for longer time. He is using the below code to delete the customer record.Consider
persistance unit is "unit1".

@Entity
class CustomerEntity {
@Id
int customerld;
String customerName;
//Generate getters and setters Managed (ans in pdf is Removed ...need to just verify)
}
class CustomerDao {
public void deleteCustomer() {
try {
int id=1001;
EntityManagerFactory entityManagerFactory =
Persistence.createEntityManagerFactory('unit1");
EntityManager entityManager = entityManagerFactory.createEntityManager();
entityManager.getTransaction().begin();
employeeEntity = entityManager.find(EmployeeEntity.class.id);
if (id == employeeEntity.getEmployeeld()) {
entityManager.remove(employeeEntity);
entityManager.getTransaction().commit();//line - 1
}
else{
System.out.printin("employee id doesn't exist!");
}
}
catch(Exception exception) {
exception.printStack Trace();
}
}
Observe the above code and find out entity object goes to which state after line - 1
87) Unit Testing
What type of testing is done using Junit?
88) Java Database Connectivity
What JDBC stands for?
89)
What is JDBC?
90) Transaction
Which of the following is not a component/class of JDBC API?
91) ConnectionPool
Which of the following is not a component/class of JDBC API?
92) A - JDBC DriverManager is a class that manages a list of database drivers.
B - It matches connection requests from the java application with the proper database driver using
Which of the following is correct about DriverManager class of JDBC?
communication subprotocol.
Ans: Both
93) A - JDBC driver is an interface enabling a Java application to interact with a database.
B - The JDBC driver gives out the connection to the database and implements the protocol for transferring the
Which of the following is correct about driver interface of JDBC? query and result between client and database.
Ans: Both

94) A - Connection interface consists of methods for contacting a database.


Which of the following is correct about Connection interface of JDBC? B - It represents communication context.
Ans: Both
95) A - Statement encapsulates an SQL statement which is passed to the database to be parsed and compiled.
Which of the following is correct about Statement class of JDBC? B - Statement encapsulates an SQL statement which is passed to the database to be planned and executed.
Ans: Both
96) A) ResultSet holds data retrieved from a database after you execute an SQL query using Statement objects.
B) It acts as an iterator to allow you to move through its data.
Which of the following is correct about ResultSet class of JDBC?
C) The java.sql.ResultSet interface represents the result set of a database query.
Ans : All
97) DriverManager
Which of the following manages a list of database drivers in JDBC?
98)
Which of the following gives out the connection to the database and implements the protocol for transferring the JDBC driver
query and result between client and database?
99) Connection
Which of the following consists of methods for contacting a database?

100)
Which of the following encapsulates an SQL statement which is passed to the database to be parsed, compiled, Statement
planned and executed?
101) ResultSet
Which of the following holds data retrieved from a database after you execute an SQL query using Statement objects?
102) ResultSet.TYPE_BACKWARD_ONLY

103) ResultSet.TYPE_FORWARD_ONLY
In which of the following type of ResultSet, the cursor can only move forward in the result set?
104)
In which of the following type of ResultSet, the cursor can scroll forwards and backwards, and the result set is sensitive to ResultSet.TYPE_SCROLL_SENSITIVE
changes made by others to the database that occur after the result set was created?
105) JDBC-ODBC Bridge plus ODBC driver
Which of the following type of JDBC driver, calls native code of the locally available ODBC driver?
106)
Which of the following type of JDBC driver, calls database vendor native library on a client side. Native-API, partly Java driver
This code then talks to database over network?
107) JDBC-Net, pure Java driver
Which of the following type of JDBC driver, talks with the server-side middleware that then talks to database?
108) Native-protocol, pure Java driver
Which of the following type of JDBC driver, uses database native protocol?
109) JDBC-ODBC Bridge plus ODBC driver
Which of the following type of JDBC driver, is also called Type 1 JDBC driver?
110) Native-API, partly Java driver
Which of the following type of JDBC driver, is also called Type 2 JDBC driver?
111) DriverManager, Driver, Connection, Statement, ResultSet, SQLException
What are the component/class of JDBC API?
112) <body></body>
Which of the below are valid XML tags?
113)
Consider the below XSL file called LibraryTransform.xsl with code
<xsl:stylesheet version="1.0" xmlns="http:www.w3.org">
<xsl:template match="/">
<html>
<body> <books>
<h1>Library</h1> <book>
<table border="1"> <isbn>67899</isbn><title>Learning XML</title>
<tr> </book>
<td>ISBN</td> <book>
<td>TITLE</td> <isbn>00899</isbn><title>Learning HTML</title>
</tr> </book>
<xsl:for-each select="books/book"> </books>
<tr>
<td><xsl:value-of select="isbn"/></td>
<td><xsl:value-of select="title"/></td>
</tr>
</xsl:for -each>
</xsl:stylesheet>
114)
Which of the below would generate a well formed xml with above x

115) public static Connection getDBConnection()throws ClassNotFoundException


John is creating a java application to CRM.He wants his application to be connected with the MYSQL SQLExecption{
database String
to maintain the customer records. Help him to establish connection with the database. String username = "root";
String password="root";
Connection connection= null;
ClassForName("com.mysql.jdbc Driver")
connection= DriveManager.getConnection
return connection
}
116)Which of the below is/are valid javascript function(s)?
117)
import org.junit.jupiter.api.Assertion;
import org.junit.jupiter.api.Test;

class McqTests {
@Test
public void testAssertions() {
String sValue1= new String("TechGenics");
String sValue2= "TechGenics"; Assertions.assertEquals(sValue1, sValue2);
//Line 3
}
}
}

Which one of the below assertions, if placed at Line 3 in above code, will result into sucessful for
execution.
1. Assertions.assertSame(sValue1, sValue2);
2. Assertions.assertEquals(sValue1, sValue2);
118)
Mr.Fred is a curator of the chain of museaums owned by the government. He is unsing a jaba
application names publicomuseo to store,retrive and modify artifect deatils in tnames hose museaums.
Mr. Martin runs an event management company names gastinodevents.Both have joined hands to the host
events Many to one
in those museaums to ignite interest among the public.Assuming that application uses JPA for persistance
operartions
which type of association exists between museum entity and Event entity.Choose one.

119)
In JPA,JPQL queires are transiated byJPQL query processor.Consider the following sql statement Select m from MovieEntity m
select * from MovieDetails.
From the following identity the equivalent JPQL statement.Note that table is MovieDetails
and entity is MovieEntity.
120)
which of the following is/are valid to register driver class in JDBS?
1)DriverManager.getConnection("driverClassName"); Class.forName("driverClassName");
2)DriverManager.registerDriver("driverClassName");
3)DriverClassName obj=new DriverClassName(); Statement 4
4)Class.forName("driverClassName");
121)
EntityManagerFactory provider name Has connection information,entity names and persistance 1-iii,2-iv,3-ii,4-i
EntityManager data from a A logical collection of data for storing,manipulating and retriving database
Entity connections Represents the programmatic connection templete for creating
persistance.xml Manages entities and performs CRUD operations
122) @test,
please select the correct annotations @desabled
@tag
123) create
which of the following options are valid for property " hibernate.hdm2ddi.auto" update
create-drop
124) org.junit.jupiter.api.test
harish and team is writing is writing a junit5 based test cases.help them to identify,which annotation. .....method .....................................
..........................some code below
125)
Yash task is to update the customer record using JPQL so he was writing update statement and passed to the createQuery() Answer:- B) Parameter cannot be passes to a named query to do the operation on required data set
method, then he realised that its not a good practice to pass query string while creating queries. He would like to use namedQuery
for this approach. Help him to identify wrong statement about NamedQuery.

126)
Predict the output of following program:
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class McqTests{
@Test Assertion fails and displays the supplied failure message “condition is true”
public void TestAssertions(){
int iValue1 = 200;
int iValue2 = 200;

Assertions.assertTrue(iValue < iValue2, "Condition is true");


}
}
127)

Assume that table book is already created in the book_db database, with columns 'book_id', 'book_name' and 'price'.

Refer the code beloe:

public class TransactionExample{


private static Connection connect = null;
private static PreparedStatement preparedStatement1 = null;
private static PreparedStatement preparedStatement2 = null;

public static void main(String a[]){ Answer :- A) 1


int count = 0;
try{
connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/book_db", "root", "rooot");

preparedStatement1 = connect.prepareStatement("insert into book values(?,?,?)");

preparedStatement1.setInt(1,1);
preparedStatement1.setString(2, "Book1");
preparedStatement1.setDouble(3, 100.0);
count = preparedStatement1.executeUpdate();
}
}
}
128)

In JPA, JPQL queries are translated by JPQL query processor. Consider the following SQL statement: Answer :- A) Select m from MovieEntity m;

select * from MovieDetails;

From the following identify the equivalent JPQL statement. Note that table is MovieDetails and entity is MovieEntity.
Option A is the answer

@ManyToMany(cascade=Cascade Type.ALL)
@JoinTable(name=”book_publisher”,
joinColumns={@JoinColumn(name=”book_fk_id”)};
inverseJoinColumns={@JoinColumn(name=”publisher_fk_id”)})

Assume that BookEntity and PublisherEntity has many to many JPA Entity relationship. Refer the tables

and code below:


129)

True
1001 Delhi

130)
Check the answer

Consider that John finds difficulties in searching a book by its bookid alone, he believed that book can be

retrived easily than before it composite primary key for publisherId is also created for the book table.

Choose the VALID code from below to create a composite primary key for bookId & publisherId in book
table

131)

132)

133)
134) @Entity and @Table
@Table and @Id
Farhan wants to create a CustomerEntity class to map with the customer tabe. Help him to………. @Id and @Column
@Entity and @Id
Mandatory annotations to be used in entity class from thr following options.
Find the correct answer

135) <form>
<h1>Login</h1>
Choose the most approriate code to build the below form with following requirements Enter account no:<input type=”textbook”><br><br>
Select billing plan :<select>
 Heading Tag with level as “Login” <option>Postpaid</option>
<option>Prepaid</option>
 Text as “Enter account no.” followed by a text box </select><br>
<input type=”Login” value=”submit”>
 Text as “Select billing plan” followed by a drop down with options as “Post paid” and “Pre paid” </form>
 Submit button with label “Login”

136)

Select the valid way in which JavaScript can be associated with an HTML document. [Choose 3]
137) Sujay is right only 1 root element per XML document
Sujay is wrong. XML can have multiple root statements
Sujay thinks that a well-formedxml has only one root element. Which of the following statements are There is no root element in XML
None of the above
correct?

138) 1
5
10
50
Run time exception in line-n

Assume that book table is available in the database book_db, with following table schema…………

……………….Consider John wants an application to insert a book information inside the book table with

series of editions...

You might also like