Computer Science, asked by narendrasinghcm, 6 months ago

predict the return data type of the following:
i) int p; double q:
r = p+q;
System.out.println(r);
ii) float m;
p = m/3*(Math.pow(4,3));
System.out.println(p);

PLZ GIVE THE EXACT ANSWERS ​

Answers

Answered by Anonymous
9

Answer:

There is a phenomenon in Java called "Type Conversion". In this phenomenon, when there is a mixed expression (with different data types), the resulting type is always the datatype which is of higher order.

The hierarchy of datatypes is:

byte

char

short

int

long

float

double.

Thus, double is the highest one.

In the above expression r = p+q   where p is integer type and q is double type, the resulting value r will be of double type.

Because, double is below int in the hierarchical table, so its range of values and preference is more.

Explanation:

Answered by abhijeetnivangune
0

Answer:

Please see attached image.

Attachments:
Similar questions