Question No: 21 – (Topic 1)

Which of the following statements is true about the Java synchronized keyword?

It prevents multiple threads from accessing a block of code at the same time.

It allows the class to be loaded as soon as the JRE starts.

It prevents multiple developers from code redundancy.

It allows two different functions to execute in a shared manner.

Answer: A

Question No: 22 – (Topic 1)

Mark works as a Programmer for InfoTech Inc. He develops a Web application that takes input from users. Which of the following methods can be used by the client and server to validate the users input?

Each correct answer represents a complete solution. Choose all that apply.

Validation through Servlets on the server side

Validation using JavaScript on the client side

Validation through Java Applets on the client side

Validation through XML on the server side

Answer: A,B

Question No: 23 – (Topic 1)

Which of the following are marker interfaces?

Each correct answer represents a complete solution. Choose all that apply.

The Clonable interface

The Serializable interface

The Comparable interface

The Runnable interface

Answer: A,B

Question No: 24 – (Topic 1)

Which of the following rules must be followed while determining a class loader? Each correct answer represents a complete solution. Choose all that apply.

A new instance of the AppletClassLoader is used while loading the first class of an applet.

If the request to load a class is triggered by a reference to it from an existing class, the class loader for the existing class is asked to load the class.

A new instance of the URLClassLoader is used while loading the first class of an application.

The primordial class loader is used if java.lang.Class.ForName is directly called.

Answer: A,B,C,D

Question No: 25 – (Topic 1)

Mark works as a Programmer for InfoTech Inc. He wants to develop a JMS API application that is used as a messaging service application. He writes the following createSession() method.

session = connection.createSession(false, 2);

Which of the following statements are true about the syntax?

Each correct answer represents a complete solution. Choose all that apply.

The client acknowledges a consumed message by calling the message#39;s acknowledge method.

The acknowledge method can reduce session overhead by minimizing the work the session does to prevent duplicates.

This method instructs the session to lazily acknowledge the delivery of messages.

The session automatically acknowledges a client#39;s receipt of a message.

If a message consumer consumes eight messages and then acknowledges the fourth message delivered, all eight messages are acknowledged.

Answer: A,E

Question No: 26 – (Topic 1)

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.

Answer: A,C,D

Question No: 27 – (Topic 1)

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()

Answer: A,B

Question No: 28 – (Topic 1)

You work as a Software Developer for NewTech Inc. You write a bean class using Enterprise

JavaBeans 3.0. The class uses the @DeclareRoles (quot;ADMIN, HR, DBA, USERquot;) 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(quot;ADMINquot;) annotation

The @PermitAll annotation

Answer: A,C

Question No: 29 – (Topic 1)

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.

Answer: B,C

Question No: 30 – (Topic 1)

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?