Menu
Question Index
...

What will be the output of following program?

import java.util.Formatter;

public class FormateExample {
    public static void main(String[] args) {
        String name = "javA";
        double input = 20.79;
        Formatter f = new Formatter();;
        for (int i = 0; i < name.length(); i++) {
            f.format("%S ", name.charAt(i), (int) name.charAt(i));
        }
        System.out.print(f);
    }
}


j 106 a 97 v 118 A 65
J  A  V  A
j a v A
java.util.IllegalFormatConversionException
Some other Output
Compilation Error or Runtime Error other Output

Doubts

Problems

Topic: Java Formatter

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App