Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

clone help

 
indi anj
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was reading java book and i did not get the clone part.

int [] p = new int [100];
int [] s = (int[]) p.clone();

Which of the following statements will change the last value of p to 75?

A) p[99]=75; B)p[100]=75; C)s[99]=75; D)s[100]=75; E) two or more of the answers will chane i to 75
[ September 11, 2005: Message edited by: indi anj ]
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, what exactly is the question?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that part of the question is missing. The choices given don't make any sense based on the code snippet that you gave. I know it probably isn't part of your question, but it will help us understand the context so that we can provide an answer.

Layne
[ September 11, 2005: Message edited by: Layne Lund ]
 
shank ram
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question you have posed analyses your grasp of fundamental array concepts.

The last element of a array 'p' of 100 integer elements is addressed as what ... p[100] or p[99] ? - This is the first point to be understood.

After you successfully cloned the array 'p' ... will the change in an element of the clone ... here 's' ... reflect on the original 'p' ? - This is the second point.

So, write the code


Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic