Given: Which code fragment, when inserted at line 14, enables the code to print Mike
Found?
A.
int f = ps.indexOf(p2);
B.
int f = ps.indexOf {new patient (“Mike”)};
C.
int f = ps.indexOf (patient(“Mike”));
D.
patient p = new Patient (“Mike”); int f = pas.indexOf(P)
A is correct
List ps= new ArrayList();
patient p2 = new patient(“Mike”);
ps.add(p2);
int f = ps.indexOf(p2);
if(f>=0){
System.out.println(“Found Mike”);
}
import java.util.ArrayList;
import java.util.List;
class Patient {
String name;
public Patient(String name){
this.name = name;
}
}
public class Access {
public static void main(String[] args){
List ps= new ArrayList();
Patient p2 = new Patient(“Mike”);
ps.add(p2);
int f = ps.indexOf(p2);
if(f>=0){
System.out.println(“Found Mike”);
}
}
}
b
Patient p2 = new patient (“Mike”)
so answare A.