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.
Loadthe date string in an instance Date type variablebyannotation of the instance variable and
let the container autoconvert it to a Datetypeautomatically.

B.
Load thedate string in an instance String type variablebyannotation of this instance
variableandconvertitto aDatetype object in the beans constructor.

C.
Load thedatestringinaninstanceString typevariableby annotationof this instance variable and
convert it to aDate typeobjectin a@PostConstructannotatedmethod.

D.
Load the date string in an instance Date typevariableby annotation ofasetter method that takes
a String and which carries out the conversion and assigns the value totheinstance variable.



Leave a Reply 0

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