Consider a scenario where you are required to store a large number of decimal values with high precision for a financial application. Which data type would be preferable and why?
- BigDecimal
- double
- float
- long
In a financial application, precision is crucial. The double data type can store decimal values but may not provide the necessary precision due to its limited number of significant digits. BigDecimal is preferred in such scenarios because it offers arbitrary precision and is ideal for financial calculations where rounding errors need to be minimized. float and long do not provide the required precision for financial calculations.
Loading...
Related Quiz
- Which method is used to submit a task for execution to the ExecutorService and returns a Future object?
- Which method can be used to temporarily pause the execution of a thread for a specified time?
- The InetAddress class provides methods to get the IP address of a local computer by using method ________.
- If we have a 2D array int[][] arr, the expression arr[i] refers to the __________.
- Consider a scenario where you need to sort a list of employees based on their age and then return the first employee’s name. How would you achieve this using Stream API?