Which two scenarios can be used to prevent converting from String to Date in every business method?

A developer writes a session bean which uses several configurable constants. The constants are
all defined as String types in JNDI. This cannot be changed because existing code is using the
same JNDI information. One of the constants is a date, represented in string format. This date
constant is used in multiple business methods of this session bean, actually as a Date object.
Converting strings to dates is an expensive operation; therefore, the developer wants to do as little
converting as possible.
Which two scenarios can be used to prevent converting from String to Date in every business
method? (Choose two.)

A developer writes a session bean which uses several configurable constants. The constants are
all defined as String types in JNDI. This cannot be changed because existing code is using the
same JNDI information. One of the constants is a date, represented in string format. This date
constant is used in multiple business methods of this session bean, actually as a Date object.
Converting strings to dates is an expensive operation; therefore, the developer wants to do as little
converting as possible.
Which two scenarios can be used to prevent converting from String to Date in every business
method? (Choose two.)

A.
Load the date string in an instance Date type variable by annotation of the instance variable
and let the container autoconvert it to a Date type automatically.

B.
Load the date string in an instance String type variable by annotation of this instance variable
and convert it to a Date type object in the beans constructor.

C.
Load the date string in an instance String type variable by annotation of this instance variable
and convert it to a Date type object in a @PostConstruct annotated method.

D.
Load the date string in an instance Date type variable by annotation of a setter method that
takes a String and which carries out the conversion and assigns the value to the instance variable.



Leave a Reply 0

Your email address will not be published. Required fields are marked *