QUIZ_1-10

pdf

School

Algonquin College *

*We aren’t endorsed by this school

Course

8277

Subject

Electrical Engineering

Date

Jan 9, 2024

Type

pdf

Pages

55

Uploaded by lewisbrown27

Report
Quiz 01 - JDBC, Servlet, and JSP - Results Attempt 1 of 1 Written May 21, 2023 9:17 PM - May 21, 2023 9:27 PM Released May 22, 2023 8:00 AM Attempt Score 7 / 8 - A Overall Grade (Highest Attempt) 7 / 8 - A Question 1 1 / 1 point Match the method to its description? If you are not sure, look up the documentation online. __2__ Can execute any query that does not return any ResultSet like INSERT and UPDATE. It returns the number of updated rows. __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 set of rows, like SELECT. It returns a ResultSet which contains the data and can never be null. 1 . PreparedStatement::execute 2 . PreparedStatement::executeUpdate 3 . PreparedStatement::executeQuery Question 2 1 / 1 point Assume we are inserting a row to a DB table using JDBC. After inserting the row we also need to get the auto generated key for it from the DB. Which line of code below is correct? a) connection.prepareStatement(INSERT_PERSON, Statement.RETURN_GENERATED_KEYS) b) connection.prepareStatement(Statement.RETURN_GENERATED_KEYS) c) connection.prepareStatement(INSERT_PERSON) d) There is no need for any special code. The auto generated key can be retrieved from any DB without the need of extra code. Question 3 1 / 1 point There are no differences between the two blocks of code below. They will both produce the same result. (Note: Assume the code is correct, anything omitted is irrelevant to the question.) // Code Block 1 Properties dbProps = new Properties(); dbProps.put("user", username); dbProps.put("password", password); Connection connection = DriverManager.getConnection(jdbcUrl, dbProps); // Code Block 2 Connection connection = DriverManager.getConnection(jdbcUrl, username, password); a) True b) False Question 4 0 / 1 point JSP (Java/Jakarta Server Pages) is the way to write html code with Java code embedded in it. Servlets, on the other hand, are written in Java with HTML embedded in them. Correct Answer a) True Incorrect Response b) False Question 5 1 / 1 point When a JSP page is called, it will be compiled (by the JSP engine internally) into a Java servlet. a) True b) False Question 6 1 / 1 point Method destroy() in servlets can be called by the user at anytime to destroy the servlet. This method can be called by unhappy user to nuke a server as a sign of protest. a) True b) False Question 7 1 / 1 point Method init() in a servlet can be used to initialize objects when the servlet is started for the first time. It is called once and once only. a) True b) False Question 8 1 / 1 point What is the lifecycle of a servlet? a) Servlets are static classes that are never instantiated. b) Only one servlet is created which will respond to all incoming requests. c) 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. d) A new servlet is created and destroyed for every request. Done
Quiz 03 - Hibernate - Results Attempt 1 of 1 Written Jun 4, 2023 7:27 PM - Jun 4, 2023 7:48 PM Released Jun 5, 2023 8:00 AM Attempt Score 10 / 10 - A+ Overall Grade (Highest Attempt) 10 / 10 - A+ Question 1 1 / 1 point Which annotation is used to let Hibernate/JPA know that the primary key field or property of an entity is auto-generated? Read online documentation: https://docs.oracle.com/javaee/7/api/javax/persistence/GeneratedValue.html a) @Basic b) @Column c) @GeneratedValue d) @Id Question 2 1 / 1 point
Which annotation is used to identify an instance variable which corresponds to the primary key of a mapped table on the database. This annotation is only used for single-column primary key. Read online documentation: https://docs.oracle.com/javaee/7/api/javax/persistence/Id.html a) @Id b) @Basic c) @GeneratedValue d) @Column Question 3 1 / 1 point Assume some code is written to execute a simple select only query on the DB. If this code is written in the style of Hibernate, there must be call to session.beginTransaction() . Starting a transaction is not needed in case of code written in the style of JPA when doing simple select only query. Hint: Look at and compare HibernateExample.java and JPAExample.java programs given in Week 4. a) True b) False Question 4 1 / 1 point Hibernate sits between the database and Java application. It is an implementation of JPA. a) True b) False Question 5 1 / 1 point What annotation is needed to mark a class as an entity to be mapped by Hibernate/JPA? Read the online documentation: https://docs.oracle.com/javaee/7/api/javax/persistence/Entity.html a) @NamedQuery
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
b) @Table c) @Id d) @Entity Question 6 1 / 1 point Which annotation is used to map an instance variable to its column on a table in the DB. Read online documentation: https://docs.oracle.com/javaee/7/api/javax/persistence/Column.html a) @Column b) @Id c) @GeneratedValue d) @Basic Question 7 1 / 1 point What does the annotation @Transient on a field or property of an entity mean? Read online documentation: https://docs.oracle.com/javaee/7/api/javax/persistence/Transient.html a) It specifies that the field or property can be null. b) It specifies that the field or property is not persistent. c) It specifies that the field or property is to be mapped to a column on a table in the database.
d) All answers are wrong. Question 8 1 / 1 point What is true about the @Table annotation? Read the online documentation: https://docs.oracle.com/javaee/7/api/javax/persistence/Table.html a) If no @Table annotation is used, then default values are used, that is, the entity class MyEntity will be mapped to the myentity table in the database if no @Table annotation is provided. b) It allows you to define the name, schema, and catalog of the table for your entity mapping. c) All answers are true. Question 9 1 / 1 point What is the name of the file which stores the configuration for JPA? Hint: Look inside the src/main/resources/META-INF folder of the sample project Example-HibernateJPA given in Week 4 . a) persistence.xml b) hibernate.cfg.xml c) context.xml d) web.xml Question 10 1 / 1 point
JPA annotations (such as @Id, @Column, @Transient, etc.) should be placed on class member fields or on property-style get methods but never both. a) True b) False Done
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Quiz 04 - EJB and JPA - Results Attempt 1 of 1 Written Jun 10, 2023 9:37 AM - Jun 10, 2023 9:47 AM Released Jun 12, 2023 8:00 AM Question 1 1 / 1 point All JPQL queries can be written in HQL as Hibernate is 100% compliant with JPA. However, not all HQL queries can be written in JPQL as Hibernate has extra features that JPA does not support. a) True b) False Question 2 0 / 1 point Given the code below, how do we reference the id field 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 } a) #{InventoryPojo.id} Correct Answer b) #{iPojo.id} Incorrect Response c) #{inventoryPojo.id} d) #{IPojo.id} Question 3 1 / 1 point According to Oracle Java EE 8 Tutorial which reason below is appropriate to use @Stateless? https://javaee.github.io/tutorial/ejb-intro002.html#GIPMT a) A single enterprise bean needs to be accessed by multiple threads concurrently.
b) The bean's state represents the interaction between the bean and a specific client. c) State needs to be shared across the application. d) The bean needs to hold information about the client across method invocations. e) The bean's state has no data for a specific client. Question 4 1 / 1 point Given the persistence.xml configuration file below, what is correct? <persistence version="2.1" xmlns=" http://xmlns.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/persistenc <persistence-unit name="PU_DataBank_CST" transaction-type="JTA"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <jta-data-source>java:app/jdbc/databank</jta-data-source> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="javax.persistence.schema-generation.database.action" value="create-only"/> <property name="javax.persistence.schema-generation.create-source" value="metadata"/> <!-- https://docs.jboss.org/hibernate/stable/orm/userguide/html_single/Hibernate_User_Guide.ht <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL8Dialect"/> <property name="hibernate.connection.autocommit" value="false"/> <property name="hibernate.connection.shutdown" value="true"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/> <property name="hibernate.use_sql_comments" value="true"/> </properties> </persistence-unit> </persistence> a) @PersistenceContext(name="persistence-unit") b) @PersistenceContext(name="org.hibernate.jpa.HibernatePersistenceProvider ") c) @PersistenceContext(name="PU_DataBank_CST") d) @PersistenceContext(name="java:app/jdbc/databank ") Question 5 1 / 1 point According to Oracle Java EE 8 Tutorial which reason below is appropriate to use @Singleton? https://javaee.github.io/tutorial/ejb-intro002.html#GIPMT a) The bean's state has no data for a specific client. b) A single enterprise bean needs to be accessed by multiple threads concurrently. c) The bean's state represents the interaction between the bean and a specific client.
d) The bean needs to hold information about the client across method invocations. Question 6 1 / 1 point What is true about @DependsOn? Read the following https://javaee.github.io/javaee-spec/javadocs/javax/ejb/DependsOn.html a) All are true. b) Used to express an initialization dependency between singleton components. c) Can be given ejb-names of singleton components whose initialization must occur before this singleton. d) It must be placed with @Singleton. Question 7 1 / 1 point Which of the states below are for EJB? (All or nothing) a) Singleton b) SessionScoped c) Stateful d) Stateless e) ApplicationScope Question 8 1 / 1 point What does @Startup mean on a @Singleton bean? Read https://docs.oracle.com/cd/E19798-01/821-1841/gippq/index.html and https://docs.oracle.com/javaee/6/api/javax/ejb/Startup.html a) Marks a singleton bean for eager initialization during the application startup sequence. b) Marks the class to be started, otherwise it will never start. c) None. d) Marks a singleton bean for lazy initialization. Question 9 1 / 1 point According to Oracle Java EE 8 Tutorial which reason below is appropriate to use @Stateful? https://javaee.github.io/tutorial/ejb-intro002.html#GIPMT
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
a) The bean's state has no data for a specific client. b) The bean needs to hold information about the client across method invocations. c) State needs to be shared across the application. d) A single enterprise bean needs to be accessed by multiple threads concurrently. e) The bean implements a web service. Done
Quiz 05 - JPA - Results Attempt 1 of 1 Written Jun 25, 2023 10:58 PM - Jun 25, 2023 11:05 PM Released Jun 19, 2023 8:00 AM Attempt Score 10 / 10 - A+ Overall Grade (Highest Attempt) 10 / 10 - A+ Question 1 1 / 1 point What annotation is used if enum type field/property is used in an entity? a) None, enum is not supported. b) @Column(name="enum") c) @Enumerated d) @Temporal Question 2 1 / 1 point There is no difference in starting/initializing JPA in Java SE vs Java EE. a) True
b) False Question 3 1 / 1 point 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.html a) True b) False Question 4 1 / 1 point How many optional elements (or attributes) can be set using @Column annotation and how many of those are mandatory? Read: https://javaee.github.io/javaee-spec/javadocs/javax/persistence/Column.html a) @Column takes no extra details b) 10 and all c) 10 and none d) @Column is for Hibernate only and not used in JPA. Question 5 1 / 1 point What is the recommended GenerationType for MySQL? Read: https://vladmihalcea.com/why- should-not-use-the-auto-jpa-generationtype-with-mysql-and-hibernate/ a) GenerationType.SEQUENCE b) GenerationType.AUTO c) GenerationType.TABLE
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
d) GenerationType.IDENTITY Question 6 1 / 1 point Given the code below, what will be the column type in the DB? Assume that the table is generated by JPA and that SomeEnum is an enum type. @Enumerated(EnumType.ORDINAL) @Column(name = "COL_SOMETHING") protected SomeEnum foo; a) NVARCHAR b) VARCHAR c) BIT d) int Question 7 1 / 1 point In @Column annotation below, how do we set it up to use Oracle's NVARCHAR unicode-aware column-type? @Entity(name = "H") @Table(name = "TABLE_H") public class HPojo { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) protected int id; @Column(name = "COL_SOMETHING") protected String foo; // JPA likes default constructor public HPojo() {
} } a) By default, all string mappings support Unicode. b) columnDefinition="NVARCHAR" c) columnDefinition="VARCHAR" d) columnDefinition="VARCHAR(100)" Question 8 1 / 1 point What is the purpose of the @Version annotation placed on a field of an entity? a) It represents the version of the table, as to how many times it has been dropped and recreated. 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 the DB. c) It prevents simultaneous updates of a row in a table. Each update increments the version, hence preventing old versions from updating newer versions. Question 9 1 / 1 point Which annotations prevents a field or property in an entity to be mapped/persisted? a) @Id b) @Transient c) @Basic
d) @EmbeddedId Question 10 1 / 1 point Which annotation maps the primary key field/property of an entity to the primary key column of a table? a) @Id b) GenerationType.IDENTITY c) @Column(name = "ID") d) @GeneratedValue Done
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Bonus Quiz Term Break - Results Attempt 1 of 1 Written Jun 25, 2023 10:48 PM - Jun 25, 2023 10:58 PM Released Jun 26, 2023 8:00 AM Attempt Score 9 / 14 - C Overall Grade (Highest Attempt) 9 / 14 - C Question 1 0 / 1 point Match the method to its description? If you are not sure, look up the documentation online. __3__ Can execute any query which return a set of rows, like SELECT. It returns a ResultSet which contains the data and can never be null. Incorrect Response __2__ (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. Incorrect Response __1__ (2) Can execute any query that does not return any ResultSet like INSERT and UPDATE. It returns 1 . PreparedStatement::execute 2 . PreparedStatement::executeUpdate 3 . PreparedStatement::executeQuery
the number of updated rows. Question 2 1 / 1 point What is the lifecycle of a servlet? a) 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. b) Servlet are static classes that are never instantiated. c) Only one servlet is created which will respond to all incoming requests. d) A new servlet is created and destroyed for every request. Question 3 0 / 1 point 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" /> a) id attribute is the name of the object that will be created by JSF and used in the setter of managed DTO. Incorrect Response b) id attribute must be provided. Correct Answer c) id attribute is not needed. Question 4 0 / 1 point 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. Incorrect Response a) "#{inventoryController.loadInventory}" b) #{inventoryController.loadInventory()} Correct Answer c) "#{inventoryController.loadInventory()}" d) "inventoryController.loadInventory()" Question 5 0 / 1 point 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. Correct Answer a) True Incorrect Response b) False Question 6 1 / 1 point 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. a) @GeneratedValue b) @Basic c) @Column
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
d) @Id Question 7 1 / 1 point What does the annotation @Basic(optional=false) mean? Read: https://docs.oracle.com/javaee/7/api/javax/persistence/Basic.html a) Validation is optional. b) The field/property can be null. c) The field/property cannot be null. d) All answers are wrong. Question 8 1 / 1 point Annotations should be placed on instance variables or get methods of an entity but never both if the @Access annotation is not used. a) True b) False Question 9 1 / 1 point Which of the states below are for EJB? (All or nothing) a) SessionScoped b) Singleton c) Stateful
d) ApplicationScope e) Stateless Question 10 1 / 1 point What is true about the @DependsOn annotation? https://javaee.github.io/javaee-spec/javadocs/javax/ejb/DependsOn.html a) All true b) It must be placed with @Singleton. c) Used to express an initialization dependency between singleton components. d) Can be given ejb-names of singleton components whose initialization must occur before this singleton. Question 11 0 / 1 point 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 } a) #{InventoryPojo.id} Incorrect Response b) #{inventoryPojo.id} Correct Answer c) #{iPojo.id} d) #{IPojo.id} Question 12 1 / 1 point 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.html a) True b) False Question 13 1 / 1 point 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; a) int
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
b) NVARCHAR c) BIT d) VARCHAR Question 14 1 / 1 point What is the purpose of the @Version annotation? a) It represents the version of the table, as how many times it has been dropped and recreated. b) It prevents simultaneous update of a row in a table. Each update increments the version, hence preventing old versions updating newer versions. c) 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. Done
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Quiz 06 - JPA Relations and Mapping - Results Attempt 1 of 1 Written Jul 9, 2023 11:11 PM - Jul 9, 2023 11:34 PM Released Jul 10, 2023 8:00 AM Attempt Score 8 / 9 - A Overall Grade (Highest Attempt) 8 / 9 - A Question 1 0 / 1 point Select all annotations which represent the relationship between two entities/tables in JPA. Correct Answer a) @ManyToMany Correct Answer b) @ManyToOne c) @Inheritance d) @JoinColumn
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Correct Answer Incorrect Response e) @ManyToOne Correct Answer f) @OneToMany Question 2 1 / 1 point What happens if cascade is not defined? Please read: @interface OneToMany @OneToMany(mappedBy = "owningEmployee") private List<Phone> phones; a) Any operation in the current entity will cascade to phones as well. b) Cascade should only be placed in @ManyToOne relationships. c) No such field exists. d) No operation in the current entity will cascade to phones. Question 3 1 / 1 point What does cascade below mean? Please read: @interface OneToMany @OneToMany(mappedBy = "owningEmployee", cascade = CascadeType.ALL, orphanRemoval = true) private List<Phone> phones; a) No such field exists.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
b) Cascade should only be placed in @ManyToOne relationships. c) Any operation in current entity will cascade to phones as well. d) No operation in the current entity will cascade to phones. Question 4 1 / 1 point All entities must use the @MappedSuperClass annotation since id , created , updated , and version fields can only be placed in the mapped super class. a) True b) False Question 5 1 / 1 point Assume everything else is correct. Answer the question inside the BankAccount class. public class BankAccount { // What annotation describes the relationship here? protected Person owner; } a) @OneToMany
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
b) @OneToOne c) @ManyToMany d) @ManyToOne Question 6 1 / 1 point Assume everything else is correct. Answer the question inside the MembershipCard class. @Entity @Table(name = "membership_card") public class MembershipCard { // What annotation describes the relationship here? protected Student student; ... } @Entity @Table(name = "student")
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
public class Student { @Id protected int id; ... } a) @JoinColumn(name = "id", referencedColumnName = "student_ id") @ManyToOne(fetch = FetchType.LAZY) b) @JoinColumn(name = "id", referencedColumnName = "student_ id") @OneToMany (fetch = FetchType.LAZY) c) @JoinColumn(name = "student_id", referencedColumnName = "id") @ManyToMany(fetch = FetchType.LAZY) d) @JoinColumn(name = "student_id", referencedColumnName = "id") @OneToMany(fetch = FetchType.LAZY) e) @JoinColumn(name = "student_id", referencedColumnName = "id") @ManyToOne(fetch = FetchType.LAZY) Question 7 1 / 1 point Assume everything else is correct. Answer the question inside the Student class.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
@Entity @Table(name = "student") public class Student { // What annotation describes the relationship here? protected Set<MembershipCard> membershipCardSet; ... } @Entity @Table(name = "membership_card") public class MembershipCard { ... protected Student student; ... } a) @OneToMany(mappedBy = "student", fetch = FetchType.LAZY) b) @OneToMany(mappedBy = "student_id", fetch = FetchType.LAZY) c) @ManyToMany(mappedBy = "student", fetch = FetchType.LAZY)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
d) @ManyToOne (mappedBy = "student_id", fetch = FetchType.LAZY) e) @ManyToOne(mappedBy = "student", fetch = FetchType.LAZY) Question 8 1 / 1 point Assuming the table and code below are correct. Answer the question on University class? --------------- | university | --------------- | univ_id INT | --------------- @MappedSuperclass abstract class PojoBase { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) protected int id; } @Entity @Table(name = "university") // Do we need any other annotation here? public class University extends PojoBase { ... } a) Yes, the other annotation should be: @AssociationOverride(name = "id", column = @Column(name = "univ_id")) b) Yes, the other annotation should be: @AttributeOverride(name = "id", column = @Column(name = "univ_id")) c) No, the code is complete.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
d) Yes, the other annotation should be: @AttributeOverride(column = @Column(name = "univ_id")) Question 9 1 / 1 point What does mappedBy mean? Please read: @interface OneToMany @OneToMany(mappedBy = "owningEmployee", cascade = CascadeType.ALL, orphanRemoval = true) a) No such field exists. b) Name of the column in the other table which owns the relationship. c) The field is in the other entity which owns the relationship. d) Name of the column in the current entity. Done
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Quiz 07 - REST - Results Attempt 1 of 1 Written Jul 16, 2023 10:01 PM - Jul 16, 2023 10:05 PM Released Jul 17, 2023 8:00 AM Attempt Score 7 / 7 - A+ Overall Grade (Highest Attempt) 7 / 7 - A+ Question 1 1 / 1 point Select the statement/statements below that is/are true regarding REST? a) Every resource has a URL. b) Any request that doesn't have side effects should use GET. c) All interactions are stateless. d) A URL is not 'opaque' - implementation details are exposed. Question 2 1 / 1 point Connect each HTTP method to its CRUD behaviour. __1__ Create __5__ Partial Update 1 . POST 2 . GET
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
__3__ Update __2__ Read __4__ Delete 3 . PUT 4 . DELETE 5 . PATCH Question 3 1 / 1 point The purpose of the annotation @Path("/hello") is to define a relative path for a resource called "hello" placed on a class. a) True b) False Question 4 1 / 1 point The main config class for a REST application needs to extend what class? Hint: Please refer to the REST-Demo project discussed in the lecture. a) @ApplicationPath("/api/v1") b) java.io.Serializable c) javax.ws.rs.core.Application d) javafx.application.Application Question 5 1 / 1 point Given the resource path below, match the HTTP method to its operation? "{}" is just a placeholder. /persons/{person_id}/addresses __1__ POST 1 . Create a new address
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
__2__ GET __3__ PUT 2 . Read all addresses 3 . Update an address Question 6 1 / 1 point What is the purpose of the annotation @ApplicationPath("/api/v1") ? a) It filters all paths that contain "/api/v1" . b) It provides access to resource v1 . c) The application path that serves as the base URI for all resources. Question 7 1 / 1 point Match the HTTP status codes below to their description. __3__ Redirection __4__ Client Error __2__ Success __1__ Informational __5__ Server Error 1 . 1xx 2 . 2xx 3 . 3xx 4 . 4xx 5 . 5xx Done
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Quiz 08 - Security - Results Attempt 1 of 1 Written Jul 23, 2023 11:21 PM - Jul 23, 2023 11:24 PM Released Jul 24, 2023 8:00 AM Attempt Score 10 / 10 - A+ Overall Grade (Highest Attempt) 10 / 10 - A+ Question 1 1 / 1 point Given only one IdentityStore is needed through the lifetime of a web app. What scope should be used? a) @ConversationScope b) @ApplicationScoped c) @RequestScope d) @SessionScope Question 2 1 / 1 point The scope of the authentication config class should be @ApplicationScoped as this authentication will persist as long as the application is running.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
a) True b) False Question 3 1 / 1 point Where does @BasicAuthenticationMechanismDefinition store the username and password? a) HTTP header b) HTTP body Question 4 1 / 1 point A better way to store password on the DB is to add salt to the password before hashing. Salting means to append a random string (or value) to your password. This way guaranteeing a unique hash code even for identical passwords. Each password should have its own unique salt which is usually stored on the DB with the hashed password. a) True b) False Question 5 1 / 1 point What is the job of the IdentityStore? a) None of the other answers. b) Stores all the users with their passwords in the Java application. c) Validates the given credential against the database (ideally). d) Use to purchase new credential if none is available! Question 6 1 / 1 point All usernames and passwords should be stored inside of IdentityStore Java source code file instead of the DB. This way extra queries will not be made to the DB.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
a) True b) False Question 7 1 / 1 point What is the default name of username input field in @FormAuthenticationMechanismDefinition? a) Anything is possible. b) j-username c) j_username d) username Question 8 1 / 1 point Hashing of passwords before storing them to the DB is just used to guarantee that all passwords are unique. a) True b) False Question 9 1 / 1 point How is the password stored in the HTTP header of a Basic Authentication Mechanism system? a) Username and password are concatenated together with a semicolon in middle. b) Username and password are concatenated together with a colon in middle. c) Username and password are concatenated. d) Username and password are concatenated together with a space in middle.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Question 10 1 / 1 point What is the default name of password input field in @FormAuthenticationMechanismDefinition? a) j-password b) Anything is possible. c) j_password d) password Done
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Quiz 09 - REST Demo - Results Attempt 1 of 1 Written Jul 30, 2023 10:01 PM - Jul 30, 2023 10:13 PM Released Jul 31, 2023 8:00 AM Attempt Score 7.67 / 10 - B+ Overall Grade (Highest Attempt) 7.67 / 10 - B+ Question 1 1 / 1 point Annotation @Path can be placed on what? a) Method b) Variables or fields c) Class Question 2 1 / 1 point The annotations: @Produces( MediaType.APPLICATION_JSON) @Consumes( MediaType.APPLICATION_JSON) will let the system know you are planning to use JSON for your method. They must only be placed on each appropriate methods. a) True
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
b) False Question 3 1 / 1 point Which annotation is needed to define the main path of your REST application? a) @ApplicationPath placed on main class which extends the Application class. b) @Path placed on every resource class. c) @ApplicationPath placed on every resource class. d) @Path placed on main class which extends the Application class. Question 4 0.667 / 1 point What is/are true regarding MessageHolder ? Correct Answer Incorrect Response a) Instance of MessageHolder is the message that will be sent back to client in JSON format. Correct Answer b) The internal variables/methods inside MessageHolder represent what the final JSON will look like. Correct Answer c) Names provided on the getters will affect the final names of JSON fields.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Incorrect Response d) MessageHolder must always have string theMessage and LocalDateTime date . Question 5 0 / 1 point The class MessageHolder must always be created with the exact variables below: protected String theMessage; protected LocalDateTime date; Incorrect Response a) True Correct Answer b) False Question 6 0 / 1 point The annotation @RolesAllowed must be used on a method to define roles that can access it. It cannot be replaced or used in conjunction with programmatic role setup. Incorrect Response a) True Correct Answer b) False Question 7 1 / 1 point Which annotation is needed to define the path of a resource? (Not sub paths) a) @Path placed on the class. b) @ApplicationPath on every method. c) @ApplicationPath on the class. d) @Path placed on every method.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Question 8 1 / 1 point When defining a sub resource like below: @GET @Path("{resourceId}") public Response getForSpecificResource(int id) { /*some code*/ } What annotation is missing? a) Nothing b) @PathParam("resourceId") Question 9 1 / 1 point This is the primary class of a REST application. What is missing? public class RestMain { public Map<String, Object> getProperties() { } } a) implements jakarta.ws.rs.core.Application b) extends javax.ws.rs.core.Application c) No extends is needed. d) extends javafx.application.Application Question 10 1 / 1 point In what class do we need to add @DeclareRoles to declare the roles we will use in our REST application?
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
a) It must only be placed in web.xml . b) @DeclareRoles can be placed anywhere. c) Main class that extends the Application class. Done
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Quiz 10 - REST - Results Attempt 1 of 1 Written Aug 6, 2023 9:11 PM - Aug 6, 2023 9:23 PM Released Aug 7, 2023 8:00 AM Attempt Score 4 / 7 - D+ Overall Grade (Highest Attempt) 4 / 7 - D+ Question 1 0 / 1 point The left diagram below shows three JPA model classes: Entity 'A' has a 1:1 relationship to Entity 'B' and a 1:M relationship to Entity 'C'. The right diagram shows the database tables followed by some example data:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
A_TABLE B_TABLE C_TABLE A_ID|NAME|CURRENT_VALUE|B_ID| |B_ID|NAME| |C_ID|NAME|OWNING_A_ID| ----|----|-------------|----| |----|----| |----|----|-----------| 1 |John| 12443.00 | 2 | | 1 | n1 | | 1|x1 | 1| 2 |Jane| 1.00 | 1 | | 2 | n2 | | 2|y1 | 2| 3 |Xi | 6697.55 | 3 | | 3 | m3 | | 3|z1 | 1| | 4|q | 2| Which JPQL query retrieves the 'A' entities whose value is above the average value? Correct Answer a) SELECT a FROM EntityA a WHERE a.currentValue > (SELECT AVG(a2.currentValue) FROM EntityA a2) b) SELECT AVG(a.currentValue) FROM EntityA a where (SELECT count(a2) FROM EntityA a2)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Incorrect Response c) SELECT AVG(a.currentValue) FROM EntityA a d) SELECT a FROM EntityA a WHERE a.currentValue > AVG(a.currentValue) Question 2 1 / 1 point The left diagram below shows three JPA model classes: Entity 'A' has a 1:1 relationship to Entity 'B' and a 1:M relationship to Entity 'C'. The right diagram shows the database tables followed by some example data: A_TABLE B_TABLE C_TABLE A_ID|NAME|CURRENT_VALUE|B_ID| |B_ID|NAME| |C_ID|NAME|OWNING_A_ID| ----|----|-------------|----| |----|----| |----|----|-----------| 1 |John| 12443.00 | 2 | | 1 | n1 | | 1|x1 | 1|
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
2 |Jane| 1.00 | 1 | | 2 | n2 | | 2|y1 | 2| 3 |Xi | 6697.55 | 3 | | 3 | m3 | | 3|z1 | 1| | 4|q | 2| Which JPQL query retrieves the 'A' entities whose 'B' entities' name starts with the letter 'n'? https://www.objectdb.com/java/jpa/query/jpql/string a) SELECT a FROM EntityA a WHERE a.entityB.name like 'n%' b) SELECT a FROM EntityB a WHERE a.name like 'n%' c) SELECT a FROM EntityA a WHERE a.entityB.name like '_n%' d) SELECT a FROM entityA a WHERE a.entityB.name like 'n%' Question 3 1 / 1 point The left diagram below shows three JPA model classes: Entity 'A' has a 1:1 relationship to Entity 'B' and a 1:M relationship to Entity 'C'. The right diagram shows the database tables followed by some example data:
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
A_TABLE B_TABLE C_TABLE A_ID|NAME|CURRENT_VALUE|B_ID| |B_ID|NAME| |C_ID|NAME|OWNING_A_ID| ----|----|-------------|----| |----|----| |----|----|-----------| 1 |John| 12443.00 | 2 | | 1 | n1 | | 1|x1 | 1| 2 |Jane| 1.00 | 1 | | 2 | n2 | | 2|y1 | 2| 3 |Xi | 6697.55 | 3 | | 3 | m3 | | 3|z1 | 1| | 4|q | 2| Which JPQL query counts the number of 'A' Entities with no 'C's ? https://www.objectdb.com/java/jpa/query/jpql/collection a) SELECT COUNT(a) FROM EntityA a WHERE a.entityCs is empty b) SELECT COUNT(a) FROM EntityA a WHERE a.entityCs is null
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
c) SELECT COUNT(a) FROM EntityA a WHERE a.entityCs is not empty d) SELECT COUNT(a) FROM entityA a WHERE a.entityCs is empty Question 4 1 / 1 point The left diagram below shows three JPA model classes: Entity 'A' has a 1:1 relationship to Entity 'B' and a 1:M relationship to Entity 'C'. The right diagram shows the database tables followed by some example data: A_TABLE B_TABLE C_TABLE A_ID|NAME|CURRENT_VALUE|B_ID| |B_ID|NAME| |C_ID|NAME|OWNING_A_ID| ----|----|-------------|----| |----|----| |----|----|-----------| 1 |John| 12443.00 | 2 | | 1 | n1 | | 1|x1 | 1| 2 |Jane| 1.00 | 1 | | 2 | n2 | | 2|y1 | 2|
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
3 |Xi | 6697.55 | 3 | | 3 | m3 | | 3|z1 | 1| | 4|q | 2| Which JPQL query retrieves the 'A' entities with 'C's name the ends with the number '1' ? https://www.objectdb.com/java/jpa/query/jpql/collection a) SELECT a FROM EntityA a JOIN a.entityCs c WHERE c.name like '1%' b) SELECT DISTINCT a FROM EntityA a JOIN a.entityCs c WHERE c.name like '_1%' c) SELECT DISTINCT a FROM EntityA a JOIN a.entityCs c WHERE c.name like '%1' d) SELECT a FROM EntityA a JOIN a.entityCs c WHERE c.name like '%1' Question 5 0 / 1 point
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
A_TABLE B_TABLE C_TABLE A_ID|NAME|CURRENT_VALUE|B_ID| |B_ID|NAME| |C_ID|NAME|OWNING_A_ID| ----|----|-------------|----| |----|----| |----|----|-----------| 1 |John| 12443.00 | 2 | | 1 | n1 | | 1|x1 | 1| 2 |Jane| 1.00 | 1 | | 2 | n2 | | 2|y1 | 2| 3 |Xi | 6697.55 | 3 | | 3 | m3 | | 3|z1 | 1| | 4|q | 2| If GET /a/{id} is sent for id=2, what is the HTTP return code and the JSON returned? Assume fetch types are eager. Correct Answer a) { "aId": 2, "name": "Jane", "currentValue": 1.00,
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
"entityB": { "bId": "1", "name": "n1" }, "entityCs": [ { "cId": 2, "name": "y1" }, { "cId": 4, "name": "q" } ] } b) { "aId": 2, "name": "Jane", "currentValue": 1.00 } Correct Answer Incorrect Response c) HTTP Response: 200 d) HTTP Response: 404 Question 6 0 / 1 point
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
A_TABLE B_TABLE C_TABLE A_ID|NAME|CURRENT_VALUE|B_ID| |B_ID|NAME| |C_ID|NAME|OWNING_A_ID| ----|----|-------------|----| |----|----| |----|----|-----------| 1 |John| 12443.00 | 2 | | 1 | n1 | | 1|x1 | 1| 2 |Jane| 1.00 | 1 | | 2 | n2 | | 2|y1 | 2| 3 |Xi | 6697.55 | 3 | | 3 | m3 | | 3|z1 | 1| | 4|q | 2| If GET /a/{id} is sent for id=4, what is the HTTP return code and the JSON returned? assume fetch types are Eager. a) HTTP Response: 200
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Correct Answer Incorrect Response b) HTTP Response: 404 Correct Answer c) { "status-code": 404, "reason-phrase": "Not found"} d) { "cId": 4, "name": "q" } Question 7 1 / 1 point
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
A_TABLE B_TABLE C_TABLE A_ID|NAME|CURRENT_VALUE|B_ID| |B_ID|NAME| |C_ID|NAME|OWNING_A_ID| ----|----|-------------|----| |----|----| |----|----|-----------| 1 |John| 12443.00 | 2 | | 1 | n1 | | 1|x1 | 1| 2 |Jane| 1.00 | 1 | | 2 | n2 | | 2|y1 | 2| 3 |Xi | 6697.55 | 3 | | 3 | m3 | | 3|z1 | 1| | 4|q | 2| If we want to add a C to an existing A what should be the path of the resource? a) PUT /a/{id}/c b) PUT /c/{id}/a
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
c) POST /c/{id}/a d) POST /a/c/{id} Done
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help