Hi,
Following question is from a mock exam and there is nothing wrong with question and answer.
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
Given answer is 'B' and 'D'. i do agree with answer.
Should i expect these kind of answers where one answer('B') is a subset of another answer('D'). just wanna make sure.
Please do reply.
regards
vivek