Qtr No. 213, New Town Yehlanka Indore 454775
Consider the following Java code:
// Assume all the necessary imports are done
public class StudentManager{
public static void main(String[] args) {
List<String> names = new ArrayList<>();
names.add("John");
names.add("Jane");
names.add("Alex");
names.add("Emily");
String searchTerm = "Alex";
boolean containsSearchTerm = names.contains(searchTerm);
int indexOfSearchTerm = names.indexOf(searchTerm);
System.out.println("Contains Search Term: "+containsSearchTerm);
System.out.println("Index of Search Term: "+indexOfSearchTerm);
}
}
What will be the output of the above code when executed?
Contains Search Term: true, Index of Search Term: 2
Contains Search Term: false, Index of Search Term: 2
Contains Search Term: true, Index of Search Term: 3
Contains Search Term: false, Index of Search Term: 3
To get all Infosys Certified L1 Junior Java Programmer Exam questions Join Group https://bit.ly/infy_premium_group
We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.
Qtr No. 213, New Town Yehlanka Indore 454775
admin@prepflix.in