103k views
2 votes
Assume that the following method header is for a method in class A.

public void displayValue (int value)

Assume that the following code segments appear in another method, also in class A. Which contains a legal call to the displayValue method?

A. int x = 7;
void displayValue(x);
B. int x = 7;
displayValue(x);
C. int x = 7;
displayValue(int x);
D. int x = 7;
displayValue(x)

User Jim Paris
by
5.1k points

1 Answer

7 votes

Answer:

The answer to the given question is option "B".

Step-by-step explanation:

In the question it is given that there is a method name is "displayValue()" is defined in this method we pass an integer variable that is "value" and in this method, we calculate some values, and call this method So, the correct code for calling this method is the option "B" and others options are not correct that can be described as:

  • In option, A Calling time of the function we do not use the return type, That's why this option is not correct.
  • In option, C Calling time of the function we do not pass any data type of variable, That's why this option is not correct.
  • In option, D we do not use semicolon in the function call, which is wrong.

That's why option "B" is correct.

User Tema
by
5.3k points