public static in max(int a, int b) { int result; if(a > b) result = a; else resu
ID: 3851394 • Letter: P
Question
public static in max(int a, int b) { int result; if(a > b) result = a; else result = b; return result; } public static double max(int a, double ){ double result; if (a > b) result = a; else result = b; return result * 2; } public static void main(String[] args){ int x = 2, y = 5 int z = max(x,y); int u = max(maxy,2.0); } } what is the return type of max( int a, int b) method what is the return type of max( int a, duoble b) method what will be the value of variable z what will be the value of variable u what is the argument of main method(variable name and type)
Explanation / Answer
1)Answer for retunr type of max(int a,int b) is int
Given method is:
public static int max(int a, int b)
{
int result;
if(a>b)
{
result = a;
}
else
{
result = b;
}
return result;
}
Passing x=2, and y=5, so it returns int data type(The bigger value of both)
2)Return type of max(int a,double b) is double.
The given method is:
public static double max(int a, double b )
{
double result;
if (a > b) result = a;
else result = b;
return result * 2;
}
it returns double data type.
3)value of z=5 since int max(int a, int b) method retuns the bigger value among x=2 and y=5
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.