Menu
Question Index
...

What will be the output of the following program?

public class KillPiracy {

    public static void main(String[] args) {
        args = new String[]{"lliK", "ycariP"};
        int i = 0;
        for (String arg : args) {
            process(args, i++);
            System.out.print(arg + " ");
        }
    }

    private static void process(String[] args, int i) {
        args[args.length - i - 1] = new StringBuffer(args[args.length - i - 1]).reverse().toString();
        System.out.print(args[args.length - i - 1] + " ");
    }
}


Piracy lliK Kill ycariP
Piracy lliK Kill Piracy
Kill Piracy Kill Piracy    
Some other output or Compilation Error or Runtime Error

Doubts

Problems

Topic: Java StringBuffer, reverse() - Reverse A String In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App