Question 6 of 63

Given the code fragment:

Which code can be added to register both of these methods to receive BankEvent notifications only if an instance of BankActivityService is already instantiated in the current context?

    Correct Answer: D

    To register methods to receive notifications only if an instance of BankActivityService is already instantiated in the current context, you must use the @Observes annotation with the notifyObserver parameter set to IF_EXISTS before the method parameter declaration. This ensures that the methods are only invoked if the observer instance is already available. Therefore, the correct code is @Observes(notifyObserver=IF_EXISTS) on line 4 and line 7 before the method parameter declaration.

Question 7 of 63

Which code snippet prints the exception error message as part of the page output?

    Correct Answer: A

    To print the exception error message as part of the page output, you can use JSP expressions. The option '<%= exception.message %>' directly embeds the exception's message into the HTML content, making it suitable for displaying the message on the page. Other options like '<c:out value="${requestScope["˜javax.servlet.error.exception"]}"/>' do not directly access the exception message, and '<% exception.getMessage(); %>' or '<% System.out.println(e.getMessage()) %>' are either incorrect syntax or would print to the system console instead of the page.

Question 8 of 63

Java EE's support for WS-Security includes handling which two types of security credentials? (Choose two.)

    Correct Answer: A, B

    Java EE's support for WS-Security includes handling X.509 certificates and SAML tokens. X.509 certificates are widely used digital certificates that help validate the identity of the parties involved and establish a secure communication channel. SAML (Security Assertion Markup Language) tokens are used for exchanging authentication and authorization data between security domains, commonly in a web-based environment. Both X.509 certificates and SAML tokens are standard security credentials supported by WS-Security in Java EE.

Question 9 of 63

Given the code fragment from a Facelet page:

On Line 1, you ae asked to insert a search box that displays the text "Search Here" via a placeholder.

Assume searchMB is a valid Managed Bean.

Which two options enable you to create a search box with a placeholder attribute on Line 1? (Choose two.)

    Correct Answer: C, D

    To create a search box with a placeholder attribute in a JSF (JavaServer Faces) application, we need to ensure that the code properly adheres to the JSF syntax and specifications. Therefore, options C and D are correct. Option C uses the `jsf:id` attribute along with the placeholder and value attributes correctly. Option D utilizes the `pt:placeholder` attribute, which is part of the pass-through attributes in JSF 2.2 and later, and correctly binds the value to the managed bean. Other options either misuse JSF syntax or attributes.

Question 10 of 63

Given the code fragment:

Which method should be used on line 3 to enable default validation mechanism?

    Correct Answer: B

    To enable the default validation mechanism in JAXB, you should use the setSchema method. The setValidating method is deprecated, and using setEventHandler is for handling validation events but does not enable the default validation mechanism. Therefore, the correct method to use is setSchema(Schema).