Menu
Question Index
...

What will be the output of the following program?

public class Printstatment14
{
    public static void Elements(int[] arr)
    {
        for (int i = 0; i < arr.length; i++)
        {
            boolean isValid = false;
            for (int j = 0; j < i; j++)
            {
                if (arr[i] == arr[j])
                {
                    isValid = true;
                    break;
                }
            }
            if (!isValid)
            {
                System.out.print(arr[i] + " ");
            }
        }
    }
    public static void main(String a[])
    {
        int[] nums = {5, 2, 7, 2, 4, 7, 8, 2, 3};
        Printstatment14.Elements(nums);
    }
}


5 2 7 4 8 3
2 7
4 7 8 2
2
Compilation Error or Runtime Error

Doubts

Problems

Topic: Unknown

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App