Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

question 42 1 pts given the following method header, which of these met…

Question

question 42
1 pts
given the following method header, which of these method calls is incorrect?
public void displayvalue(double x, int y);
displayvalue(a, b); // where a is a long and b is a byte
displayvalue(a, b); // where a is an int and b is a byte
displayvalue(a, b); // where a is a short and b is a long
all of these would give an error.

Explanation:

Brief Explanations

The method displayValue expects a double and an int as parameters. In the first option, a long cannot be directly passed as a double without an explicit conversion, and in the third option, a long cannot be passed as an int without an explicit conversion. In the second option, an int can be passed as an int and a byte can be promoted to an int automatically.

Answer:

A. displayValue(a, b); // where a is a long and b is a byte
C. displayValue(a, b); // where a is a short and b is a long
D. All of these would give an error.