Create an account to track your scores
and create your own practice tests:
Test: Computer Science
Consider the following code:
public static int[] del(int[] a,int delIndex) {
if(delIndex < 0 || delIndex >= a.length) {
return null;
}
int[] ret = new int[a.length - 1];
for(int i = 0; i < a.length; i++) {
if(i != delIndex) {
ret[i] = a[i];
}
}
return ret;
}
1. | What is the error in the code above? |
You need to implement a swap for the values.
The use of the array index i is incorrect.
The intial conditional (i.e. the if statement) has incorrect logic.
There is a null pointer exception.
The loop is infinite.
Ping
Certified Tutor
Certified Tutor
The University of Texas at Dallas, Bachelor of Science, Computer Science. University of North Texas, Master of Arts, Education.
James
Certified Tutor
Certified Tutor
Georgia Institute of Technology-Main Campus, Current Undergrad Student, Computer Science.
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
GMAT Courses & Classes in Chicago, GRE Courses & Classes in Chicago, SSAT Courses & Classes in Miami, Spanish Courses & Classes in San Diego, GRE Courses & Classes in New York City, MCAT Courses & Classes in Chicago, Spanish Courses & Classes in Los Angeles, GMAT Courses & Classes in New York City, SAT Courses & Classes in Washington DC, LSAT Courses & Classes in San Francisco-Bay Area
Popular Test Prep
ISEE Test Prep in Los Angeles, GMAT Test Prep in New York City, SSAT Test Prep in San Diego, GMAT Test Prep in Chicago, SAT Test Prep in New York City, MCAT Test Prep in Seattle, ACT Test Prep in Chicago, LSAT Test Prep in San Francisco-Bay Area, SSAT Test Prep in Los Angeles, ISEE Test Prep in Atlanta
