Hi , I am new here to post a message, but have been visiting javaranch for quite sometime
My query from JXAM:
Given the following definition:
String s = null;
Which code fragment will cause an exception of type NullPointerException to be thrown.
if ((s != null) & (s.length()>0))
if ((s != null) && (s.length()>0))
if ((s != null) | (s.length()>0))
if ((s != null) | | (s.length()>0))
None of the above.
The JXAM solution says 1, 2, 3, 4 are correct ans, however I feel the solution is wrong.
2 does not throw an exception .
Also I am not clear about the question.
Can someone explain to me please.
Thanks
Megha