JP Morgan Interview Question
Java DevelopersCountry: India
Interview Type: Written Test
100
100 -- // inside integer array there is and another array which is object. hence it would be a shallow clone instead of deep.
5 -- // since we are creating new object copy[1] = new int[]{300,400,500}; now copy[1] will refer to completely new memory address and any further changes wont affect shallow clone of data.
400
Hope this helps.
Thanks
Answer:
- Flash May 14, 2017100
100
5
400
Remember the difference between cloning a primitive and an object (an 'Array' object in this case)