May 2021 1 17 Report
JAVA COMPUTER PROGRAMING !!!!?

Exactly one of the following correctly sets total to the number of p's grandchildren. Which one?

A.

Person p = new Person( "Fred" );

int total = p.numChildren();

B.

Person p = new Person( "Fred" );

int total = p.numChildren( p.numChildren() );

C.

Person p = new Person( "Fred" );

int total = 0;

for ( int k = 1 ; k <= p.numChildren() ; k++ )

{

total += p.numChildren();

}

D.

Person p = new Person( "Fred" );

int total = 0;

for ( int k = 1 ; k <= p.numChildren() ; k++ )

{

total += p.child( k ).numChildren();

}

E.

Person p = new Person( "Fred" );

int total = 0;

for ( int k = 1 ; k <= p.numChildren() ; k++ )

{

total += p.numChildren().child( k );

}

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 Q2A.ES - All rights reserved.