# Kathy's book - chapter 6 - question #7

Mansi Vyas

Greenhorn

Posts: 27

Corey McGlone

Ranch Hand

Posts: 3271

Damien Howard

Ranch Hand

Posts: 456

Mansi Vyas

Greenhorn

Posts: 27

posted 12 years ago

Sorry for not including the question. Here it is...

Which of the following are valid calls to Math.max? Choose all that apply.

A. Math.max(1,4)

B. Math.max(2.3, 5)

C. Math.max(1,3,5,7)

D. Math.max(-1.5, -2.8f)

In choice B, I think that the 5 is being implicity converted to a 5.0(double). In choice D, I think that -2.8f is being implicity promoted to a double. Both are invoking the following method signiture, double max(double a, double b).

Is this correct?

Thanks.

Mansi

Which of the following are valid calls to Math.max? Choose all that apply.

A. Math.max(1,4)

B. Math.max(2.3, 5)

C. Math.max(1,3,5,7)

D. Math.max(-1.5, -2.8f)

In choice B, I think that the 5 is being implicity converted to a 5.0(double). In choice D, I think that -2.8f is being implicity promoted to a double. Both are invoking the following method signiture, double max(double a, double b).

Is this correct?

Thanks.

Mansi

Andres Gonzalez

Ranch Hand

Posts: 1561

posted 12 years ago

Correct...

The thing to remember here is this order:

byte

short

int

long

float

double

So, for example, in option D. we have a float and a double, so we know that float can be

HTH

The thing to remember here is this order:

byte

short

int

long

float

double

So, for example, in option D. we have a float and a double, so we know that float can be

**implicitly**promoted to a double.HTH

*I'm not going to be a Rock Star. I'm going to be a LEGEND!* --Freddie Mercury