aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes MindQ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "MindQ" Watch "MindQ" New topic
Author

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 correct answer is d
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