help with inputForMethod_1_B(), thanks package code; import java.util.ArrayList;
ID: 3686188 • Letter: H
Question
help with inputForMethod_1_B(), thanks
package code;
import java.util.ArrayList;
public class Inputs {
// Study the definition of the method
// method_1
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_1,
// causes method_1 to return the value 20.
public ArrayList<String> inputForMethod_1_A() {
ArrayList<String>retVal = new ArrayList<String>();
retVal.add("hello");
retVal.add("World");
retVal.add("xxxxxxxxxx");
retVal.add("");
return retVal;
}
// Study the definition of the method
// method_1
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_1,
// causes method_1 to return the value 6.
public ArrayList<String> inputForMethod_1_B() {
return null;
}
Explanation / Answer
import java.util.ArrayList;
public class Inputs {
// Study the definition of the method
// method_1
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_1,
// causes method_1 to return the value 20.
public ArrayList<String> inputForMethod_1_A() {
ArrayList<String>retVal = new ArrayList<String>();
retVal.add("hello");
retVal.add("World");
retVal.add("xxxxxxxxxx");
retVal.add("");
return retVal;
}
// Study the definition of the method
// method_1
// defined in the class Methods.
// Define the following method so it returns a value which,
// if passed as an argument to method_1,
// causes method_1 to return the value 6.
public static ArrayList<String> inputForMethod_1_B() {
ArrayList<String> list = new ArrayList<String>();
list.add("Hi");
list.add("Good");
list.add("");
return list;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.