Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class Status {
    public static void main(String[] args) {
        List list = new ArrayList<String>();
        list.add("SRIT");
        list.add("JNTUA");
        list.add("SVIT");
        list.add("SKD");
        list.add("CRIT");
        for (int i = 0; i < list.size();) {
            switch (list.get(i)) {
                case "JNTUA" :
                    System.out.println("Number 1");
                case "SVIT" :
                    System.out.println("Number 3");
                case "SRIT" :
                    System.out.println("Number 2");
                    break;
                case "CRIT" :
                    System.out.println("Number 4");
                    break;
                case "SKD" :
                    System.out.println("Number 5");
                    break;
            }
            break;
        }
    }
}


Number 2
Number 1
Number 3
Number 2
Number 2
Number 1
Number 3
Some other output
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