Hi Guys , Confusion ....confusion ...Confusion .
This is a mockup Question .
class Practice{
public void method(int arr[]){
arr[0] = 10;
}
public static void main(
String[] args){
int[] small = {1,2,3};
Practice t= new Practice10();
t.method(small);
System.out.println(small[0]);
}
}
When I saw this question the first thing that came to my mind is the fact that Non -Static methods cannot be reference from static context .
So I thought this would result in a compile time error . But when I executed the program it executed correctly . Ok that was my first question .
I was thinking of the output for this program .
I thought coz in
Java method calling is by "pass by value" , I thought after the method call t.method(small); the output would be 1 but to my surprise the answer was 10
.
Can anyone please clear my doubts ? I would really appreciate your help .
Regards,
Rakesh
[ October 05, 2007: Message edited by: Rakesh Yelugoila ]