jason roberts

Greenhorn
+ Follow
since Jun 23, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jason roberts

I think I get it now, the resulting array is used in the for-each loop, not just the initial array.

Thanks for your help.
Hi Sravani,

In the first iteration i=1 which sets arr[1]=0 .The resulting array is {1,0,3,4}
In the second iteration i=0 which sets arr[0]=0. The resulting array is {0,0,3,4}
In the third iteration i=3 which sets arr[3]=0. The resulting array is {0,0,3,0}
In the last iteration i=0 which sets arr[0]=0. The resulting array is {0,0,3,0}



I guess I don't understand why it isn't:

In the first iteration i=1 which sets arr[1]=0 .The resulting array is {1,0,3,4}
In the second iteration i=2 which sets arr[2]=0. The resulting array is {1,0,0,4}
In the third iteration i=3 which sets arr[3]=0. The resulting array is {1,0,0,0}
In the last iteration i=4 which attempts to set arr[4]=0, and throws an exception.

I thought that since the array is {1,2,3,4}, the index values on each iteration would be 1,2,3 and 4.

Please help.

Thanks.
Can someone explain why the output to the following code is: 0 0 3 0



I would think there would be an ArrayOutOfBounds exception in the first for loop because it tries to set arr[4] = 0.

Thanks.
Makes sense now...Thanks alot!
Hi all,

I am taking a practice exam and don't understand the answer to the following question:

Consider the following code:



What is the result?

A. Car
B. Vehicle
C. Compiler error at line 3
D. Compiler error at line 5
E. Exception thrown at runtime

I thought the answer was D, but apparently I'm wrong....it's A.

Why can class PE14 override the run() method if it is declared as private in class Vehicle?

Thanks.

-Jason