Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class CharTest {
    public static void main(String[] args) {
        char input[]={'J','a','V','a',' ','M','e','R','i','T','c','A','m','P','u','S'};
        Formatter name = new Formatter();
        for (int i = 0; i < input.length; i++) {
            if (i % 2 == 0) {
                name.format("%C", input[i]);
            } else {
                name.format("%c", input[i]);
            }
        }
        System.out.println(name);
    }
}


JaVa MERITCAMPUS
JAVA MeRiTcAmPuS
Compilation Error
Runtime Error

Doubts

Problems

Topic: Formatting Strings And Characters By Using Formatter

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App