Originally posted by Gong James:
Q119 Which of the following are true?
A A reference to an array can be cast to a reference to an Object.
B A reference to an array can be cast to a reference to a Cloneable.
C A reference to an array can be cast to a reference to a String.
D None of the above.
the given ans is:A,B.
My ans is:A.
Am I correct ?If not ,correct me Pls!!
You are always to the item!!!
Ans: A,B
How its becoz Every array implements the interfaces Cloneable and java.io.Serializable.
class
Test {
public static void main(String[] args) {
int ia1[] = { 1, 2 };
int ia2[] = (int[])ia1.clone();
System.out.print((ia1 == ia2) + " ");
ia1[1]++;
System.out.println(ia2[1]);
}
}
Pls refer JLS for further expln
Enjoy
Ragu