Which code fragment, when inserted at line 14, enables the code to print Mike Found?

Given: Which code fragment, when inserted at line 14, enables the code to print Mike
Found?

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)



Leave a Reply 3

Your email address will not be published. Required fields are marked *


pojo

pojo

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”);
}

xxx

xxx

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

obrain

obrain

Patient p2 = new patient (“Mike”)
so answare A.