a) Look at the following method header: public static void showValue The followi
ID: 3543744 • Letter: A
Question
a) Look at the following method header:
public static void showValue
The following code has a call to the showValue method. Fin the error.
int x =8;
showValue(int); //Error!
b)Find the error in the following method definition:
public static double timesTwo(double num)
{
double result = num*2;
}
For a, I think there is an error in the showValue(int); because it is suppose to be showValue(x); instead, but I'm not really sure.
For b, there is a semicolon missing on the first line. If anyone cal help?
Explanation / Answer
a)calling should be as
showValue(x); // because u have to put the value not datatype
b)
public static double timesTwo(double num)
{
double result = num*2;
return result; // here is error
}
in this all thing is ok ,,,,semicolon is not required in first line because
it is a method definition ..
altthough u have to return some value because method is returnig double
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.