This week's book giveaway is in the OCAJP 8 forum.We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!See this thread for details.
Big Moose Saloon
 Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies Register / Login Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!

# MindQ

Ragu Sivaraman
Ranch Hand

Joined: Jul 20, 2001
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

Joined: Aug 22, 2001
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

Joined: Nov 03, 2000
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

Joined: Jul 20, 2001
Posts: 464
Yup got it
Thankx guys

I agree. Here's the link: http://aspose.com/file-tools

subject: MindQ