//Inputs.java code package code; import java.util.ArrayList; public class Inputs
ID: 3686811 • Letter: #
Question
//Inputs.java code
package code;
import java.util.ArrayList;
public class Inputs {
// Study the definition of the method
// method_2
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_2,
// causes method_2 to return the value 20.
public ArrayList<Integer> inputForMethod_2() {
return null;
}
// Study the definition of the method
// method_3
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_3,
// causes method_3 to return the value 20.
public ArrayList<String> inputForMethod_3() {
return null;
}
// Study the definition of the method
// method_4
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_4,
// causes method_4 to return the value 20.
public ArrayList<String> inputForMethod_4() {
return null;
}
Explanation / Answer
class Inputs {
// Study the definition of the method
// method_2
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_2,
// causes method_2 to return the value 20.
public ArrayList<Integer> inputForMethod_2() {
ArrayList<Integer> input=new ArrayList<Integer>();
for(int i=0;i<10;i++)
input.add(1);
return input;
}
// Study the definition of the method
// method_3
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_3,
// causes method_3 to return the value 20.
public ArrayList<String> inputForMethod_3() {
ArrayList<String> input=new ArrayList<String>();
for(int i=0;i<10;i++)
input.add("a");
return input;
}
// Study the definition of the method
// method_4
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_4,
// causes method_4 to return the value 20.
public ArrayList<String> inputForMethod_4() {
ArrayList<String> input=new ArrayList<String>();
for(int i=0;i<10;i++)
input.add("a");
return input;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.