Question 45
What will happen when you try compiling and running this code?
public class Ref{
public static void main(String argv[]){
Ref r = new Ref();
r.amethod(r);
}
public void amethod(Ref r){
int i=99;
multi(r);
System.out.println(i);
}
public void multi(Ref r){
r.i = r.i*2;
}
}
1) Error at compile time
2) An output of 99
3) An output of 198
4) An error at runtime
Answer to Question 45
--------------------------------------------------------------------------------
Question 46)
You need to create a class that will store unique object elements. You do not need to sort these elements but they must be unique.
What interface might be most suitable to meet this need?
1)Set
2)List
3)Map
4)Vector
Answer to Question 46
--------------------------------------------------------------------------------
Question 47)
Which of the following will successfully create an instance of the Vector class and add an element?