Hi Randall,
1 ) Answer Is ,
It'll give compile error in Line 2 ! You cannot assign
Object type reference to
String type variable.
By explicit casting you can make it to compile correctly,
Object o = new String("abcd");
String s = (String)o;
2)
Line 1 ,
first operand is false ,since the operator is
bitwise AND it'll evaluate the second operand as well, which gives a NullPointerException.
Line 2,
first operand is false , since the operator is
short circuit AND it'll not evalute the second operand & will not give a NullPointerException.
Line 3,
first operand is false , since the operator is
bitwise OR operator it'll evalute both of the operands which cause to give NullPointerException.
Line 4,
first operand is false , since the operator is
short circuit OR operator it should evaluate the second operand as well which again gives a NullPointerException.
So answer should be 1,3 & 4
Rgds,
Shan.