
Respuesta :
The correct option: double result = secret(4, 4.0); is lines of code will successfully compile if they are placed in a method of the same class as secret.
Explain the term compiling?
- When creating a Java program, the text that can be read by programmers is converted into bytecodes, that are platform-independent commands for the Java Virtual Machine (JVM).
As explained in the following method-
public double secret(int x, double y)
{
return x/2.0;
}
This function's return type is double, so any variable where the result will be stored should also have a double type.
The right choice, therefore, is double result = secret(4, 4.0);
All other choices are false and will result in an error.
for instance:
secret(4, 4); int result;
While you pass all integer variables, the function secret in it only accepts the first integer plus second double inputs.
int result = secret(4, 4.0);
Double values are not permitted to be stored in integer.
In the formula double result = secret(4.0, 4.0), you are giving the wrong kind of argument.
To know more about the compiling, here
https://brainly.com/question/14158853
#SPJ4
The complete question is-
Consider the following method.
public double secret(int x, double y) { return x/2.0; }
Which of the following lines of code, if located in a method in the same class as secret, will compile without error?
int result = secret(4, 4);
double result = secret(4.0, 4);
int result = secret(4, 4.0);
double result = secret(4.0, 4.0);
double result = secret(4, 4.0);