Java Techgenics MCQ 2


Hello guys if you are looking for Java Techgenics Multiple choice questions then here you will get Java Techgenics MCQ 2 Objective type questions | Java Techgenics MCQ 2 Accenture | Java Techgenics MCQ 2 Dumps | Java Techgenics MCQ 2


Note: Please use “Find In Page” Option in Chrome to find out your questions

1)  Which of the following are JPA providers ? 
Ans- EclipseLink & Hibernate
2)  which of these statements are correct with respect to CSS ? 
Ans
CSS is used for describing the presentation of web pages ,including colors layout and fonts
css enables presentation and content teams can work simultaneously on independent components
3)  Which method is used to check whether the designated column can be used in SQL where clause? 
Ans- isSearchable()
4) Harry wants to creates 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 about 
ResultSet from the given option
Ans- When there are no more rows to iterate the retrieved result then read() returns nothing.
5)  Choose the disadvantage on thin driver from below options 
Ans- It is dependent on the database
6)  Which of the following statement is/are valid to register driver class in JDBC? 
Ans- Class.forName("driverClassName");
DriverManager.registerDriver("driverClassName");
7)  Sheila wants to check if a condition in her code is working correctly . Which Junit assert method is 
appropriate for her?
Ans - void assertTrue(boolean condition)
8)  Consider the following test case:
import java.time. Duration;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api. Test; 
class McqTests {
@Test public void testAssertions() {
Assertions.assert Timeout(Duration.ofSeconds(1), ()-> { 
Thread.sleep(100); }); Assertions.assertEquals(10, "10"); } }
Ans - Assertion results in a test failure because of - AssertionFailed Error. expected. java.lang.Integer 
but was: java.lang.String
9)  Which one of the below tag creates boundaries of document header? 
Ans - <head>
10)  Which of the below are valid XML tags? 
Ans - <body></body>
11)  consider the below XSl file calle Library Transform.xsl with code
<xsl;stylesheet version ="1.0"xmlns = "https://...
<xsl:template match="/"><html><body><h1>Library</h1>
<table border="1">
<tr>
<td>ISBN</td><td>TITLE</td>
<tr>
<xsl:for-each select="books/book">
<tr>
<td><xsl:value-of select-"isbn"/></td>
<td><xsl:value-of select="title"/></td>
</tr>
</xsl:for-each></xsl:template></xsl:stylesheett>
Which of the below would generate a well formed xml with above x
Ans - 
<books>
<book><isbn>678999</isbn><title>Learninig XML</title></book> 
<book><isbn>008999</isbn><title>Learninig HTML</title></book> 
</books>
12)  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. below is the div element,help bobselect the most appropriate way to apply styling via CSS.
Ans - box1{ background-color red; font-style italic; }
13)  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
Ans - jdbc:mysql://localhost:3306/test
14)  Thomas is designing home page for a news website. Home page design consist of many container like 
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.
Ans - <link rel="stylesheet"type="text/css" href="containerstyle.css"/>
15)  There are a number of HTTP methods.Select valid HTTP methods from given list. [choose 2] 
Ans :- GET and PUT
16)  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; } 
@Entity public class House {
@ld private int houseNo; @OneToMany(cascade Cascade Type ALL) private List windows; } 
Choose the best option
Ans - It's One To Many bidirectional association Or its One to many unidirectional association
17)  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(); 
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.
Ans - 1001 John Pune Gold
18)  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();
MovieEntity.setMovieId(movieEntity.getMovieId());
MovieEntity.setMovieName(movieEntity.getMovieN ame());
MovieEntity.setMovieGenre(movieEntity.getMovie Genre()); 
entityManager.getTransection().begin();
movieEntity.movieEntity2 = entityManager.merge(movieEntity1); 
movieEntity2.setMovieName("dummy");
entityMnager.getTransection().commit(); movieID = movieEntity2.getEmployeedId();}
catch(Exception exception){ 
throw exception;}
finally{ (Incompleted Code………)
Ans - entity2 is the reference od managed copy hence it will be successful update
19)  John is creating a java application for CRM. He wants his application to be connected with the mysql 
database to maintain the customer records. Help him to connection with the database
Ans - public static Connection getDBConnection() throws ClassNotFoundException, SQLException { 
String url="jdbc:mysql://localhost:3306/dbcon"; String username="root"; String password="root"; 
Connection connection=null; Class.forName("com.mysql.jdbc.Driver");
connection=DriverManager.getConnection(username, password); return connection; }
20)  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 for this situation
Ans - PreparedStatement
21)  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) 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
Ans - I and II only
22)  Which object represents the programmatic connection definition? It also reads the connection information 
from persistence.xml by mapping with the PersistenceUnitName
Ans - EntityManagerFactory
23)  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"); 
// fill the code here
MovieEntity has the fields String movieName, String genre and String language. 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
Ans - A) List <object> list=query.getResultList(); System.out.println("Moviename \t MovieGenre \t 
MovieLanguage"); for(Object entity : list) { Object[] obj=(Object[]) entity;
System.out.println((String)obj[0]+"\t"+(String)obj[1]+"\t"+(String) obj[2]); }
24)  Choose from below VALID named queries annotation in JPA
Ans - @NamedQueries({ @NamedQueries @NamedGAry(name="query1"query "select b from 
BookEntity b), @NamedQuery(name="query2"query = "select b.bookld from BookEntityb') })
25)  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 } 
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
Ans - Removed
26)  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
PublishYear
1
5
6
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
the secret rhonda byrne 250$ 2006
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().b egin(); 
res = query.excecuteupdate();
Ans:- Query query = entityManager.createOuery("update BookEntity k set k.prlce=?11 and k.author-?21 
where k.book_id = :Id"); query.setParameter(11,200.0); query.setParameter(21, "Shakespeare"); query 
.setParameter("id",1);
27)  What type of testing is done using Junit? 
Ans - Unit Testing
28)  Anil is explaining JUnit 5 assumptions to his team. Which one of the below statements is false with respect 
to assumptions and assertions?
Ans - Failed assumptions result in a test failure
30)  Ena and her team is working on UI design of a job portal. currently they are designing a candidate 
registration form.ena and 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
Ans - Post
31)  Dhananjay has been entrusted with the task of creating a webpages. The webpage will have s text box 
and a button. The user can enter the number using the text box. 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. Select the valid code option which can fulfill this 
requirement.
Ans -  <!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++){ text+=””+(n*i)+”<br>”;}
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>
32)  Consider css and html code in mystyle.css and index.html file as below: 
mystyle.css: .center ( color:red; backgroundcolor:yellow;}
index.html:<html><head> 
<!-line3-></head>
<body>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
Ans - <link rel = "stylesheet" type="text/css" href ="mystyle.css">
33)  Consider the below html: (some mistake) 
<h1>Voter Age Validation</h1>
<form action=”success”> Enter your age:<input type=”text” id=”age> 
<input type=”button” value=”validate” onclick=”votrAge()”></form>
Choose the most appropriate javascript function implementation for voterAge() 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.
Ans - function voter Age()
{ var age=parseInt(document.getElementById("age").value); if(age>=18) 
{ alert("Valid Age"); } else { alert("Invalid Age"); } }
34)  Which Annotations and method signatures are correct in Junit ? [Choose 2] 
Ans -
A) @BeforeAll static void beforeAll()
B) @BeforeEac h void beforeEach()
35)  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/jdbcdem os";
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,pas sword);
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(); }
Ans:- A) pstatement.setString(1,bean.getMovieName()); 
pstatement.setString(2,bean.getGenre());
pstatement.setString(3,bean.getLanguage ()); 
rowsInsertCount=pstatement.executeUpdate();
36)  From which version of JDBC , driver name registration is not required? 
Ans - JDBC 4.0
37)  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
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
Ans - var result=document.getElement.ById("num"); 
result=parseInt(result)+1;
console.log(result);
38)  Select a valid option to create html form, that allow users to enter name,email and gender. must allow to 
select only one of a given choice male,female and other.
Ans - <html><body><h2>form</h2> 
<form>
Name: <br>
<input type=”text” id=”fname” name=”fname”><br> 
email: <br>
<input type=”text” id=”email” name=”email”><br>
<input type=”ratio” id=”male” name=”gender”>value=”male”>male<br>
<input type=”ratio” id=”female” name=”gender”>value=”female”>female<br> 
<input type=”ratio” id=”other” name=”gender”>value=”other”>other<br> 
</form></body></html>
39)  Which of the following methods in JPA when involed, entity changes to managed state. Choose TWO i) 
Find ii) Persist iii) Remove iv) Merge
Ans - i and ii only
40)  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.
Ans - ??????????????????????????
41)  please select the correct annotations 
Ans - @test, @desabled @tag
42)  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)
3. The https:// web pages indication along with a lock icon in the browser window pane indicate the presence of 
a secure web page.
Ans - 2nd and 3rd statements are correct
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 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: ( Continue)..........
Ans - pstatement.setint(1, Id)
44)  Which of these statements are incorrect with respect to Junit 5? 
Ans - 1.Junit 5 supports Java 5 or higher
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
45)  Choose from below INVALID annotation in JPA 
Ans - : @Qualifier
46)  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?
Ans - select movie,screen from movieEntity movie,ScrrenEntity screen where Movie.movieid = 
screen.movieid
47)  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 } } }
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);
Ans - Assertions.assertEquals(sValue1, sValue2);
48)  Which below is/are valid javascript funcations 
1- funcation sum(){C
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; }
Ans - 1st
49)  Which of the following options are valid for property " hibernate.hdm2ddi.auto” 
Ans - create ,update ,createdrop
50)  Assume the book table is created in book_dp database and record a 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 (‘Harry 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) 
int noOfRecordDeleted=0;
String query = "delete from book where price between ? and ?; 
Try{
connect DriverManager.getConnection("jdbc:mysql://localhost:3306 book_db","root","root");
preparedStatement1=connect.prepareStatement(query);
preparedStatement1.setDouble(1, price1);
prepared Statement1.setDouble(2. price2);
noOfRecordDeleted= prepared Statement1.executeUpdate(); 
( Question Half)
Ans -  No record deleted.
51)  Harish and team is writing is writing a junit5 based test cases.help them to identify,which annotation. 
....method.
Ans - org.junit.jupiter.api.test ...................... Some code below
52)  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 for this approach. Help him to identify wrong statement about 
NamedQuery.
Ans - Parameter cannot be passes to a named query to do the operation on required data set
53)  Predict the output of following program: 
import org.junit.jupiter.api.Assertions; 
import org.junit.jupiter.api.Test;
class McqTests{ @Test public void TestAssertions(){
int iValue1 = 200; int iValue2 = 200;
Assertions.assertTrue(iValue < iValue2, "Condition is true"); } }
Ans - Assertion fails and displays the supplied failure message “condition is true”
54)  Assume that BookEntity and PublisherEntity has many to many JPA Entity relationship. 
Refer the tables and code below:
Ans - @ManyToMany(cascade=Cascade Type.ALL) @JoinTable(name=”book_publisher”, 
joinColumns={@JoinColumn(name=”book_fk_id”)};
inverseJoinColumns={@JoinColumn(name=”publisher_fk_id”)})
55)  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{
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(); 
}}
Ans - 1
56)  In JPA, JPQL queries are translated by JPQL query processor. Consider the following SQL statement: 
select * from MovieDetails;
From the following identify the equivalent JPQL statement. 
Note that table is MovieDetails and entity is MovieEntity.
Ans - Select m from MovieEntity m;
57)  Farhan wants to create a CustomerEntity class to map with the customer tabe. Help him to………. 
Mandatory annotations to be used in entity class from thr following options.
Ans - : @Entity and @Id
58)  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>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value='jdbc mysql:localhost:8306jpa_de" />
<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"/>
</properties>
</persistence-unit>
<persistence> 
BookMain.java
Ans - Runtime exception in line-3
59)  Sujay thinks that a well-formedxml has only one root element. Which of the following 
Ans -  Sujay is right only 1 root element per XML document
60)  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 } 
@Entity @Table(name = "location") 
public class LocationEntity{
@Id private int locationId; private String city; 
// Code and setters/getters goes here } 
Customer
customerId     customerName           locationId_fk
1001               Jack 1
1002               Jim1
1003               Jai 2 
location 
locationId        city
1                     Chennai
2                     Pune
3                     Banglore
Ans - It leads to failure i.e. referntial integrity constraint voilation and exception hence no record is 
deleted
61) Mr. John has written a code to update movie details. He has a compiletime-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/jdbcdem os";
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());
// Compeiltime 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(); }
Ans - pstatement setInt(2,bean.getMovieId());
62)  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 operartions 
which type of association exists between museum entity and Event entity.Choose one.
Ans - Many to one
63)  Which property of ResetSet type will be automatically assigned if you do not specify 
Ans - ResultSet TYPE_FORWARD_ONLY
64)  Ben wants to delete the customer record 1001 john 1002 jack 1003 krish int id=1001; 
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(d eletedata); 
if(deleteRowsUpdateCount>0){
System.out.println("Employee deleted Successfully:"+ deleteRowsUpdateCount);
Ans - Employee deleted successfully:1
65)  Choose the most approriate code to build the below form with following requirements 
● Heading Tag with level as “Login”
● Text as “Enter account no.” followed by a text box
● Text as “Select billing plan” followed by a drop down with options as “Post paid” and “Pre paid” 
● Submit button with label “Login”
Ans - <form> 
<h1>Login</h1>
Enter account no:<input type=”textbook”<br><br>
Select billing plan:<select> <option>Postpaid</option><option>Prepaid</option></select></br> 
<input type=”Login” value=”submit”></form>
66)  Consider css and html code in mystyle.css and index.html files as below: 
mystyle.css:
.center{
background-color: yellow:{ 
index.html:
<html> <head><!--Line3 -></head> 
<body>
<h1 class="center"> Java</h1>
p class="center">Java isa popular programming language, creeted in 1995</p> </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.
Ans: -  link rel="stylesheet" type="texucss" href="mystyle.css">
67)  Consider the following program and choose a right option:
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assetTrue;
import org.junit.jupiter.params.ParameterizedTest;
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); } }
Ans - The default delimeter is a comma (,) but you can use another....(Not understandable)....attribute
68)  Choose from the following CORRECT statement about parsing, compiling and executing SQL queries in 
JDBC
Ans - Statement is used for encapsulating an SQL statement to parse, compile and execute it to 
database
69)  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 customerType; 
//Generate getters and setters }
Help her to select the appropriate code from the below options to achieve this task
Ans - public integer addcustomer throw exception { integer customerid =0; entitymanager 
entitymanager =null;


Leave a Reply

Your email address will not be published. Required fields are marked *