SCJP Module-12 Question-1


 

SCJP Module-12 Question-1

The Sample program given below will test your knowledge about the NumberFormat class of Java.

The Sample program given below will test your knowledge about the NumberFormat class of Java.

Given below the sample code :

NumberFormat nform = NumberFormat.getInstance();
nform.setMaximumFractionDigits(4);
nform.setMinimumFractionDigits(2);
String i = nform.format(3.1415926);
String j = nform.format(3);

Here, the default locale is Locale.US, Which statement is true about the output of the above code ?

1. value of i = 3.141

2. value of i = 3.1415

3. value of j = 3.00

4. value of i = 3.1416

Answer

(3) & (4)

Ads