Menu
Topics Index
...
`

Formatting input


If you need explanation Read this topic

If you need Answer Take test on this topic

Formatting input
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 ", (int) input);
        System.out.println(f);
        f.format("%f", input);
        System.out.println(f);
    }
}

A. 20 
20 20.520000
B. 20
20 20.52
C. Compilation Error
D. 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.

option is a..

Posted by Vijay Kumar    2014-06-04 13:13:47


ans a. 1st ouoput type casting usd n prints 20,
2nd prints 2 values f.format containd typecastd value and float value of i ..by default decimal points prints 6 digits aft the point

Posted by Maheshwari Natarajan    2014-06-04 13:18:37


No winner for this dose. Correct option is 'A' :(. Maheshwari Natarajan was already won in this week.

Posted by Merit Campus    2014-06-05 04:12:17


© meritcampus 2019

All Rights Reserved.

Open In App