GSSP-Java

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.

  1. After deserialization, objects have the same state as it had when it was serialized.
  2. It uses ObjectOutputStream to deserialize objects.
  3. It uses the ObjectInput and ObjectOutput interfaces.
  4. 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.

  1. encodeURL
  2. encodeRedirectURL
  3. sendRedirect
  4. 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.

  1. The isCallerInRole() method
  2. The getCallerPrincipal() method
  3. The @RolesAllowed("ADMIN") annotation
  4. 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.

  1. The StringBuffer class offers faster performance than the StringBuilder class.
  2. The StringBuffer class is thread-safe while the StringBuilder class is not.
  3. A character in a string can be searched using the indexOf() operator.
  4. 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?

  1. HttpSessionListener
  2. HttpSessionActivationListener
  3. HttpSessionAttributeListener
  4. HttpSessionBindingListener