What will the following print when compiled and run?
public class Main { public static void main(String[] args) { Double[] dArray = {10.987, -100.678, 1000.345}; System.out.format("|"); for (int i = 0; i < dArray.length; i++) { System.out.format("%(,+-" + (i+1) + "." + (i+1) + "f|", dArray[i]); } } }
Select the one correct answer.
(c)
The program will use the following formats %(,+-1.1, %(,+-2.2, and %(,+-3.3 to print the values in the array dArray
.
The flag '(' results in negative values being enclosed in ().
The flag ',' specifies that the locale-specific grouping character should be used.
The flag '+' specifies that positive values should be prefixed with the + sign.
The flag '-' specifies that values should be printed left-justified.
The width is less than the required width, and therefore overridden.
The precision can result in rounding, as is the case for the first two values.