Question: How does using findMax ( ) improve the code? public static int findMax ( int val 1 , int val 2 ) { int max;

How does using findMax() improve the code?
public static int findMax(int val1, int val2){
int max;
if (val1> val2){
max= val1;
}
else{
max=val2
}
return max;
}
public static void main(String args[]){
int max1;
int max2;
int max3;
max1=findMax(15,7);
max2=findMax(100,101);
max3=findMax(20,30);
}
Using findMax() makes main() run faster
Using findMax() decreases redundant code
Using findMax() reduces the number of variables
Using findMax() does not improve the code
 How does using findMax() improve the code? public static int findMax(int

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!