Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class RestInPeaceANR {
    public static void main(String[] args) {
        List<String> words = new ArrayList<String>();
        words.add("Rest"); words.add("In"); words.add("Peace");
        int index = 0;
        for (String word : words) {
            System.out.print(word + " ");
            words.set(index++, word.toUpperCase());
        }
        Collections.reverse(words);
        for (String word : words) {
            System.out.print(word.charAt(--index));
        }
    }
}


Rest In Peace SNP
Rest In Peace anR
Rest In Peace ANR
REST IN PEACE ANR
Compilation Error or Runtime Error

Doubts

Problems

Topic: Collection Framework 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