Sail E0 Webinar
Question
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]);        }    }}
Options:
A .  Print the duplicate elements in the array
B .  Print the element with maximum frequency
C .  Print the unique elements in the array
D .  None of the mentioned
Answer: Option A


The print statement is executed only when the items are equal and their indices are not.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers