Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!

# MindQ

Ragu Sivaraman
Ranch Hand
Posts: 464
17. If arr[] contains only positive integer values, what does this function do?
public int guessWhat( int arr[] )
{ int x= 0;
for( int i = 0; i < arr.length; i++ )
x = x < arr[i] ? arr[i] : x;
return x;
}
a) Returns the index of the highest element in the array
b) Returns true/false if there are any elements that repeat in the array
c) Returns how many even numbers are in the array
d) Returns the highest element in the array
e) Returns the number of question marks in the array

Can some explain it to me?

shrirang
Greenhorn
Posts: 3
the logic is nothing but the logic of finding highest number in the array.Only thing is that its conditional operator that is used.

Roopa Bagur
Ranch Hand
Posts: 267
d.returns the highest element in the array.
Originally posted by Ragu Sivaraman:
17. If arr[] contains only positive integer values, what does this function do?
public int guessWhat( int arr[] )
{ int x= 0;
for( int i = 0; i < arr.length; i++ )
x = x < arr[i] ? arr[i] : x;
return x;
}
a) Returns the index of the highest element in the array
b) Returns true/false if there are any elements that repeat in the array
c) Returns how many even numbers are in the array
d) Returns the highest element in the array
e) Returns the number of question marks in the array

Can some explain it to me?

Ragu Sivaraman
Ranch Hand
Posts: 464
Yup got it
Thankx guys