0% found this document useful (0 votes)
33 views7 pages

Bonus Quiz Term Break (4 Errors)

Uploaded by

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

Bonus Quiz Term Break (4 Errors)

Uploaded by

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

Bonus Quiz Term Break

Question 1 (1 point)
Saved
Match the method to its description? If you are not sure, look
up the documentation online.
Question 1 options:
1 Can execute any type of query, like
SELECT and INSERT. If return is true,
the executed query has a ResultSet,
otherwise, just a row count of updated
rows or nothing.
3 Can execute any query which return a 1. PreparedStatement::execute
set of rows, like SELECT. It returns a 2. PreparedStatement::executeUpdate
ResultSet which contains the data and 3. PreparedStatement::executeQuery
can never be null.
2 Can execute any query that does not
return any ResultSet like INSERT and
UPDATE. It returns the number of
updated rows.
Question 2 (1 point)
Saved
What is the lifecycle of a servlet?
Question 2 options:

a) A new servlet is created and destroyed for every request.

b) Only one servlet is created which will respond to all incoming requests.

c) Servlet are static classes that are never instantiated.

d) Only one servlet is created for head URLPattern. Each request to a specific URLPattern is served by a
thread using the servlet object associated to that URLPattern.
Question 3 (1 point)
Saved
Given the code below from JSF demo, what is true? Assume
this code is complete with no other dependencies.
<h:outputText value="#{uiconsts['columnLabel_Id']}" />
<h:inputText value="#{newInv.id}" id="id" />
Question 3 options:

a) id attribute is the name of the object that will be created by JSF and used in the setter of managed
DTO.

b) id attribute is not needed.

c) id attribute must be provided.

Question 4 (1 point)
Saved
What is the correct syntax to use a bean object in the XHTML
tag below? (goes in front of the action= )
<f:viewAction phase="UPDATE_MODEL_VALUES" action= />
Assume that the name of the controller is inventoryController.
Question 4 options:

a) #{inventoryController.loadInventory()}

b) "#{inventoryController.loadInventory()}"

c) "#{inventoryController.loadInventory}"

d) "inventoryController.loadInventory()"

Question 5 (1 point)
Saved
Assume some code is written to execute a select query on DB
(like the demo project in Week 4). If this code is written in the
style of Hibernate, there must be call to
session.beginTransaction(). This is not needed in case of code
written in JPA.
Question 5 options:
a) True
b) False
Question 6 (1 point)
Saved
Which annotation is used to identify an instance variable or
property of an entity that is to be mapped to the primary key
column of a table on the DB. This annotation is only used for
primary key.
Question 6 options:

a) @Column

b) @Id

c) @GeneratedValue

d) @Basic

Question 7 (1 point)
Saved
What does the annotation @Basic(optional=false) mean?
Read:
https://docs.oracle.com/javaee/7/api/javax/persistence/Basic.h
tml
Question 7 options:
a) The field/property cannot be null.

b) Validation is optional.

c) All answers are wrong.

d) The field/property can be null.

Question 8 (1 point)
Saved
Annotations should be placed on instance variables or get
methods of an entity but never both if the @Access annotation
is not used.
Question 8 options:
a) True
b) False
Question 9 (1 point)
Saved
Which of the states below are for EJB? (All or nothing)
Question 9 options:

a) SessionScoped

b) Stateful

c) ApplicationScope

d) Stateless

e) Singleton

Question 10 (1 point)
Saved
What is true about the @DependsOn annotation?
https://javaee.github.io/javaee-spec/javadocs/javax/ejb/
DependsOn.html
Question 10 options:

a) Can be given ejb-names of singleton components whose initialization must occur before this singleton.

b) All true

c) Used to express an initialization dependency between singleton components.

d) It can be placed with @Singleton.

Question 11 (1 point)
Saved
Given the code below, how do we reference the id field of this
POJO in an XHTML file?
@ViewScoped

@Entity( name = "iPojo")

@Table( name = "regional_inventory")

public class InventoryPojo implements Serializable {

private static final long serialVersionUID = 1L;

protected int id;

protected String retailerName;

protected String region;

protected int level;

@Id

@GeneratedValue( strategy = GenerationType.IDENTITY)


@Column( name = "INV_ID")

public int getId() {

return id;

public void setId( int id) {

this.id = id;

//other needed methods

Question 11 options:

a) #{iPojo.id}

b) #{IPojo.id}

c) #{inventoryPojo.id}

d) #{InventoryPojo.id}

Question 12 (1 point)
Saved
By default, all fields or properties in an entity are considered
to be @Basic which means they are nullable. Read:
https://docs.oracle.com/javaee/7/api/javax/persistence/Basic.h
tml
Question 12 options:
a) True
b) False
Question 13 (1 point)
Saved
Given the code below, what will be the column type in the
DB? Assume the table is generated by JPA.
@Enumerated(EnumType.ORDINAL)

@Column(name = "COL_SOMETHING")

protected SomeEnum foo;

Question 13 options:

a) NVARCHAR

b) int

c) VARCHAR

d) BIT

Question 14 (1 point)
Saved
What is the purpose of the @Version annotation?
Question 14 options:

a) It prevents simultaneous update of a row in a table. Each update increments the version, hence
preventing old versions updating newer versions.

b) It is for the version of code which has updated the data, for example code written in JDK 11 will have
version 11 on DB.

c) It represents the version of the table, as how many times it has been dropped and recreated.

You might also like