subject
Computers and Technology, 20.08.2020 18:01 nova97

Suppose that f contains an instance of the Family class whose myMembers instance variable contains at least one instance of Person. Which of the following code fragments outputs the age of the oldest Person in myMembers? I. Person p = f. myMembers. get( 0 );
for ( int i = 0 ; i < f. myMembers. size() ; i++ )
{
if ( p. getAge() < f. myMembers. get( i ).getAge() )
p = f. myMembers. get( i );
}
System. out. println( p. myAge() );

II. int i = f. getMembers().size() - 1;
int age = 0;
while ( i >= 0 )
{
if ( f. getMembers().get( i ).getAge() > age )
age = f. getMembers().get( i ).getAge();
i--;
}
System. out. println( age );

III. int n = f. getMembers().size();
Person p = null;
for ( int i = 0 ; i < n ; i++ )
{
if ( i == 0
|| f. getMembers().get( i ).getAge() > p. getAge() )
{
p = f. getMembers().get( i );
}
}
System. out. println( p. getAge() );

a. I only
b. II only
c. III only
d. II and III only
e. I, II, and III

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 05:00, edjiejwi
Lisa has a section of her document that she would like to include in the index. which option should lisa choose? mark index mark entry insert endnote add text
Answers: 3
image
Computers and Technology, 23.06.2019 02:30, woodpeckerdeejpe8wvh
How to launch an app: steps to be successful? launching an app is a great idea, but it’s not that easy as we supposed to think. the majority of mobile applications don’t generate revenue because companies aren’t ready to be competitive. referring to our experience in successfully building and launching apps we hope to you omit these difficulties. we are going to talk about ideas, marketing, testing your product, its development, distribution and support. you will learn 8 product launch stages to succeed.
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, trippie4life
3. when you right-click a linked spreadsheet object, what commands do you choose to activate the excel features? a. linked worksheet object > edit b. edit data > edit data c. linked spreadsheet > edit d. object > edit data
Answers: 2
image
Computers and Technology, 23.06.2019 13:00, torresnoemi899
Which of the following statements is false? a. a class can directly inherit from class object. b. if the class you're inheriting from declares instance variables as private, the inherited class can access those instance variables directly. c. a class's instance variables are normally declared private to enforce good software engineering. d. it's often much more efficient to create a class by inheriting from a similar class than to create the class by writing every line of code the new class requires.
Answers: 3
You know the right answer?
Suppose that f contains an instance of the Family class whose myMembers instance variable contains a...

Questions in other subjects: