Create an account to track your scores
and create your own practice tests:
Test: Computer Science
Consider the code below:
String[] db = {"Harvey","Plutarch","Frege","Radulphus"};
ArrayList<String> names = new ArrayList<String>();
for(int i = 0; i < 12; i++) {
names.add(db[i % db.length]);
}
for(int i = 0; i < 12; i++) {
if(names.get(i).equals("Frege")) {
names.remove(i);
}
}
1. | What is the bug in the code above? |
The list will overrun its indices in the second loop.
There is an infinite loop in one of the two loops.
The list will use up all of the memory on the machine.
The .get method is buggy and likely to crash. It is better to use an Iterator.
There are no bugs.
Amirhossein
Certified Tutor
Certified Tutor
University of Tabriz, Bachelor of Science, Laser and Optical Engineering. Shahid Beheshti University, Master of Science, Opti...
Andrew
Certified Tutor
Certified Tutor
Louisiana State University Eunice, Bachelor of Science, Computer Software Engineering.
Computer Science Tutors in Top Cities:
Atlanta Computer Science Tutors, Austin Computer Science Tutors, Boston Computer Science Tutors, Chicago Computer Science Tutors, Dallas Fort Worth Computer Science Tutors, Denver Computer Science Tutors, Houston Computer Science Tutors, Kansas City Computer Science Tutors, Los Angeles Computer Science Tutors, Miami Computer Science Tutors, New York City Computer Science Tutors, Philadelphia Computer Science Tutors, Phoenix Computer Science Tutors, San Diego Computer Science Tutors, San Francisco-Bay Area Computer Science Tutors, Seattle Computer Science Tutors, St. Louis Computer Science Tutors, Tucson Computer Science Tutors, Washington DC Computer Science Tutors
Popular Courses & Classes
SAT Courses & Classes in San Diego, GRE Courses & Classes in Miami, LSAT Courses & Classes in Seattle, Spanish Courses & Classes in Phoenix, SSAT Courses & Classes in Phoenix, SAT Courses & Classes in New York City, SSAT Courses & Classes in Chicago, Spanish Courses & Classes in Seattle, SAT Courses & Classes in Miami, Spanish Courses & Classes in San Francisco-Bay Area
Popular Test Prep
SSAT Test Prep in New York City, LSAT Test Prep in Dallas Fort Worth, MCAT Test Prep in Washington DC, ISEE Test Prep in Los Angeles, ISEE Test Prep in Seattle, GRE Test Prep in Philadelphia, ISEE Test Prep in Philadelphia, LSAT Test Prep in San Francisco-Bay Area, LSAT Test Prep in Washington DC, ISEE Test Prep in Atlanta