C Addressing the element s1[ 1 ] produces a null value.
D Addressing the element s2[ 1 ] produces an empty String.
Your recorded answer B,C Answer given:A,B
I felt B,C All the arrays are intialized by default. So elements of object arrays will be assigned to null. But here its given array object itself is assigned to null .Is it specific to static arrays or string arrays??
Cheers Smitha [ August 24, 2005: Message edited by: Barry Gaunt ]
A The logical test x == null will return true. B The value retrieved by addressing y[ 0 ] is 0. C Addressing the element s1[ 1 ] produces a null value.
A is true x is declared as static integer array static fileds get initialized during class load... so x is assigned to null since arrays are treated as objects in java B is true arrays elements get default values when initialized C is False since S="" and not null since it is String object
A is correct because x is an instance variable pointing to an array. Since arrays are objects and all instance variables are initialized to their default values, x will contain null, the default value for objects. Note, the array hasn't actually be instantiated yet.
B is correct because all elements of a newly initialized array are set to their default values. Since B is pointing to an array of integers and the initial value for integers is 0, all 20 values in the array referenced by y are 0.
C is incorrect because the array has not been initialized. Only the instance variable has been created. The variable s1 points to null just like the int array x does. Trying to access s1 will throw an exception.
D is incorrect. Remember the rule from answer B: all elements of a newly initialized array are set to their default values. Since Strings are objects, all the elements of s2 are initialized to null, NOT to empty Strings.
Hope that helps! [ August 24, 2005: Message edited by: Ryan Kade ]