GSSP-Java practice questions, page 6 of 11, with answer review and explanations.
Question 26
Which of the following statements are true about object serialization? Each correct answer represents a complete solution. Choose all that apply.
After deserialization, objects have the same state as it had when it was serialized.
It uses ObjectOutputStream to deserialize objects.
It uses the ObjectInput and ObjectOutput interfaces.
An object will have the same state at deserialization as it had at the time it was serialized if all its superclasses are also serializable.
Question 27
Which of the following methods of the HttpServletResponse interface is used for URL rewriting? Each correct answer represents a complete solution. Choose all that apply.
encodeURL
encodeRedirectURL
sendRedirect
getRequestURL()
Question 28
You work as a Software Developer for NewTech Inc. You write a bean class using Enterprise JavaBeans 3.0. The class uses the @DeclareRoles ("ADMIN, HR, DBA, USER") annotation to declare the security roles. The class contains a method named showResult(). You want to ensure that the ADMIN role is granted privilege to the showResult() method. Moreover, if a role that is not allowed to access the method tries to call the method, an error message must be shown. Assuming that there is no security-related element in the deployment descriptor, which of the following will you use to accomplish the task? Each correct answer represents a part of the solution. Choose two.
The isCallerInRole() method
The getCallerPrincipal() method
The @RolesAllowed("ADMIN") annotation
The @PermitAll annotation
Question 29
Which of the following statements about the String, StringBuffer, and StringBuilder classes are true? Each correct answer represents a complete solution. Choose all that apply.
The StringBuffer class offers faster performance than the StringBuilder class.
The StringBuffer class is thread-safe while the StringBuilder class is not.
A character in a string can be searched using the indexOf() operator.
The return type of the trim() method present in the String class is void.
Question 30
Which of the following listeners causes an object of the implementing class to be notified when it is added to or removed from a session?