A class was given in the main() method: Stack s1=new Stack(); Stack s2=new Stack(); method(s1,s2); System.out.println("s1" + s1+" "+ "s2" + s2); the method is so defined: public static void method(Stack s1,Stack s2){ s1.push(new Integer(100)); s2=s1 } what is the output ? I choose E A. Compile error, because ... B. Runtime error, because ... C. s1[100]s2[100] D. s1[ ]s2[ ] E. s1[100]s2[ ] F. s1[ ]s2[100] Need to know the methods of Stack: push(), pop() and peek(). Stack is part of the java.util package - it is a subclass of Vector so I guess it is part of the objectives. Kai: Many thought this is a Collection question, but I believe it is more about argument passing. -Arun
hi Chiru, youre wrong because you in fact you have 4 references to 2 objects when you say s1.push(100) you change the object1 when you say s1 = s2 then only the local copy of s1 refers to s2 when the method ends s1 still refers to the first object if find it poor programming you should use differnt var names. robert