1.
Which of the following statements about the fetch modes in Entity beans is FALSE?
Correct Answer
C. The default fetching mode for a field in an Entity bean annotated by @Basic is LAZY.
Explanation
The default fetching mode for a field in an Entity bean annotated by @Basic is not LAZY.
2.
What is TRUE about the cascading and cascade mode attributes in Entity Beans?
Correct Answer(s)
A. Cascade mode attributes can be specified for the association annotaions (like @OneToMany) in an entity bean.
D. Refresh cascade causes to refresh the target entities of a relationship when refresh is invoked on the source entity of the relationship
Explanation
Cascade mode attributes can be used to specify the cascading behavior for association annotations in an entity bean, such as @OneToMany. This means that when certain operations are performed on the source entity, such as persisting, deleting, or refreshing, the same operations will be cascaded to the target entities of the relationship. In this case, the refresh cascade mode attribute specifically causes the target entities to be refreshed when the refresh operation is invoked on the source entity of the relationship.
3.
How to declare JPA Entity class?
Correct Answer(s)
B. Annotate the class with @Entity
C. Annotate the primary key attribute or its getter method with @Id
D. Define private attributes to map the table columns.
Explanation
The correct answer is to annotate the class with @Entity, annotate the primary key attribute or its getter method with @Id, and define private attributes to map the table columns. This is the standard way to declare a JPA Entity class. The @Entity annotation marks the class as an entity that will be mapped to a database table. The @Id annotation is used to indicate the primary key attribute of the entity. Private attributes are used to map the columns of the table.
4.
What is the impact of marking an attribute in a JPA Entity class with @Transient annotation?
Correct Answer
B. This attribute will should not be persisted by the EJB container.
Explanation
By marking an attribute in a JPA Entity class with the @Transient annotation, it indicates that the attribute should not be persisted by the EJB container. This means that the attribute will not be stored in the database when the entity is saved or updated. This can be useful when there are certain attributes that are not relevant to be stored in the database or when they are derived from other attributes and can be calculated on the fly.
5.
In which life cycle state the JPA entity class is synchronized with the database?
Correct Answer
B. Managed
Explanation
The JPA entity class is synchronized with the database in the "Managed" life cycle state. In this state, the entity is being managed by the persistence context, and any changes made to the entity will be automatically synchronized with the database when the transaction is committed.
6.
What causes the entity manager to move an Entity instance from the detached to the managed state?
Correct Answer
B. Invoke the merge() method of the entity manager on the instance
Explanation
When the merge() method of the entity manager is invoked on an Entity instance, it causes the entity manager to move the instance from the detached state to the managed state. This means that the entity instance becomes associated with the persistence context of the entity manager and any changes made to the instance will be tracked and synchronized with the database when the transaction is committed. The merge() method is typically used when you want to update an existing entity with new data from a detached instance.
7.
Which of the following is NOT a JPA entity manager method?
Correct Answer
D. Detach
Explanation
The "Detach" method is not a JPA entity manager method. JPA entity manager provides methods like "Persist" to persist an entity, "Flush" to synchronize the changes to the database, "Contains" to check if an entity is managed, and "Find" to retrieve an entity by its primary key. However, "Detach" is not a valid JPA entity manager method.
8.
Which method of the jpa entity manager would you use to force synchronizing the persistence context from the database?
Correct Answer
C. Refresh
Explanation
The refresh method of the JPA entity manager is used to force synchronizing the persistence context from the database. This method retrieves the latest state of an entity from the database and updates the corresponding entity object in the persistence context. It is useful when there is a need to reload the entity with the most up-to-date data from the database, discarding any changes made to the entity in the persistence context.
9.
Which method of the jpa entity manager would you use to force synchronizing the database with the entities of the persistence context?
Correct Answer
B. Flush
Explanation
The flush method of the JPA entity manager is used to force synchronizing the database with the entities of the persistence context. It ensures that all pending changes to the entities are written to the database immediately. This is useful when you want to make sure that any changes made to the entities are persisted in the database before performing any further operations.
10.
In the web services world, the REST (REpresentational State Transfer) is:
Correct Answer
B. A software architectural paradigm
Explanation
The REST (REpresentational State Transfer) is a software architectural paradigm. It is a design approach for building scalable and loosely coupled web services. RESTful systems use HTTP as the main communication protocol and follow a set of principles and constraints to enable interoperability and simplicity. This architectural style emphasizes stateless communication, resource-oriented design, and the use of standard HTTP methods (GET, POST, PUT, DELETE) for manipulating resources. It is widely used in modern web development for creating APIs that can be easily consumed by different clients.
11.
In a RESTful web service, you would use the HTTP methods as verbs to invoke the CRUD action (create, read, update, and delete) Which of the following is true:
Correct Answer(s)
A. To read use HTTP get method.
B. To delete use HTTP delete method.
Explanation
In a RESTful web service, the HTTP methods are used as verbs to invoke the CRUD actions. The correct answer states that to read data, the HTTP GET method should be used, and to delete data, the HTTP DELETE method should be used. This aligns with the standard conventions of RESTful architecture, where GET is used for retrieving data and DELETE is used for removing data.
12.
When is it most appropriate to architect your enterprise java application using SOAP protocol web services over RESTful?
Correct Answer(s)
B. When the web service interface must be predefined in a concrete contract.
D. When asynchronous invocation is required.
Explanation
SOAP protocol web services are most appropriate when the web service interface must be predefined in a concrete contract and when asynchronous invocation is required. SOAP allows for the definition of a strict interface between the client and server, ensuring that both parties understand the structure and format of the data being exchanged. This is useful when the application requires a predefined and standardized interface. Additionally, SOAP supports asynchronous invocation, allowing the client to send a request and continue with other tasks without waiting for a response. This is beneficial when the application needs to perform multiple tasks simultaneously or when there is a need for non-blocking communication.
13.
Web Services are the amalgamation of:
Correct Answer
B. SOAP, UDDI, WSDL
Explanation
Web services are a combination of SOAP, UDDI, and WSDL. SOAP (Simple Object Access Protocol) is a messaging protocol used for exchanging structured information in web services. UDDI (Universal Description, Discovery, and Integration) is a directory service that allows businesses to publish and discover web services. WSDL (Web Services Description Language) is an XML-based language used to describe the interface and functionality of a web service. Together, these three technologies form the foundation of web services, enabling communication, discovery, and description of services over the internet.
14.
Service Transport, XML MEssaging, Service Description and Service Discovery are four layers of:
Correct Answer
B. Web service protocol stack
Explanation
The four layers mentioned - Service Transport, XML Messaging, Service Description, and Service Discovery - are part of the Web service protocol stack. These layers work together to enable communication and interaction between different components of a Web service. The Service Transport layer handles the transportation of messages, the XML Messaging layer deals with the formatting and encoding of messages in XML, the Service Description layer provides information about the Web service, and the Service Discovery layer helps in discovering and locating available Web services. Together, these layers form the protocol stack that facilitates the functioning of Web services.
15.
Which of the following is used to describe web services?
Correct Answer
D. WSDL
Explanation
WSDL (Web Services Description Language) is used to describe web services. It is an XML-based language that provides a standardized way to describe the functionalities and operations of a web service. WSDL defines the endpoints, input/output parameters, message formats, and communication protocols for a web service, allowing clients to understand how to interact with the service.
16.
Web Services enables...
Correct Answer
D. All of the above
Explanation
Web services enable data to be exchanged between various applications and different platforms, allowing for interoperability between systems. This means that applications can function between two different operating systems servers. Therefore, the correct answer is "All of the above".
17.
In accessing a web service through synchronous call,
Correct Answer
C. Application has to wait until execution is completed.
Explanation
In accessing a web service through synchronous call, the application has to wait until execution is completed. This means that the application will make a call to the web service and then pause its execution until it receives a response from the service. Once the execution is completed, the application can continue to perform the needed task using the received response. This ensures that the application does not proceed with its task until it has obtained the necessary data from the web service.
18.
Difference between RESTfull web services and SOAP web services
Correct Answer
D. All of the above.
Explanation
The correct answer is "All of the above." This is because all three statements are true and highlight the key differences between RESTful web services and SOAP web services. REST is indeed simpler and easier to use compared to SOAP. REST utilizes the HTTP protocol for producing or consuming web services, while SOAP relies on XML. Additionally, REST is considered lightweight in comparison to SOAP.
19.
What is difference between top-down and bottom-up approach of developing web services?
Correct Answer
C. Both a and b.
Explanation
The correct answer is both a and b. In the top-down approach, the first step is to create the WSDL (Web Services Description Language) document, which defines the structure and functionality of the web service. After that, Java classes are generated based on the WSDL document. On the other hand, in the bottom-up approach, Java code is written first to implement the desired functionality of the web service. Then, WSDL fields are automatically generated based on the implemented code. Both approaches have their advantages and disadvantages, and the choice between them depends on the specific requirements and constraints of the project.
20.
EclipseLink, TopLink, and Hybernarte are implementations of:
Correct Answer
C. JPA
Explanation
EclipseLink, TopLink, and Hibernate are all implementations of JPA (Java Persistence API). JPA is a specification that defines a standard way to map Java objects to relational databases, allowing developers to interact with databases using object-oriented approaches rather than writing SQL queries. These implementations provide the necessary tools and libraries to work with JPA and handle the persistence of Java objects in a database.