i did not get this exercise...
int  p = new int ;
int  s = p;
Which of the following statements will change the last value of p to 75?
E) two or more of the answers will change p to 75
array index start from 0 therefore always keep in mind that the when you set the array length it will start from 0 and the last index is length-1.
So keeping that in mind last value in array will be at 99 index. Then there is another detail to remember that you are assingning the reference to array to another variable that is
which means a value changed in s is actually being changed in p not in s. keeping thi smind what can u see that which are ur answers?
If you got to change the value of the last value of p then,
Won't work since both are different and during declaration, only a reference of p would be passed to sand not p itself.
Java always uses its own type of pointers, when you create a new object and give it a name, in truth you are only making a pointer to that object by naming it, the object does not need a name. Arrays are indexed so an array of length 100 last element will be element 99
a) p=75; and C) s=75;
will both set the last value, therfore e) is the answer.
ps. if this is for some kind of assignment or class work writing a program and finding out for your self would probably be a better method of investigation!
Last edited by Waylander; 09-14-2005 at 05:05 AM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)