Hi all
This is a question from Mock Exam
1
String s = null;
2 if ( s != null & s.length() > 0)
3 System.out.println("s != null & s.length() > 0");
4 if ( s != null && s.length() > 0)
5 System.out.println("s != null & s.length() > 0");
6 if ( s != null | | s.length() > 0)
7 System.out.println("s != null & s.length() > 0");
8 if ( s != null | s.length() > 0)
9 System.out.println("s != null | s.length() > 0");
Which of the following lines throwing null pointer exception
A. 2,4
B. 6,8
C. 2,4,6,8
D. 2,6,8
Correct answer is D
But I could not get logic behind it clearly
Can anyone be of any help in this regard ?