Menu
Topics Index
...
`

Formatting input2632


If you need explanation Read this topic

If you need Answer Take test on this topic

Formatting input2632
What will be the output of the following program?
import java.util.*;
public class Formatting {
    public static void main(String[] args) {
        double input = 20.52;
        Formatter f = new Formatter();
        f.format("%d ", input);
        System.out.println(f);
        f.format("%f", input);
        System.out.println(f);
    }
}

A. 20 
20 20.520000
B. 20.52
20.52 20.520000
C. 20.520000 
20.520000 20.520000
D. Compilation Error
E. Runtime Error
Topic: Java Formatting Numbers

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans E input is double and we trying to convert it into Int n float so . illegaargsmentexception

Posted by Uday Kumar    2014-07-01 03:50:55


A

Posted by Rathod Ajay    2014-07-01 04:44:47


Ans is A...first the int part of f is printed..and then float value is printed

Posted by Badam Swathi    2014-07-01 06:50:55


ans is B

Posted by Shashi Kumar    2014-07-01 07:45:20


Congratulations Uday Kumar. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-07-02 04:19:53


© meritcampus 2019

All Rights Reserved.

Open In App