Answered step by step
Verified Expert Solution
Question
1 Approved Answer
User Consider the correctness of the following two methods that add an element x at index i in an ArrayList. public void add ( int
User
Consider the correctness of the following two methods that add an element x at index i in an ArrayList.
public void addint i T x
if i i n throw Exception
if n alength resize;
for int jn; j i; j
aj aj;
ai x;
n;
public void addint i T x
if i i n throw Exception
if n alength resize;
for int ji; j n; j
aj aj;
ai x;
n;
Select all options below that are true.
A Neither method is correct
B The second method is correct
C The first method is correct
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started