Examveda

What does the following piece of code do?
for (int i = 0; i < arr.length-1; i++)
{
    for (int j = i+1; j < arr.length; j++)
    {
        if( (arr[i].equals(arr[j])) && (i != j) )
        {
            System.out.println(arr[i]);
        }
    }
}

A. Print the duplicate elements in the array

B. Print the element with maximum frequency

C. Print the unique elements in the array

D. Prints the element with minimum frequnecy

Answer: Option A


This Question Belongs to Data Structure >> Searching Algorithms

Join The Discussion

Related Questions on Searching Algorithms